Moved SlashCommandBuilder to commands.js

This commit is contained in:
Christer Warén 2021-08-26 18:00:04 +03:00
parent bd70f2bedc
commit fcb5f4f6e6
11 changed files with 12 additions and 57 deletions

View File

@ -1,3 +1,4 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token, version } = require('../config.js');
@ -11,6 +12,10 @@ module.exports = {
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
command.data = new SlashCommandBuilder()
.setName(command.name)
.setDescription(command.description);
if(command.options) command.data.options = command.options;
commands.push(command.data.toJSON());
}

View File

@ -1,5 +1,3 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'bug',
alias: 'none',
@ -7,9 +5,6 @@ module.exports = {
description: 'Report a bug',
permission: 'none',
category: 'info',
data: new SlashCommandBuilder()
.setName('bug')
.setDescription('Report a bug'),
async execute(interaction, client, Discord, command) {
let message = {};

View File

@ -1,5 +1,3 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'help',
alias: 'h',
@ -7,9 +5,6 @@ module.exports = {
description: 'Get help using bot',
permission: 'none',
category: 'info',
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Get help using bot'),
execute(interaction, client, Discord, command) {
let message = {};

View File

@ -1,5 +1,3 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'invite',
alias: 'i',
@ -7,9 +5,6 @@ module.exports = {
description: 'Invite Bot',
permission: 'none',
category: 'info',
data: new SlashCommandBuilder()
.setName('invite')
.setDescription('Invite Bot'),
execute(interaction, client, Discord, command) {
let message = {};
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);

View File

@ -1,15 +1,10 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'list',
alias: 'l',
usage: '',
description: 'List radio stations.',
description: 'List radio stations',
permission: 'none',
category: 'radio',
data: new SlashCommandBuilder()
.setName('list')
.setDescription('List radio stations.'),
execute(interaction, client, Discord, command) {
let message = {};
if(!client.stations) {

View File

@ -1,5 +1,3 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'maintenance',
alias: 'm',
@ -7,9 +5,6 @@ module.exports = {
description: 'Bot Maintenance',
permission: 'none',
category: 'info',
data: new SlashCommandBuilder()
.setName('maintenance')
.setDescription('Bot Maintenance'),
execute(interaction, client, Discord, command) {
let message = {};

View File

@ -1,5 +1,3 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'nowplaying',
alias: 'np',
@ -7,9 +5,6 @@ module.exports = {
description: 'Current Radio Station',
permission: 'none',
category: 'radio',
data: new SlashCommandBuilder()
.setName('nowplaying')
.setDescription('Current Radio Station'),
async execute(interaction, client, Discord, command) {
let message = {};
const radio = client.radio.get(interaction.guild.id);

View File

@ -4,23 +4,18 @@ const {
getVoiceConnection,
joinVoiceChannel
} = require("@discordjs/voice");
const { SlashCommandBuilder } = require('@discordjs/builders');
const { createDiscordJSAdapter } = require("../utils/adapter");
module.exports = {
name: "play",
alias: "p",
usage: "<song name>",
description: "Play radio.",
description: "Play radio",
options: [
{ type: "STRING", name: "query", description: "Select station", required: true}
],
permission: "none",
category: "radio",
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play radio.')
.addStringOption(option =>
option.setName('query')
.setDescription('Select station')
.setRequired(true)),
async execute(interaction, client, Discord, command) {
let message = {};
let query = interaction.options.getString("query");

View File

@ -1,15 +1,10 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'statistics',
alias: 'stats',
usage: '',
description: 'Show usage statistics.',
description: 'Show statistics',
permission: 'none',
category: 'info',
data: new SlashCommandBuilder()
.setName('statistics')
.setDescription('Show usage statistics.'),
execute(interaction, client, Discord, command) {
let message = {};
let stations = client.stations;

View File

@ -1,5 +1,3 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'status',
alias: 'st',
@ -7,9 +5,6 @@ module.exports = {
description: 'Bot Status',
permission: 'none',
category: 'info',
data: new SlashCommandBuilder()
.setName('status')
.setDescription('Bot Status'),
async execute(interaction, client, Discord, command) {
let message = {};

View File

@ -1,15 +1,10 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
name: 'stop',
description: 'Stop radio.',
description: 'Stop radio',
alias: 's',
usage: '',
permission: 'none',
category: 'radio',
data: new SlashCommandBuilder()
.setName('stop')
.setDescription('Stop radio.'),
execute(interaction, client, Discord, command) {
const radio = client.radio.get(interaction.guild.id);
if (client.funcs.check(client, interaction, command)) {