aboutsummaryrefslogtreecommitdiff
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
parent4c26fbcb7e1674d5ccbb5468a32cd4a2bc2a315b (diff)
downloadDLAP-d7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc.tar.gz
DLAP-d7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc.tar.bz2
DLAP-d7e4cf29e6fc6b8f4ba07e837dcf56b3f5d63afc.zip
ESLint
-rw-r--r--.eslintrc.json16
-rw-r--r--AudioBackend.js180
-rw-r--r--bot.js35
-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
-rw-r--r--deploy-command.js17
-rw-r--r--package.json5
16 files changed, 323 insertions, 298 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..638fdcf
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,16 @@
+{
+ "env": {
+ "browser": true,
+ "es2022": true
+ },
+ "extends": [
+ "standard"
+ ],
+ "parserOptions": {
+ "ecmaVersion": "latest",
+ "sourceType": "module"
+ },
+ "rules": {
+ "semi": [2, "always"]
+ }
+}
diff --git a/AudioBackend.js b/AudioBackend.js
index 64f85b1..ed30afe 100644
--- a/AudioBackend.js
+++ b/AudioBackend.js
@@ -1,9 +1,9 @@
/**************************************************************************
- *
+ *
* DLAP Bot: A Discord bot that plays local audio tracks.
* (C) Copyright 2022
- * Programmed by Andrew Lee
- *
+ * Programmed by Andrew Lee
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
+ *
***************************************************************************/
import {
@@ -25,14 +25,15 @@ import {
getVoiceConnection,
joinVoiceChannel,
VoiceConnectionStatus
-} from '@discordjs/voice'
-import { MessageEmbed } from 'discord.js'
-import config from './config.json' assert {type: 'json'}
-import { readdirSync, writeFile } from 'node:fs'
+} from '@discordjs/voice';
+import { MessageEmbed } from 'discord.js';
+import { readdirSync, readFileSync, writeFile } from 'node:fs';
+// import config from './config.json' assert {type: 'json'}
+const config = JSON.parse(readFileSync('./config.json'));
export const player = createAudioPlayer();
export let audio;
-export let files = readdirSync('music');
+export const files = readdirSync('music');
let fileData;
export let audioArray;
export let currentTrack;
@@ -40,117 +41,114 @@ export let currentTrack;
export let playerState;
export let isAudioStatePaused;
-export async function voiceInit(bot) {
+export async function voiceInit (bot) {
bot.channels.fetch(config.voiceChannel).then(async channel => {
const connection = joinVoiceChannel({
- channelId: channel.id,
- guildId: channel.guild.id,
- adapterCreator: channel.guild.voiceAdapterCreator
+ channelId: channel.id,
+ guildId: channel.guild.id,
+ adapterCreator: channel.guild.voiceAdapterCreator
});
connection.on(VoiceConnectionStatus.Ready, async () => {
- console.log('Ready to blast some beats!');
- await shufflePlaylist(bot);
+ console.log('Ready to blast some beats!');
+ await shufflePlaylist(bot);
});
connection.on(VoiceConnectionStatus.Destroyed, () => {
- console.log('Destroyed the beats...');
+ console.log('Destroyed the beats...');
});
player.on('error', error => {
- console.error(error);
- nextAudio(bot);
+ console.error(error);
+ nextAudio(bot);
});
player.on('idle', () => {
- console.log("Beat has finished playing, now to the next beat...");
- nextAudio(bot);
- })
+ console.log('Beat has finished playing, now to the next beat...');
+ nextAudio(bot);
+ });
return connection.subscribe(player);
- }).catch(e => { console.error(e) })
+ }).catch(e => { console.error(e); });
}
-function shuffleArray(array) {
- for (let i = array.length - 1; i > 0; i--) {
- const j = Math.floor(Math.random() * (i + 1));
- [array[i], array[j]] = [array[j], array[i]];
- }
+function shuffleArray (array) {
+ for (let i = array.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * (i + 1));
+ [array[i], array[j]] = [array[j], array[i]];
+ }
}
-export async function shufflePlaylist(bot) {
- console.log('Shuffling beats...');
- currentTrack = 0
- audioArray = files;
- shuffleArray(audioArray);
- console.log(audioArray);
- audio = audioArray[currentTrack]
- return await playAudio(bot);
+export async function shufflePlaylist (bot) {
+ console.log('Shuffling beats...');
+ currentTrack = 0;
+ audioArray = files;
+ shuffleArray(audioArray);
+ console.log(audioArray);
+ audio = audioArray[currentTrack];
+ return await playAudio(bot);
}
-export async function nextAudio(bot) {
- let totalTrack = files.length
- totalTrack--
+export async function nextAudio (bot) {
+ let totalTrack = files.length;
+ totalTrack--;
- if (currentTrack >= totalTrack) {
- console.log('All beats in the playlist has finished, reshuffling...');
- await shufflePlaylist(bot);
- } else {
- currentTrack++
- audio = audioArray[currentTrack];
- }
+ if (currentTrack >= totalTrack) {
+ console.log('All beats in the playlist has finished, reshuffling...');
+ await shufflePlaylist(bot);
+ } else {
+ currentTrack++;
+ audio = audioArray[currentTrack];
+ }
- return await playAudio(bot);
+ return await playAudio(bot);
}
-export async function inputAudio(bot, integer) {
- let inputFiles = readdirSync('music');
- audio = inputFiles[integer];
- return await playAudio(bot);
+export async function inputAudio (bot, integer) {
+ const inputFiles = readdirSync('music');
+ audio = inputFiles[integer];
+ return await playAudio(bot);
}
-export async function playAudio(bot) {
- let resource = createAudioResource('music/' + audio);
-
- player.play(resource);
+export async function playAudio (bot) {
+ const resource = createAudioResource('music/' + audio);
- console.log('Now playing: ' + audio);
+ player.play(resource);
- playerState = "Playing"
- isAudioStatePaused = false
+ console.log('Now playing: ' + audio);
- audio = audio.split('.').slice(0, -1).join('.');
+ playerState = 'Playing';
+ isAudioStatePaused = false;
- if (config.txtFile === true) {
- fileData = "Now Playing: " + audio
- writeFile("./now-playing.txt", fileData, (err) => {
- if (err)
- console.log(err);
- });
- }
+ audio = audio.split('.').slice(0, -1).join('.');
- const statusEmbed = new MessageEmbed()
- .addField('Now Playing', `${audio}`)
- .setColor('#0066ff')
+ if (config.txtFile === true) {
+ fileData = 'Now Playing: ' + audio;
+ writeFile('./now-playing.txt', fileData, (err) => {
+ if (err) { console.log(err); }
+ });
+ }
- let statusChannel = bot.channels.cache.get(config.statusChannel);
- if (!statusChannel) return console.error('The status channel does not exist! Skipping.');
- return await statusChannel.send({embeds: [statusEmbed]});
+ const statusEmbed = new MessageEmbed()
+ .addField('Now Playing', `${audio}`)
+ .setColor('#0066ff');
+ const statusChannel = bot.channels.cache.get(config.statusChannel);
+ if (!statusChannel) return console.error('The status channel does not exist! Skipping.');
+ return await statusChannel.send({ embeds: [statusEmbed] });
}
-export async function destroyAudio(interaction) {
+export async function destroyAudio (interaction) {
if (config.txtFile === true) {
- fileData = "Now Playing: Nothing";
- writeFile("now-playing.txt", fileData, (err) => {
- if (err)
- console.log(err);
+ fileData = 'Now Playing: Nothing';
+ writeFile('now-playing.txt', fileData, (err) => {
+ if (err) { console.log(err); }
});
}
- audio = "Not Playing"
- playerState = "Stopped"
- isAudioStatePaused = true
+ audio = 'Not Playing';
+ playerState = 'Stopped';
+ isAudioStatePaused = true;
const connection = getVoiceConnection(interaction.guild.id);
if (VoiceConnectionStatus.Ready) {
@@ -159,27 +157,27 @@ export async function destroyAudio(interaction) {
}
}
-export function audioState() {
+export function audioState () {
if (isAudioStatePaused === false) {
- isAudioStatePaused = true
- playerState = "Paused"
+ isAudioStatePaused = true;
+ playerState = 'Paused';
} else if (isAudioStatePaused === true) {
- isAudioStatePaused = false
- playerState = "Playing"
+ isAudioStatePaused = false;
+ playerState = 'Playing';
}
}
-export async function stopBot(bot, interaction) {
+export async function stopBot (bot, interaction) {
const statusEmbed = new MessageEmbed()
- .setAuthor({name: bot.user.username, iconURL: bot.user.avatarURL()})
- .setDescription(`That\'s all folks! Powering down ${bot.user.username}...`)
- .setColor('#0066ff')
- let statusChannel = bot.channels.cache.get(config.statusChannel);
+ .setAuthor({ name: bot.user.username, iconURL: bot.user.avatarURL() })
+ .setDescription(`That's all folks! Powering down ${bot.user.username}...`)
+ .setColor('#0066ff');
+ const statusChannel = bot.channels.cache.get(config.statusChannel);
if (!statusChannel) return console.error('The status channel does not exist! Skipping.');
- await statusChannel.send({embeds: [statusEmbed]});
+ await statusChannel.send({ embeds: [statusEmbed] });
console.log(`Powering off ${bot.user.username}...`);
await destroyAudio(interaction);
bot.destroy();
return process.exit(0);
-} \ No newline at end of file
+}
diff --git a/bot.js b/bot.js
index 75a217c..69df79b 100644
--- a/bot.js
+++ b/bot.js
@@ -1,9 +1,9 @@
/**************************************************************************
- *
+ *
* DLAP Bot: A Discord bot that plays local audio tracks.
* (C) Copyright 2022
- * Programmed by Andrew Lee
- *
+ * Programmed by Andrew Lee
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -16,18 +16,18 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
+ *
***************************************************************************/
-import { Client, MessageEmbed, Collection, version } from 'discord.js'
-import { voiceInit } from './AudioBackend.js'
-import { readdirSync } from 'node:fs'
-import config from './config.json' assert { type: 'json' }
+import { Client, MessageEmbed, Collection, version } from 'discord.js';
+import { voiceInit } from './AudioBackend.js';
+import { readdirSync, readFileSync } from 'node:fs';
+// import config from './config.json' assert { type: 'json' } Not in ECMAScript yet
+const config = JSON.parse(readFileSync('./config.json'));
-const bot = new Client({intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']});
+const bot = new Client({ intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES'] });
bot.login(config.token);
-
/**
* Project Ideas:
* Shuffle or "Play by order" mode
@@ -47,7 +47,7 @@ for (const file of commandFiles) {
bot.once('ready', async () => {
console.log('Bot is ready!');
console.log(`Logged in as ${bot.user.tag}!`);
- console.log(`Running on Discord.JS ${version}`)
+ console.log(`Running on Discord.JS ${version}`);
console.log(`Voice Channel: ${config.voiceChannel}`);
console.log(`Status Channel: ${config.statusChannel}`);
@@ -57,7 +57,7 @@ bot.once('ready', async () => {
name: 'some beats',
type: 'LISTENING'
}],
- status: 'online',
+ status: 'online'
});
const activity = bot.presence.activities[0];
@@ -65,16 +65,15 @@ bot.once('ready', async () => {
// Send bots' status to channel
const readyEmbed = new MessageEmbed()
- .setAuthor({name: bot.user.username, iconURL: bot.user.avatarURL()})
- .setDescription('Starting bot...')
- .setColor('#0066ff')
+ .setAuthor({ name: bot.user.username, iconURL: bot.user.avatarURL() })
+ .setDescription('Starting bot...')
+ .setColor('#0066ff');
- let statusChannel = bot.channels.cache.get(config.statusChannel);
+ const statusChannel = bot.channels.cache.get(config.statusChannel);
if (!statusChannel) return console.error('The status channel does not exist! Skipping.');
- await statusChannel.send({embeds: [readyEmbed]});
+ await statusChannel.send({ embeds: [readyEmbed] });
await voiceInit(bot);
-
});
bot.on('interactionCreate', async interaction => {
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 });
+ }
+};
diff --git a/deploy-command.js b/deploy-command.js
index b3c2d76..f04872e 100644
--- a/deploy-command.js
+++ b/deploy-command.js
@@ -1,18 +1,19 @@
-import fs from 'node:fs'
-import { REST } from '@discordjs/rest'
-import { Routes } from 'discord-api-types/v10'
-import config from './config.json' assert {type: 'json'}
+import fs, { readFileSync } from 'node:fs';
+import { REST } from '@discordjs/rest';
+import { Routes } from 'discord-api-types/v10';
+// import config from './config.json' assert {type: 'json'}
+const config = JSON.parse(readFileSync('./config.json'));
const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
- const { default: command } = await import(`./commands/${file}`);
- commands.push(command.data.toJSON());
+ const { default: command } = await import(`./commands/${file}`);
+ commands.push(command.data.toJSON());
}
const rest = new REST({ version: '10' }).setToken(config.token);
rest.put(Routes.applicationGuildCommands(config.clientID, config.guildID), { body: commands })
- .then(() => console.log('Successfully registered application commands.'))
- .catch(console.error);
+ .then(() => console.log('Successfully registered application commands.'))
+ .catch(console.error);
diff --git a/package.json b/package.json
index 6a93082..5e72c09 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,11 @@
"libsodium-wrappers": "^0.7.10"
},
"devDependencies": {
+ "eslint": "^8.0.1",
+ "eslint-config-standard": "^17.0.0",
+ "eslint-plugin-import": "^2.25.2",
+ "eslint-plugin-n": "^15.0.0",
+ "eslint-plugin-promise": "^6.0.0",
"nodemon": "^2.0.15"
}
}