mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 11:01:04 -05:00
Initial support for channel-based data storage
This commit is contained in:
@@ -6,10 +6,27 @@ import { packageJson } from './util';
|
||||
|
||||
const CHANNEL_OPTIONS_MAX = 25;
|
||||
|
||||
const helpSlashCommand = new SlashCommandBuilder()
|
||||
export const helpCommand = new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription(`How to use ${packageJson().name}`);
|
||||
|
||||
export const inviteCommand = new SlashCommandBuilder()
|
||||
.setName('invite')
|
||||
.setDescription('Get the invite link for this bot.');
|
||||
|
||||
export const messageCommand = new SlashCommandBuilder()
|
||||
.setName(config.slashCommandName)
|
||||
.setDescription('Generate a message from learned past messages')
|
||||
.addBooleanOption((tts) =>
|
||||
tts.setName('tts').setDescription('Read the message via text-to-speech.').setRequired(false)
|
||||
)
|
||||
.addBooleanOption((debug) =>
|
||||
debug
|
||||
.setName('debug')
|
||||
.setDescription('Follow up the generated message with the detailed sources that inspired it.')
|
||||
.setRequired(false)
|
||||
);
|
||||
|
||||
/**
|
||||
* Helps generate a list of parameters for channel options
|
||||
*/
|
||||
@@ -20,15 +37,15 @@ const channelOptionsGenerator = (builder: SlashCommandChannelOption, index: numb
|
||||
.setRequired(index === 0)
|
||||
.addChannelType(ChannelType.GuildText as any);
|
||||
|
||||
const listenChannelCommand = new SlashCommandBuilder()
|
||||
export const listenChannelCommand = new SlashCommandBuilder()
|
||||
.setName('listen')
|
||||
.setDescription('Change what channels the bot actively listens to and learns from.')
|
||||
.addSubcommand((sub) => {
|
||||
sub
|
||||
.setName('add')
|
||||
.setDescription(
|
||||
`Add channels to learn from. Doesn't add the channel's past messages; re-train to do that.`
|
||||
);
|
||||
|
||||
Array.from(Array(CHANNEL_OPTIONS_MAX).keys()).forEach((index) =>
|
||||
sub.addChannelOption((opt) => channelOptionsGenerator(opt, index))
|
||||
);
|
||||
@@ -45,9 +62,25 @@ const listenChannelCommand = new SlashCommandBuilder()
|
||||
);
|
||||
return sub;
|
||||
})
|
||||
.setDescription(`How to use ${packageJson().name}`);
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('list')
|
||||
.setDescription(`List the channels the bot is currently actively listening to.`)
|
||||
);
|
||||
|
||||
const commands = [helpSlashCommand.toJSON(), listenChannelCommand.toJSON()];
|
||||
export const trainCommand = new SlashCommandBuilder()
|
||||
.setName('train')
|
||||
.setDescription(
|
||||
'Train from past messages from the configured listened channels. This takes a while.'
|
||||
);
|
||||
|
||||
const commands = [
|
||||
helpCommand.toJSON(),
|
||||
inviteCommand.toJSON(),
|
||||
messageCommand.toJSON(),
|
||||
listenChannelCommand.toJSON(),
|
||||
trainCommand.toJSON(),
|
||||
];
|
||||
|
||||
export async function deployCommands(clientId: string) {
|
||||
const rest = new REST({ version: '9' }).setToken(config.token);
|
||||
|
||||
Reference in New Issue
Block a user