1 |
#!/bin/ts-node |
#!/bin/node |
2 |
|
|
3 |
import { SlashCommandBuilder } from '@discordjs/builders'; |
const { SlashCommandBuilder } = require('@discordjs/builders'); |
4 |
import { REST } from '@discordjs/rest'; |
const { REST } = require('@discordjs/rest'); |
5 |
import { Routes } from 'discord-api-types/v9'; |
const { Routes } = require('discord-api-types/v9'); |
6 |
import { config } from 'dotenv'; |
const { config } = require('dotenv'); |
7 |
import { existsSync } from 'fs'; |
const { existsSync } = require('fs'); |
8 |
import path from 'path'; |
const path = require('path'); |
9 |
|
|
10 |
if (existsSync(path.join(__dirname, '.env'))) { |
if (existsSync(path.join(__dirname, '.env'))) { |
11 |
config(); |
config(); |
31 |
.addUserOption(option => option.setName('user').setDescription('The user')), |
.addUserOption(option => option.setName('user').setDescription('The user')), |
32 |
|
|
33 |
// AUTOMATION |
// AUTOMATION |
34 |
|
new SlashCommandBuilder().setName('ballot').setDescription('Ballot engine') |
35 |
|
.addSubcommand(subcommand => |
36 |
|
subcommand |
37 |
|
.setName('create') |
38 |
|
.setDescription('Send a ballot/poll message for collecting votes') |
39 |
|
.addStringOption(option => option.setName('content').setDescription('Message content').setRequired(true)) |
40 |
|
.addBooleanOption(option => option.setName('anonymous').setDescription('If this is set to true then the syetem won\'t show your username')) |
41 |
|
.addChannelOption(option => option.setName('channel').setDescription('The channel where the message should be sent'))) |
42 |
|
.addSubcommand(subcommand => |
43 |
|
subcommand |
44 |
|
.setName('view') |
45 |
|
.setDescription('Get information/stats about a ballot') |
46 |
|
.addIntegerOption(option => option.setName('id').setDescription('The ballot ID'))), |
47 |
|
|
48 |
new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'), |
new SlashCommandBuilder().setName('queues').setDescription('List all queued jobs'), |
49 |
|
|
50 |
new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later') |
new SlashCommandBuilder().setName('schedule').setDescription('Schedule a message for sending later') |
214 |
.addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)), |
.addUserOption(option => option.setName('member').setDescription("The member").setRequired(true)), |
215 |
].map(command => command.toJSON()); |
].map(command => command.toJSON()); |
216 |
|
|
217 |
const rest = new REST({ version: '9' }).setToken(TOKEN!); |
const rest = new REST({ version: '9' }).setToken(TOKEN); |
218 |
|
|
219 |
rest.put(Routes.applicationGuildCommands(CLIENT_ID!, GUILD_ID!), { body: commands }) |
rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands }) |
220 |
.then(() => console.log('Successfully registered application commands.')) |
.then(() => console.log('Successfully registered application commands.')) |
221 |
.catch(console.error); |
.catch(console.error); |