mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 19:01:06 -05:00
Some work on channel-gating
This commit is contained in:
@@ -1,14 +1,53 @@
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { SlashCommandBuilder, SlashCommandChannelOption } from '@discordjs/builders';
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v9';
|
||||
import { ChannelType, Routes } from 'discord-api-types/v9';
|
||||
import { config } from './config';
|
||||
import { packageJson } from './util';
|
||||
|
||||
const CHANNEL_OPTIONS_MAX = 25;
|
||||
|
||||
const helpSlashCommand = new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription(`How to use ${packageJson().name}`);
|
||||
|
||||
const commands = [helpSlashCommand.toJSON()];
|
||||
/**
|
||||
* Helps generate a list of parameters for channel options
|
||||
*/
|
||||
const channelOptionsGenerator = (builder: SlashCommandChannelOption, index: number) =>
|
||||
builder
|
||||
.setName(`channel-${index + 1}`)
|
||||
.setDescription('A text channel')
|
||||
.setRequired(index === 0)
|
||||
.addChannelType(ChannelType.GuildText as any);
|
||||
|
||||
const listenChannelCommand = new SlashCommandBuilder()
|
||||
.setName('listen')
|
||||
.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))
|
||||
);
|
||||
return sub;
|
||||
})
|
||||
.addSubcommand((sub) => {
|
||||
sub
|
||||
.setName('remove')
|
||||
.setDescription(
|
||||
`Remove channels from being learned from. Doesn't remove the channel's data; re-train to do that.`
|
||||
);
|
||||
Array.from(Array(CHANNEL_OPTIONS_MAX).keys()).forEach((index) =>
|
||||
sub.addChannelOption((opt) => channelOptionsGenerator(opt, index))
|
||||
);
|
||||
return sub;
|
||||
})
|
||||
.setDescription(`How to use ${packageJson().name}`);
|
||||
|
||||
const commands = [helpSlashCommand.toJSON(), listenChannelCommand.toJSON()];
|
||||
|
||||
export async function deployCommands(clientId: string) {
|
||||
const rest = new REST({ version: '9' }).setToken(config.token);
|
||||
|
||||
Reference in New Issue
Block a user