aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-07-09 22:14:38 -0400
committerAndrew Lee <alee14498@protonmail.com>2022-07-09 22:14:38 -0400
commitd7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc (patch)
treea6fd714025ec7fe78bd89d45d7f0fa36bc8f73aa /commands
parent4c26fbcb7e1674d5ccbb5468a32cd4a2bc2a315b (diff)
downloadDLAP-d7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc.tar.gz
DLAP-d7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc.tar.bz2
DLAP-d7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc.zip
ESLint
Diffstat (limited to 'commands')
-rw-r--r--commands/about.js58
-rw-r--r--commands/join.js24
-rw-r--r--commands/leave.js26
-rw-r--r--commands/list.js31
-rw-r--r--commands/pause.js34
-rw-r--r--commands/ping.js16
-rw-r--r--commands/play.js60
-rw-r--r--commands/reshuffle.js28
-rw-r--r--commands/shutdown.js24
-rw-r--r--commands/skip.js26
-rw-r--r--commands/status.js41
11 files changed, 187 insertions, 181 deletions
diff --git a/commands/about.js b/commands/about.js
index 185a795..fa6d8a2 100644
--- a/commands/about.js
+++ b/commands/about.js
@@ -19,35 +19,37 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { MessageEmbed, version, MessageActionRow, MessageButton } from 'discord.js'
-import npmPackage from '../package.json' assert { type:'json' }
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { MessageEmbed, version, MessageActionRow, MessageButton } from 'discord.js';
+// import npmPackage from '../package.json' assert { type:'json' }
+import { readFileSync } from 'node:fs';
+const npmPackage = JSON.parse(readFileSync('./package.json'));
export default {
- data: new SlashCommandBuilder()
- .setName('about')
- .setDescription('Information about the bot'),
- async execute(interaction, bot) {
- const aboutEmbed = new MessageEmbed()
- .setAuthor({name:`About ${bot.user.username}`, iconURL:bot.user.avatarURL()})
- .addField('Information', 'A Discord bot that plays local audio tracks.')
- .addField('Version', `DLAP ${npmPackage.version}`)
- .addField('Original Creator', 'Andrew Lee (Alee#4277)') // Do not remove this since I created this :)
- //.addField('Contributors', '[your name] (discord#0000)')
- //.addField('Forked by', '[your name] (discord#0000)')
- .addField('Frameworks', `Discord.JS ${version} + Voice`)
- .addField('License', 'GNU General Public License v3.0')
- .setFooter({text:'© Copyright 2020-2022 Andrew Lee'})
- .setColor('#0066ff')
+ data: new SlashCommandBuilder()
+ .setName('about')
+ .setDescription('Information about the bot'),
+ async execute (interaction, bot) {
+ const aboutEmbed = new MessageEmbed()
+ .setAuthor({ name: `About ${bot.user.username}`, iconURL: bot.user.avatarURL() })
+ .addField('Information', 'A Discord bot that plays local audio tracks.')
+ .addField('Version', `DLAP ${npmPackage.version}`)
+ .addField('Original Creator', 'Andrew Lee (Alee#4277)') // Do not remove this since I created this :)
+ // .addField('Contributors', '[your name] (discord#0000)')
+ // .addField('Forked by', '[your name] (discord#0000)')
+ .addField('Frameworks', `Discord.JS ${version} + Voice`)
+ .addField('License', 'GNU General Public License v3.0')
+ .setFooter({ text: '© Copyright 2020-2022 Andrew Lee' })
+ .setColor('#0066ff');
- const srcOrig = new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setStyle('LINK')
- .setLabel('Original Source Code')
- .setURL('https://github.com/Alee14/DLMP3'),
- );
+ const srcOrig = new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setStyle('LINK')
+ .setLabel('Original Source Code')
+ .setURL('https://github.com/Alee14/DLMP3')
+ );
- return await interaction.reply({ embeds:[aboutEmbed], components:[srcOrig] });
- },
-}; \ No newline at end of file
+ return await interaction.reply({ embeds: [aboutEmbed], components: [srcOrig] });
+ }
+};
diff --git a/commands/join.js b/commands/join.js
index 42f3e1c..b309f97 100644
--- a/commands/join.js
+++ b/commands/join.js
@@ -19,17 +19,17 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { voiceInit } from '../AudioBackend.js'
-import { PermissionFlagsBits } from 'discord-api-types/v10'
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { voiceInit } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export default {
- data: new SlashCommandBuilder()
- .setName('join')
- .setDescription('Joins voice chat')
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction, bot) {
- await interaction.reply({ content: 'Joining voice channel', ephemeral: true })
- return await voiceInit(bot);
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('join')
+ .setDescription('Joins voice chat')
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ async execute (interaction, bot) {
+ await interaction.reply({ content: 'Joining voice channel', ephemeral: true });
+ return await voiceInit(bot);
+ }
+};
diff --git a/commands/leave.js b/commands/leave.js
index 63b4245..b37ebdc 100644
--- a/commands/leave.js
+++ b/commands/leave.js
@@ -19,18 +19,18 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { destroyAudio } from "../AudioBackend.js"
-import { PermissionFlagsBits } from "discord-api-types/v10"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { destroyAudio } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export default {
- data: new SlashCommandBuilder()
- .setName('leave')
- .setDescription('Leaves the voice chat')
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction) {
- console.log('Leaving voice channel...');
- await destroyAudio(interaction);
- return await interaction.reply({content:'Leaving voice channel', ephemeral:true});
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('leave')
+ .setDescription('Leaves the voice chat')
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ async execute (interaction) {
+ console.log('Leaving voice channel...');
+ await destroyAudio(interaction);
+ return await interaction.reply({ content: 'Leaving voice channel', ephemeral: true });
+ }
+};
diff --git a/commands/list.js b/commands/list.js
index b95d46d..9d7a7fd 100644
--- a/commands/list.js
+++ b/commands/list.js
@@ -19,21 +19,26 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { readdirSync, readdir } from 'fs'
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { readdirSync, readdir } from 'fs';
const musicFolder = './music';
export default {
- data: new SlashCommandBuilder()
- .setName('list')
- .setDescription('Lists the available audio tracks'),
- async execute(interaction) {
- //If someone figures out how to either split the list or make pages when the max character reaches, please do so and make a pull request.
+ data: new SlashCommandBuilder()
+ .setName('list')
+ .setDescription('Lists the available audio tracks'),
+ async execute (interaction) {
+ // If someone figures out how to either split the list or make pages when the max character reaches, please do so and make a pull request.
- const beats = readdirSync(musicFolder).join('\n');
- readdir(musicFolder, async (err, files) => {
- await interaction.reply(`Listing ${files.length} audio tracks...\n\`\`\`\n${beats}\n\`\`\``);
- });
- },
-}; \ No newline at end of file
+ const beats = readdirSync(musicFolder).join('\n');
+ readdir(musicFolder, async (err, files) => {
+ await interaction.reply(
+ `Listing ${files.length} audio tracks...\n\`\`\`\n${beats}\n\`\`\``
+ );
+ if (err) {
+ console.error(err);
+ }
+ });
+ }
+};
diff --git a/commands/pause.js b/commands/pause.js
index 5306f63..629d423 100644
--- a/commands/pause.js
+++ b/commands/pause.js
@@ -19,22 +19,22 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { audioState, isAudioStatePaused, player } from "../AudioBackend.js"
-import { PermissionFlagsBits } from "discord-api-types/v10"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { audioState, isAudioStatePaused, player } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export default {
- data: new SlashCommandBuilder()
- .setName('pause')
- .setDescription('Pauses music')
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction) {
- if (isAudioStatePaused === false) {
- audioState();
- player.pause();
- return await interaction.reply({content:'Pausing music', ephemeral:true});
- } else {
- return await interaction.reply({content:"Music is already paused", ephemeral:true})
- }
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('pause')
+ .setDescription('Pauses music')
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ async execute (interaction) {
+ if (isAudioStatePaused === false) {
+ audioState();
+ player.pause();
+ return await interaction.reply({ content: 'Pausing music', ephemeral: true });
+ } else {
+ return await interaction.reply({ content: 'Music is already paused', ephemeral: true });
+ }
+ }
+};
diff --git a/commands/ping.js b/commands/ping.js
index 3a77d08..574afc8 100644
--- a/commands/ping.js
+++ b/commands/ping.js
@@ -19,13 +19,13 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
+import { SlashCommandBuilder } from '@discordjs/builders';
export default {
- data: new SlashCommandBuilder()
- .setName('ping')
- .setDescription('Pong!'),
- async execute(interaction, bot) {
- return await interaction.reply(`Pong! ${Math.round(bot.ws.ping)}ms`);
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('ping')
+ .setDescription('Pong!'),
+ async execute (interaction, bot) {
+ return await interaction.reply(`Pong! ${Math.round(bot.ws.ping)}ms`);
+ }
+};
diff --git a/commands/play.js b/commands/play.js
index d206c56..324573d 100644
--- a/commands/play.js
+++ b/commands/play.js
@@ -19,38 +19,38 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { isAudioStatePaused, inputAudio, audio, audioState, player, files } from '../AudioBackend.js'
-import { PermissionFlagsBits } from "discord-api-types/v10"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { isAudioStatePaused, inputAudio, audio, audioState, player, files } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export let integer;
export default {
- data: new SlashCommandBuilder()
- .setName('play')
- .setDescription('Resumes music')
- .addIntegerOption(option =>
- option.setName('int')
- .setDescription('Input a number for the selection for the audio file.'),
- )
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ data: new SlashCommandBuilder()
+ .setName('play')
+ .setDescription('Resumes music')
+ .addIntegerOption(option =>
+ option.setName('int')
+ .setDescription('Input a number for the selection for the audio file.')
+ )
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction, bot) {
- integer = interaction.options.getInteger('int');
- if (integer) {
- if (integer < files.length) {
- await inputAudio(bot, integer);
- return await interaction.reply({content:`Now playing: ${audio}`, ephemeral:true});
- } else {
- return await interaction.reply({content:'Number is too big, choose a number that\'s less than ' + files.length + '.', ephemeral:true})
- }
- }
- if (isAudioStatePaused === true) {
- audioState();
- player.unpause();
- return await interaction.reply({content:'Resuming music', ephemeral:true});
- } else {
- return await interaction.reply({content:"Music is already playing", ephemeral:true})
- }
- },
-}; \ No newline at end of file
+ async execute (interaction, bot) {
+ integer = interaction.options.getInteger('int');
+ if (integer) {
+ if (integer < files.length) {
+ await inputAudio(bot, integer);
+ return await interaction.reply({ content: `Now playing: ${audio}`, ephemeral: true });
+ } else {
+ return await interaction.reply({ content: 'Number is too big, choose a number that\'s less than ' + files.length + '.', ephemeral: true });
+ }
+ }
+ if (isAudioStatePaused === true) {
+ audioState();
+ player.unpause();
+ return await interaction.reply({ content: 'Resuming music', ephemeral: true });
+ } else {
+ return await interaction.reply({ content: 'Music is already playing', ephemeral: true });
+ }
+ }
+};
diff --git a/commands/reshuffle.js b/commands/reshuffle.js
index e311e19..c0ad342 100644
--- a/commands/reshuffle.js
+++ b/commands/reshuffle.js
@@ -19,19 +19,19 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { player, shufflePlaylist } from "../AudioBackend.js"
-import { PermissionFlagsBits } from "discord-api-types/v10"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { player, shufflePlaylist } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export default {
- data: new SlashCommandBuilder()
- .setName('reshuffle')
- .setDescription('Reshuffles the playlist')
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction, bot) {
- // Command not fully functional yet
- await interaction.reply({content:`Reshuffling the playlist...`, ephemeral:true});
- player.stop();
- return await shufflePlaylist(bot);
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('reshuffle')
+ .setDescription('Reshuffles the playlist')
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ async execute (interaction, bot) {
+ // Command not fully functional yet
+ await interaction.reply({ content: 'Reshuffling the playlist...', ephemeral: true });
+ player.stop();
+ return await shufflePlaylist(bot);
+ }
+};
diff --git a/commands/shutdown.js b/commands/shutdown.js
index 4c32bc6..6e3c52b 100644
--- a/commands/shutdown.js
+++ b/commands/shutdown.js
@@ -19,17 +19,17 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { stopBot } from "../AudioBackend.js"
-import { PermissionFlagsBits } from "discord-api-types/v10"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { stopBot } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export default {
- data: new SlashCommandBuilder()
- .setName('shutdown')
- .setDescription('Powers off the bot')
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction, bot) {
- await interaction.reply({ content: 'Powering off...', ephemeral: true})
- return await stopBot(bot, interaction);
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('shutdown')
+ .setDescription('Powers off the bot')
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ async execute (interaction, bot) {
+ await interaction.reply({ content: 'Powering off...', ephemeral: true });
+ return await stopBot(bot, interaction);
+ }
+};
diff --git a/commands/skip.js b/commands/skip.js
index 3003ca0..189aab7 100644
--- a/commands/skip.js
+++ b/commands/skip.js
@@ -19,18 +19,18 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { audio, player, nextAudio } from "../AudioBackend.js"
-import { PermissionFlagsBits } from "discord-api-types/v10"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { audio, player, nextAudio } from '../AudioBackend.js';
+import { PermissionFlagsBits } from 'discord-api-types/v10';
export default {
- data: new SlashCommandBuilder()
- .setName('skip')
- .setDescription('Skips the audio track')
- .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
- async execute(interaction, bot) {
- await interaction.reply({content:`Skipping ${audio}`, ephemeral:true});
- player.stop();
- return await nextAudio(bot, interaction);
- },
-}; \ No newline at end of file
+ data: new SlashCommandBuilder()
+ .setName('skip')
+ .setDescription('Skips the audio track')
+ .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
+ async execute (interaction, bot) {
+ await interaction.reply({ content: `Skipping ${audio}`, ephemeral: true });
+ player.stop();
+ return await nextAudio(bot, interaction);
+ }
+};
diff --git a/commands/status.js b/commands/status.js
index 7952238..9871157 100644
--- a/commands/status.js
+++ b/commands/status.js
@@ -19,28 +19,27 @@
*
***************************************************************************/
-import { SlashCommandBuilder } from '@discordjs/builders'
-import { MessageEmbed } from "discord.js"
-import {audio, audioArray, currentTrack, playerState} from "../AudioBackend.js"
+import { SlashCommandBuilder } from '@discordjs/builders';
+import { MessageEmbed } from 'discord.js';
+import { audio, audioArray, currentTrack, playerState } from '../AudioBackend.js';
export default {
- data: new SlashCommandBuilder()
- .setName('status')
- .setDescription('Checks what audio file is playing currently'),
- async execute(interaction, bot) {
+ data: new SlashCommandBuilder()
+ .setName('status')
+ .setDescription('Checks what audio file is playing currently'),
+ async execute (interaction, bot) {
+ let audioID = currentTrack;
+ audioID++;
- let audioID = currentTrack
- audioID++
+ let audioName = audioArray[audioID];
+ audioName = audioName.split('.').slice(0, -1).join('.');
- let audioName = audioArray[audioID]
- audioName = audioName.split('.').slice(0, -1).join('.');
-
- let controlEmbed = new MessageEmbed()
- .setAuthor({name: `${bot.user.username} Status`, iconURL: bot.user.avatarURL()})
- .addField('State', playerState)
- .addField('Currently Playing', audio)
- .addField('Up Next', audioName)
- .setColor('#0066ff')
- interaction.reply({embeds:[controlEmbed], ephemeral:true})
- },
-}; \ No newline at end of file
+ const controlEmbed = new MessageEmbed()
+ .setAuthor({ name: `${bot.user.username} Status`, iconURL: bot.user.avatarURL() })
+ .addField('State', playerState)
+ .addField('Currently Playing', audio)
+ .addField('Up Next', audioName)
+ .setColor('#0066ff');
+ interaction.reply({ embeds: [controlEmbed], ephemeral: true });
+ }
+};