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 { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9'); const { Routes } = require('discord-api-types/v9');
const { token, version } = require('../config.js'); const { token, version } = require('../config.js');
@ -11,6 +12,10 @@ module.exports = {
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`./commands/${file}`); 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()); commands.push(command.data.toJSON());
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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