-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendMessage.js
More file actions
26 lines (20 loc) · 1.02 KB
/
sendMessage.js
File metadata and controls
26 lines (20 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('send_message')
.setDescription('Send message to specified channel')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option => option.setName('message').setDescription('Announcement message').setRequired(true))
.addStringOption(option => option.setName('channel').setDescription('Channel ID').setRequired(true)),
async execute(interaction) {
const msg = interaction.options.getString('message');
const channel = interaction.options.getString('channel');
await postRules(interaction, msg, channel);
},
};
async function postRules(interaction, msg, id) {
const channel = interaction.client.channels.cache.get(id);
await channel.send(msg);
await interaction.reply(`Message posted in <#${id}>.`);
console.log("Sent message.");
}