Files
Yumi/src/discord/Invite.ts
T

40 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-03-03 20:56:49 +07:00
import DiscordModule, { HybridInteractionMessage } from "../utils/DiscordModule";
2021-09-18 05:19:40 -07:00
import { Message, CommandInteraction, Interaction } from "discord.js";
2022-03-03 20:56:49 +07:00
import { sendHybridInteractionMessageResponse, makeInfoEmbed } from "../utils/DiscordMessage";
2021-09-16 23:55:08 -07:00
import DiscordProvider from "../providers/Discord";
2021-09-18 05:19:40 -07:00
import Users from "../services/Users"
import Environment from "../providers/Environment";
const EMBEDS = {
INVITE_INFO: (data: Message | Interaction) => {
let message;
if(Users.isDeveloper(data.member?.user.id!) || !Environment.get().PRIVATE_BOT)
message = `[Invite ${DiscordProvider.client.user?.username} to your server!](https://discord.com/api/oauth2/authorize?client_id=${DiscordProvider.client.user?.id}&permissions=0&scope=bot%20applications.commands)`;
return makeInfoEmbed({
title: `Invite`,
description: message || `${DiscordProvider.client.user?.username}'s invite is currently private. Only the developers can add me to another server`,
user: (data instanceof Interaction) ? data.user : data.author
});
2021-09-18 05:44:44 -07:00
}
}
2021-09-16 23:55:08 -07:00
2022-03-03 20:56:49 +07:00
export default class Invite extends DiscordModule {
public id: string = "Discord_Invite";
public commands = ["invite"];
public commandInteractionName = "invite";
2021-09-18 05:19:40 -07:00
2022-03-03 20:56:49 +07:00
async GuildOnModuleCommand(args: any, message: Message) {
await this.run(new HybridInteractionMessage(message), args);
2021-09-16 23:55:08 -07:00
}
2022-03-03 20:56:49 +07:00
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
await this.run(new HybridInteractionMessage(interaction), interaction.options);
2021-09-16 23:55:08 -07:00
}
2022-03-03 20:56:49 +07:00
async run(data: HybridInteractionMessage, args: any) {
return await sendHybridInteractionMessageResponse(data, { embeds:[EMBEDS.INVITE_INFO(data.getRaw())] });
2021-09-16 23:55:08 -07:00
}
}