April/commands/misc/say.mjs

44 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-09-13 21:12:45 +02:00
import { SlashCommandBuilder } from 'discord.js';
2023-09-13 21:12:45 +02:00
export default {
data: new SlashCommandBuilder()
.setName('say')
.setDescription('Faire envoyer un message au bot')
.setDefaultMemberPermissions(0x8)
.addStringOption(option =>
option.setName('message')
.setDescription('Message à envoyer')
.setRequired(true))
.addChannelOption(option =>
option.setName('destination')
.setDescription('Sélectionnez le salon où envoyer le message!')
2023-09-13 21:12:45 +02:00
.setRequired(false))
.addStringOption(option =>
option.setName('reply')
.setDescription('Id du message auquel répondre!')
.setRequired(false)),
async execute(interaction) {
let msgtosend = interaction.options.getString('message');
msgtosend = msgtosend.substring(0,2000);
let channeltosend = interaction.options.getChannel('destination');
if (!channeltosend) {
channeltosend = interaction.channel
}
2023-09-13 21:12:45 +02:00
const replyMessageId = interaction.options.getString('reply') || null;
try {
2023-09-13 21:12:45 +02:00
channeltosend.send({ content: msgtosend, reply: { messageReference: replyMessageId }})
await interaction.reply({
content: "Message envoyé !",
ephemeral: true
})
} catch {
await interaction.reply({
content: "Erreur : Je n'ai probablement pas la permission d'envoyer des messages ou le message est trop long",
ephemeral: true
})
}
},
};