2021-09-17 05:21:01 -07:00
|
|
|
import { Message, Permissions, CommandInteraction } from "discord.js";
|
2021-09-16 01:18:30 -07:00
|
|
|
import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessage, sendReply, makeErrorEmbed } from "../utils/DiscordMessage";
|
2021-09-15 04:10:42 -07:00
|
|
|
import DiscordProvider from "../providers/Discord";
|
|
|
|
|
|
|
|
|
|
export default class Say {
|
|
|
|
|
async onCommand(command: string, args: any, message: Message) {
|
|
|
|
|
if(command.toLowerCase() !== 'say') return;
|
|
|
|
|
|
|
|
|
|
if(!message.guildId) return;
|
|
|
|
|
if(message.member === null) return;
|
|
|
|
|
if(message.guild === null) return;
|
|
|
|
|
|
2021-09-17 05:21:01 -07:00
|
|
|
await this.sendSayMessage(false, message, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async interactionCreate(interaction: CommandInteraction) {
|
|
|
|
|
if(typeof interaction.commandName === 'undefined') return;
|
|
|
|
|
if((interaction.commandName).toLowerCase() !== 'say') return;
|
|
|
|
|
await this.sendSayMessage(true, interaction, interaction.options.getString('message'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async sendSayMessage(isSlashCommand: boolean, data: any, args: any) {
|
|
|
|
|
|
|
|
|
|
if (!data.member.permissions.has([Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.MANAGE_CHANNELS]))
|
|
|
|
|
return await sendReply(data, {
|
2021-09-15 04:10:42 -07:00
|
|
|
embeds: [makeErrorEmbed ({
|
|
|
|
|
title: 'You need ``VIEW_CHANNEL, SEND_MESSAGES and MANAGE_CHANNELS`` permission on this guild!',
|
2021-09-17 05:21:01 -07:00
|
|
|
user: isSlashCommand ? data.user : data.author
|
2021-09-15 04:10:42 -07:00
|
|
|
})]
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-17 05:21:01 -07:00
|
|
|
|
2021-09-15 04:10:42 -07:00
|
|
|
if(args.length === 0)
|
2021-09-17 05:21:01 -07:00
|
|
|
return await sendReply(data, {
|
2021-09-15 04:10:42 -07:00
|
|
|
embeds: [makeErrorEmbed({
|
|
|
|
|
title: `No message defined`,
|
2021-09-17 05:21:01 -07:00
|
|
|
user: isSlashCommand ? data.user : data.author
|
2021-09-15 04:10:42 -07:00
|
|
|
})]
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-17 05:21:01 -07:00
|
|
|
if(isSlashCommand) {
|
|
|
|
|
await data.channel.send({ content: args });
|
|
|
|
|
await data.reply({ ephemeral: true, embeds: [makeSuccessEmbed({
|
|
|
|
|
title: `Successfully said`,
|
|
|
|
|
user: isSlashCommand ? data.user : data.author
|
|
|
|
|
})] });
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
await data.channel.send({ content: args.join(" ") });
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-15 04:10:42 -07:00
|
|
|
}
|
|
|
|
|
}
|