diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-12-18 22:31:04 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-12-18 22:36:32 -0500 |
| commit | c55e480e4d8dbf9d3c11cb7a13c69f9f1ab730db (patch) | |
| tree | 848c4cdc3e1efb003cc7dacf3f3670ae62562fa0 /commands | |
| parent | 4c25284974a1575b942e3d07bf00afa2614cd376 (diff) | |
| download | DLAP-c55e480e4d8dbf9d3c11cb7a13c69f9f1ab730db.tar.gz DLAP-c55e480e4d8dbf9d3c11cb7a13c69f9f1ab730db.tar.bz2 DLAP-c55e480e4d8dbf9d3c11cb7a13c69f9f1ab730db.zip | |
Improved list command; Directory name change; Fixed ActivityType
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/about.js | 56 | ||||
| -rw-r--r-- | commands/join.js | 36 | ||||
| -rw-r--r-- | commands/leave.js | 37 | ||||
| -rw-r--r-- | commands/list.js | 42 | ||||
| -rw-r--r-- | commands/next.js | 42 | ||||
| -rw-r--r-- | commands/pause.js | 40 | ||||
| -rw-r--r-- | commands/ping.js | 31 | ||||
| -rw-r--r-- | commands/play.js | 58 | ||||
| -rw-r--r-- | commands/previous.js | 39 | ||||
| -rw-r--r-- | commands/reshuffle.js | 44 | ||||
| -rw-r--r-- | commands/shutdown.js | 35 | ||||
| -rw-r--r-- | commands/status.js | 75 |
12 files changed, 0 insertions, 535 deletions
diff --git a/commands/about.js b/commands/about.js deleted file mode 100644 index 23c750e..0000000 --- a/commands/about.js +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { EmbedBuilder, version, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } from 'discord.js'; -// import npmPackage from '../package.json' assert { type:'json' } -import { readFileSync } from 'node:fs'; -const npmPackage = JSON.parse(readFileSync('./package.json', 'utf-8')); - -export default { - data: new SlashCommandBuilder() - .setName('about') - .setDescription('Information about the bot'), - async execute(interaction, bot) { - const aboutEmbed = new EmbedBuilder() - .setAuthor({ name: `About ${bot.user.username}`, iconURL: bot.user.avatarURL() }) - .addFields( - { name: 'Information', value: 'A Discord bot that plays local audio tracks.' }, - { name: 'Version', value: `DLAP ${npmPackage.version}` }, - { name: 'Original Creator', value: 'Andrew Lee (Alee#4277)' }, // Do not remove this since I created this :) - // { name: 'Contributors', value: '[your name] (discord#0000)' }, - // { name: 'Forked by', value: '[your name] (discord#0000)' }, - { name: 'Frameworks', value: `Discord.JS ${version} + Voice` }, - { name: 'License', value: 'GNU General Public License v3.0' } - ) - .setFooter({ text: '© Copyright 2020-2022 Andrew Lee' }) - .setColor('#0066ff'); - - const srcOrig = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setStyle(ButtonStyle.Link) - .setLabel('Original Source Code') - .setURL('https://github.com/Alee14/DLAP') - ); - - return await interaction.reply({ embeds: [aboutEmbed], components: [srcOrig] }); - } -}; diff --git a/commands/join.js b/commands/join.js deleted file mode 100644 index aa3eb66..0000000 --- a/commands/join.js +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { voiceInit } from '../backend/VoiceInitialization.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) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - await interaction.reply({ content: 'Joining voice channel', ephemeral: true }); - return await voiceInit(bot); - } -}; diff --git a/commands/leave.js b/commands/leave.js deleted file mode 100644 index 1577baa..0000000 --- a/commands/leave.js +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { destroyAudio } from '../backend/Shutdown.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) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - 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 deleted file mode 100644 index 8eddcda..0000000 --- a/commands/list.js +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { readdirSync, readdir } from 'node: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. - - 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/next.js b/commands/next.js deleted file mode 100644 index 759c5bb..0000000 --- a/commands/next.js +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { player } from '../backend/VoiceInitialization.js'; -import { nextAudio, playerState } from '../backend/AudioControl.js'; -import { PermissionFlagsBits } from 'discord-api-types/v10'; - -export default { - data: new SlashCommandBuilder() - .setName('next') - .setDescription('Goes to next music') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async execute(interaction, bot) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - if (playerState === 'Playing' || playerState === 'Paused') { - await interaction.reply({ content: 'Playing next music', ephemeral: true }); - player.stop(); - return await nextAudio(bot); - } else if (playerState === 'Stopped') { - return await interaction.reply({ content: 'Cannot play next music. Player is currently stopped...', ephemeral: true }); - } - } -}; diff --git a/commands/pause.js b/commands/pause.js deleted file mode 100644 index 61b9e21..0000000 --- a/commands/pause.js +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { toggleAudioState, isAudioStatePaused } from '../backend/AudioControl.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 (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - if (!isAudioStatePaused) { - toggleAudioState(); - 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 deleted file mode 100644 index 72ef024..0000000 --- a/commands/ping.js +++ /dev/null @@ -1,31 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; - -export default { - 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 deleted file mode 100644 index 4c95ab8..0000000 --- a/commands/play.js +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { inputAudio } from '../backend/QueueSystem.js'; -import { files, isAudioStatePaused, toggleAudioState } from '../backend/AudioControl.js'; -import { audio } from '../backend/PlayAudio.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), - - async execute(interaction, bot) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - 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) { - toggleAudioState(); - 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/previous.js b/commands/previous.js deleted file mode 100644 index ebedbb6..0000000 --- a/commands/previous.js +++ /dev/null @@ -1,39 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { playerState, previousAudio } from '../backend/AudioControl.js'; -import { PermissionFlagsBits } from 'discord-api-types/v10'; - -export default { - data: new SlashCommandBuilder() - .setName('previous') - .setDescription('Goes to previous music') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async execute(interaction, bot) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - if (playerState === 'Playing' || playerState === 'Paused') { - return await previousAudio(bot, interaction); - } else if (playerState === 'Stopped') { - return await interaction.reply({ content: 'Cannot play next music. Player is currently stopped...', ephemeral: true }); - } - } -}; diff --git a/commands/reshuffle.js b/commands/reshuffle.js deleted file mode 100644 index e1d37d0..0000000 --- a/commands/reshuffle.js +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { shufflePlaylist } from '../backend/QueueSystem.js'; -import { PermissionFlagsBits } from 'discord-api-types/v10'; -import { readFileSync } from 'node:fs'; -import { audioState } from '../backend/AudioControl.js'; -// import config from './config.json' assert {type: 'json'} -const { shuffle } = JSON.parse(readFileSync('./config.json', 'utf-8')); - -export default { - data: new SlashCommandBuilder() - .setName('reshuffle') - .setDescription('Reshuffles the playlist') - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async execute(interaction, bot) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - async function shuffleDetected(bot) { - await interaction.reply({ content: 'Reshuffling the playlist...', ephemeral: true }); - await audioState(2); - await shufflePlaylist(bot); - } - return (shuffle) ? await shuffleDetected(bot) : await interaction.reply({ content: 'Shuffle mode is disabled, enable it in the configuration file to access this command.', ephemeral: true }); - } -}; diff --git a/commands/shutdown.js b/commands/shutdown.js deleted file mode 100644 index 313866b..0000000 --- a/commands/shutdown.js +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { SlashCommandBuilder } from 'discord.js'; -import { stopBot } from '../backend/Shutdown.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); - } -}; diff --git a/commands/status.js b/commands/status.js deleted file mode 100644 index d19e4ac..0000000 --- a/commands/status.js +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************** - * - * DLAP Bot: A Discord bot that plays local audio tracks. - * (C) Copyright 2022 - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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 { EmbedBuilder, SlashCommandBuilder } from 'discord.js'; -import { parseFile } from 'music-metadata'; -import { audio, metadataEmpty, duration, audioTitle, currentTrack } from '../backend/PlayAudio.js'; -import { files, playerState } from '../backend/AudioControl.js'; - -export default { - data: new SlashCommandBuilder() - .setName('status') - .setDescription('Checks what audio file is playing currently'), - async execute(interaction, bot) { - if (!interaction.member.voice.channel) return await interaction.reply({ content: 'You need to be in a voice channel to use this command.', ephemeral: true }); - let audioID = currentTrack; - audioID++; - - let audioName = files[audioID]; - - if (audioName === undefined) { - audioName = 'Playlist Finished'; - } else { - if (!metadataEmpty) { - try { - const { common } = await parseFile('music/' + audioName); - audioName = common.title; - } catch (error) { - console.error(error.message); - } - } else { - audioName = audioName.split('.').slice(0, -1).join('.'); - } - } - - const controlEmbed = new EmbedBuilder() - .setAuthor({ name: `${bot.user.username} Status`, iconURL: bot.user.avatarURL() }) - .addFields( - { name: 'State', value: playerState }, - { name: 'Tracks', value: `${audioID}/${files.length}` }, - { name: 'Duration', value: duration } - ) - .setColor('#0066ff'); - - if (metadataEmpty) { - controlEmbed.addFields( - { name: 'Currently Playing', value: audio }, - { name: 'Up Next', value: audioName } - ); - } else { - controlEmbed.addFields( - { name: 'Currently Playing', value: audioTitle }, - { name: 'Up Next', value: audioName } - ); - } - interaction.reply({ embeds: [controlEmbed] }); - } -}; |
