mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Support Interaction
This commit is contained in:
+29
-7
@@ -1,4 +1,4 @@
|
|||||||
import { Message, Permissions } from "discord.js";
|
import { Message, Permissions, CommandInteraction } from "discord.js";
|
||||||
import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessage, sendReply, makeErrorEmbed } from "../utils/DiscordMessage";
|
import { getEmotes, makeSuccessEmbed, makeProcessingEmbed, sendMessage, sendReply, makeErrorEmbed } from "../utils/DiscordMessage";
|
||||||
import DiscordProvider from "../providers/Discord";
|
import DiscordProvider from "../providers/Discord";
|
||||||
|
|
||||||
@@ -10,22 +10,44 @@ export default class Say {
|
|||||||
if(message.member === null) return;
|
if(message.member === null) return;
|
||||||
if(message.guild === null) return;
|
if(message.guild === null) return;
|
||||||
|
|
||||||
if (!message.member.permissions.has([Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.MANAGE_CHANNELS]))
|
await this.sendSayMessage(false, message, args);
|
||||||
return await sendReply(message, {
|
}
|
||||||
|
|
||||||
|
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, {
|
||||||
embeds: [makeErrorEmbed ({
|
embeds: [makeErrorEmbed ({
|
||||||
title: 'You need ``VIEW_CHANNEL, SEND_MESSAGES and MANAGE_CHANNELS`` permission on this guild!',
|
title: 'You need ``VIEW_CHANNEL, SEND_MESSAGES and MANAGE_CHANNELS`` permission on this guild!',
|
||||||
user: message.author
|
user: isSlashCommand ? data.user : data.author
|
||||||
})]
|
})]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if(args.length === 0)
|
if(args.length === 0)
|
||||||
return await sendReply(message, {
|
return await sendReply(data, {
|
||||||
embeds: [makeErrorEmbed({
|
embeds: [makeErrorEmbed({
|
||||||
title: `No message defined`,
|
title: `No message defined`,
|
||||||
user: message.author
|
user: isSlashCommand ? data.user : data.author
|
||||||
})]
|
})]
|
||||||
});
|
});
|
||||||
|
|
||||||
await message.channel.send({ content: args.join(" ") });
|
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(" ") });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user