33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
const { Client, Interaction, ApplicationCommandOptionType, PermissionFlagsBits, SlashCommandBuilder } = require("discord.js");
|
|
const db = require("../../db");
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName("setbluchannel")
|
|
.setDescription("Set the channel for Blu to send messages.")
|
|
.addChannelOption((option) =>
|
|
option
|
|
.setName("channel")
|
|
.setDescription("Channel to set for Blu messages")
|
|
.setRequired(true)
|
|
)
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
async execute(interaction) {
|
|
const channelId = interaction.options.getChannel("channel");
|
|
const guildId = interaction.guild.id;
|
|
const guildName = interaction.guild.name;
|
|
const channelName = channelId.name;
|
|
|
|
if (channelId) {
|
|
await db.query(
|
|
`INSERT INTO bot_channel (guild_id, channel_id, guild_name, channel_name)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (guild_id) DO UPDATE SET Channel_id = $2, guild_name = $3, channel_name = $4`,
|
|
[guildId, channelId.id, guildName, channelName]
|
|
);
|
|
return interaction.reply(`Blu messages will be sent to <#${channelId.id}>.`);
|
|
} else {
|
|
return interaction.reply("Please provide a valid channel.");
|
|
}
|
|
},
|
|
} |