mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +00:00
first commit
This commit is contained in:
commit
4eaea3a858
7 files changed
+1472
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
/node_modules
|
||||||
|
config.json
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# ⚡Radio - A Discord music and audio bot
|
||||||
|
|
||||||
|
A free music and audio bot for Discord. No locked functionality, and open source!
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
1. Install [Node.js](https://nodejs.org/en/download/) v18.16 LTS.
|
||||||
|
2. Install [FFmpeg](https://ffmpeg.org/download.html) latest release build.
|
||||||
|
3. Install dependencies with `npm install`.
|
||||||
|
4. Configure token for Discord bot in `config.json`.
|
||||||
|
5. Run `npm start` to start the bot.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// this event is emitted whenever discord-player starts to play a track
|
||||||
|
player.events.on('playerStart', (queue, track) => {
|
||||||
|
// we will later define queue.metadata object while creating the queue
|
||||||
|
queue.metadata.channel.send(`Started playing **${track.title}**!`);
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
const Discord = require('discord.js');
|
||||||
|
const { Player } = require('discord-player');
|
||||||
|
const { token } = require('./config.json');
|
||||||
|
|
||||||
|
// Setup required permissions for the bot to work
|
||||||
|
const client = new Discord.Client({
|
||||||
|
intents: [
|
||||||
|
Discord.GatewayIntentBits.Guilds,
|
||||||
|
Discord.GatewayIntentBits.GuildMessages,
|
||||||
|
Discord.GatewayIntentBits.GuildVoiceStates,
|
||||||
|
Discord.GatewayIntentBits.GuildMessageReactions
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Log to console when successfully logged in
|
||||||
|
client.on('ready', () => {
|
||||||
|
console.log(`Logged in as ${client.user.tag}!`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// this is the entrypoint for discord-player based application
|
||||||
|
const player = new Player(client);
|
||||||
|
|
||||||
|
// This method will load all the extractors from the @discord-player/extractor package
|
||||||
|
await player.extractors.loadDefault();
|
||||||
|
|
||||||
|
client.login(token);
|
||||||
Generated
+1388
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "radio-discord-bot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "⚡ A free music and audio bot for Discord.",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@discord-player/extractor": "^4.3.1",
|
||||||
|
"@discordjs/opus": "^0.9.0",
|
||||||
|
"discord-player": "^6.6.0",
|
||||||
|
"discord.js": "^14.11.0",
|
||||||
|
"ytdl-core": "^4.11.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
async function execute(interaction) {
|
||||||
|
const channel = interaction.member.voice.channel;
|
||||||
|
if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel
|
||||||
|
const query = interaction.options.getString('query', true); // we need input/query to play
|
||||||
|
|
||||||
|
// let's defer the interaction as things can take time to process
|
||||||
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { track } = await player.play(channel, query, {
|
||||||
|
nodeOptions: {
|
||||||
|
// nodeOptions are the options for guild node (aka your queue in simple word)
|
||||||
|
metadata: interaction // we can access this metadata object using queue.metadata later on
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return interaction.followUp(`**${track.title}** enqueued!`);
|
||||||
|
} catch (e) {
|
||||||
|
// let's return error if something failed
|
||||||
|
return interaction.followUp(`Something went wrong: ${e}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user