Files
Yumi/src/discord/Invite.ts
T

42 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-09-18 05:19:40 -07:00
import { Message, CommandInteraction, Interaction } from "discord.js";
import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessage, sendMessageOrInteractionResponse, 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-16 23:55:08 -07:00
export default class Invite {
2021-09-18 05:19:40 -07:00
2021-09-16 23:55:08 -07:00
async onCommand(command: string, args: any, message: Message) {
if(command.toLowerCase() !== 'invite') return;
2021-09-18 05:19:40 -07:00
await this.process(message, args);
2021-09-16 23:55:08 -07:00
}
async interactionCreate(interaction: CommandInteraction) {
2021-09-18 05:19:40 -07:00
if(interaction.isCommand()) {
if(typeof interaction.commandName === 'undefined') return;
if((interaction.commandName).toLowerCase() !== 'invite') return;
await this.process(interaction, interaction.options);
}
2021-09-16 23:55:08 -07:00
}
2021-09-18 05:19:40 -07:00
async process(data: Interaction | Message, args: any) {
const isSlashCommand = data instanceof CommandInteraction && data.isCommand();
const isMessage = data instanceof Message;
2021-09-16 23:55:08 -07:00
2021-09-18 05:19:40 -07:00
return await sendMessageOrInteractionResponse(data, { embeds:[EMBEDS.INVITE_INFO(data)] });
2021-09-16 23:55:08 -07:00
}
}