Files
Yumi/src/discord/Invite.ts
T

45 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-06-06 14:59:53 +07:00
import { Message, CommandInteraction, Interaction } from 'discord.js';
2022-03-03 20:56:49 +07:00
2022-06-06 14:59:53 +07:00
import Environment from '../providers/Environment';
import DiscordProvider from '../providers/Discord';
import Users from '../services/Users';
import DiscordModule, { HybridInteractionMessage } from '../utils/DiscordModule';
import { sendHybridInteractionMessageResponse, makeInfoEmbed } from '../utils/DiscordMessage';
2021-09-18 05:19:40 -07:00
const EMBEDS = {
INVITE_INFO: (data: Message | Interaction) => {
let message;
2022-06-06 14:59:53 +07:00
if (Users.isDeveloper(data.member?.user.id!) || !Environment.get().PRIVATE_BOT)
2021-09-18 05:19:40 -07:00
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)`;
2022-06-06 14:59:53 +07:00
2021-09-18 05:19:40 -07:00
return makeInfoEmbed({
title: `Invite`,
2022-06-06 14:59:53 +07:00
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:19:40 -07:00
});
2021-09-18 05:44:44 -07:00
}
2022-06-06 14:59:53 +07:00
};
2021-09-16 23:55:08 -07:00
2022-03-03 20:56:49 +07:00
export default class Invite extends DiscordModule {
2022-06-06 14:59:53 +07:00
public id: string = 'Discord_Invite';
public commands = ['invite'];
public commandInteractionName = 'invite';
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-06-06 14:59:53 +07:00
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
2022-03-03 20:56:49 +07:00
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) {
2022-06-06 14:59:53 +07:00
return await sendHybridInteractionMessageResponse(data, {
embeds: [EMBEDS.INVITE_INFO(data.getRaw())]
});
2021-09-16 23:55:08 -07:00
}
2022-06-06 14:59:53 +07:00
}