38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import {
|
|
ChatInputCommandInteraction,
|
|
PermissionsBitField,
|
|
SlashCommandBuilder,
|
|
SlashCommandStringOption,
|
|
} from 'discord.js';
|
|
import {Bot} from "../bot";
|
|
|
|
const option = (new SlashCommandStringOption())
|
|
.setName('prefix')
|
|
.setDescription('The prefix.')
|
|
.setRequired(true);
|
|
|
|
export default {
|
|
data: new SlashCommandBuilder()
|
|
.setName('setignoreprefix')
|
|
.setDescription('Set the prefix that causes the bot to ignore a message.')
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator)
|
|
.addStringOption(option),
|
|
async execute(interaction: ChatInputCommandInteraction) {
|
|
const bot = Bot.getInstance();
|
|
bot.getDB().run(
|
|
'INSERT OR REPLACE INTO config (configkey, value) VALUES (?, ?)',
|
|
[
|
|
'ignorePrefix',
|
|
interaction.options.data.at(0).value,
|
|
]
|
|
);
|
|
|
|
bot.setIgnorePrefix(interaction.options.data.at(0).value.toString());
|
|
console.log('set ignore prefix to ' + interaction.options.data.at(0).value);
|
|
|
|
return await interaction.reply({
|
|
content: 'Done!',
|
|
ephemeral: true,
|
|
});
|
|
},
|
|
}; |