Discord_API_Bot/slash-commands/settings.js

55 lines
No EOL
1.7 KiB
JavaScript

const { embed_color } = require("../config");
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("settings")
.setDescription("Set the settings tickets")
.addRoleOption(option =>
option
.setRequired(true)
.setName("support-role")
.setDescription("Set the support role for tickets.")
)
.addChannelOption(option =>
option
.setRequired(true)
.setName("log-channel")
.setDescription("Select the channel for transcripts.")
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async run(interaction) {
let { options } = interaction;
const deferOptions = { ephemeral: true };
await interaction.deferReply(deferOptions);
let supportRole = options.getRole("support-role");
let logChannel = options.getChannel("log-channel");
const authorText = { name: interaction.guild.name };
const thumbnailOptions = { dynamic: true };
let settingsEmbed = new EmbedBuilder()
.setColor(embed_color)
.setAuthor(authorText)
.setThumbnail(interaction.guild.iconURL(thumbnailOptions))
.setDescription("You successfully change the settings.");
db.query(`
INSERT INTO settings (log_channelID, support_roleID, ticket_counter, guildID)
VALUES ('${logChannel.id}', '${supportRole.id}', '0', '${interaction.guildId}')
ON DUPLICATE KEY UPDATE
log_channelID='${logChannel.id}',
support_roleID='${supportRole.id}'
`);
const replyOptions = {
embeds: [settingsEmbed],
ephemeral: true
};
return interaction.editReply(replyOptions);
}
};