138 lines
No EOL
4.6 KiB
JavaScript
138 lines
No EOL
4.6 KiB
JavaScript
require('dotenv').config();
|
|
const { REST, SlashCommandBuilder, Routes } = require('discord.js');
|
|
const clientId = process.env.CLIENT_ID;
|
|
const guildId = process.env.GUILD_ID;
|
|
const token = process.env.TOKEN;
|
|
|
|
const commands = [
|
|
new SlashCommandBuilder()
|
|
.setName('generate')
|
|
.setDescription('Generate something.')
|
|
.addSubcommand(subcommand =>
|
|
subcommand
|
|
.setName('host')
|
|
.setDescription('Generate a host.')
|
|
.addNumberOption(option =>
|
|
option
|
|
.setName('rating')
|
|
.setDescription('The rating of the host.')
|
|
.setRequired(true)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('type')
|
|
.setDescription('The type of the host.')
|
|
.addChoices(
|
|
{ name: 'Foundation', value: 'foundation' },
|
|
{ name: 'Framework', value: 'framework' },
|
|
)
|
|
)
|
|
),
|
|
new SlashCommandBuilder()
|
|
.setName('simulate')
|
|
.setDescription('Simulate different type of dice rolls.')
|
|
.addSubcommand(subcommand =>
|
|
subcommand
|
|
.setName('simple')
|
|
.setDescription('Simulate a simple dice roll.')
|
|
)
|
|
.addSubcommand(subcommand =>
|
|
subcommand
|
|
.setName('extended')
|
|
.setDescription('Simulate an extended dice roll.')
|
|
.addNumberOption(option =>
|
|
option
|
|
.setName('dicepool')
|
|
.setDescription('The dicepool of the roll.')
|
|
.setRequired(true)
|
|
)
|
|
.addNumberOption(option =>
|
|
option
|
|
.setName('threshold')
|
|
.setDescription('The threshold of the roll.')
|
|
.setRequired(true)
|
|
)
|
|
.addNumberOption(option =>
|
|
option
|
|
.setName('interval')
|
|
.setDescription('The interval of the roll.')
|
|
.setRequired(true)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('interval-unit')
|
|
.setDescription('The unit of the interval. Defaults to Hours.')
|
|
.setRequired(false)
|
|
.addChoices(
|
|
{ name: 'Seconds', value: 'seconds' },
|
|
{ name: 'Minutes', value: 'minutes' },
|
|
{ name: 'Hours', value: 'hours' },
|
|
{ name: 'Days', value: 'days' },
|
|
{ name: 'Weeks', value: 'weeks' },
|
|
{ name: 'Months', value: 'months' },
|
|
)
|
|
)
|
|
.addNumberOption(option =>
|
|
option
|
|
.setName('max-edge')
|
|
.setDescription('The maximum number of edge to use.')
|
|
.setRequired(false)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('edgetype')
|
|
.setDescription('What type of edgeing should be used ?')
|
|
.addChoices(
|
|
{ name: 'None', value: 'none' },
|
|
{ name: 'Turn Up', value: 'up' },
|
|
{ name: 'Reroll', value: 'reroll' },
|
|
{ name: 'Smart', value: 'smart' },
|
|
{ name: 'All', value: 'all' },
|
|
)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('edgerefresh')
|
|
.setDescription('How often should the edge refresh ?')
|
|
.addChoices(
|
|
{ name: 'Never', value: 'none' },
|
|
{ name: 'Every Roll', value: 'fill' },
|
|
{ name: '1 Edge per Roll', value: 'once' },
|
|
{ name: '2 Edge per Roll', value: 'twice' },
|
|
)
|
|
)
|
|
.addNumberOption(option =>
|
|
option
|
|
.setName('amount')
|
|
.setDescription('How many times should the roll be simulated ? WARNING this service is pricey !')
|
|
.setRequired(false)
|
|
)
|
|
.addBooleanOption(option =>
|
|
option
|
|
.setName('hidden')
|
|
.setDescription('Should the result be hidden ?')
|
|
.setRequired(false)
|
|
)
|
|
.addBooleanOption(option =>
|
|
option
|
|
.setName('true-random')
|
|
.setDescription('Should the dice be truly random ?')
|
|
.setRequired(false)
|
|
)
|
|
)
|
|
]
|
|
.map(command => command.toJSON());
|
|
|
|
const rest = new REST({ version: '10' }).setToken(token);
|
|
|
|
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
|
|
.then((data) => console.log('Removed all commands from guilds'))
|
|
.catch(console.error);
|
|
|
|
rest.put(Routes.applicationCommands(clientId), { body: [] })
|
|
.then((data) => console.log(`Removed all global commands`))
|
|
.catch(console.error);
|
|
|
|
rest.put(Routes.applicationCommands(clientId), { body: commands })
|
|
.then((data) => console.log(`Added ${data.length} commands to global`))
|
|
.catch(console.error); |