mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-09 23:00:18 +00:00
Radio Stations from JSON file
This commit is contained in:
parent
e0d25d97a5
commit
6e11029461
@ -20,8 +20,9 @@ module.exports = {
|
|||||||
|
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`)
|
.setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`)
|
||||||
|
.setColor(client.config.embedColor)
|
||||||
.setDescription(`${developers}\nOr join the support server: ${client.config.supportGuild}`)
|
.setDescription(`${developers}\nOr join the support server: ${client.config.supportGuild}`)
|
||||||
.setColor(client.config.embedColor);
|
.setFooter('EximiaBots by Warén Media');
|
||||||
msg.channel.send(embed);
|
msg.channel.send(embed);
|
||||||
},
|
},
|
||||||
};
|
};
|
@ -11,9 +11,9 @@ module.exports = {
|
|||||||
const command = client.commands.get(args[1]);
|
const command = client.commands.get(args[1]);
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(`${client.global.db.guilds[msg.guild.id].prefix}${command.name} ${command.usage}`)
|
.setTitle(`${client.global.db.guilds[msg.guild.id].prefix}${command.name} ${command.usage}`)
|
||||||
.setDescription(command.description)
|
|
||||||
.setFooter(`Command Alias: \`${command.alias}\``)
|
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
|
.setDescription(command.description + `\n Command Alias: \`${command.alias}\``)
|
||||||
|
.setFooter('EximiaBots by Warén Media')
|
||||||
msg.channel.send(embed);
|
msg.channel.send(embed);
|
||||||
} else {
|
} else {
|
||||||
const categories = [];
|
const categories = [];
|
||||||
@ -26,9 +26,9 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(`${client.user.username} help:`)
|
.setTitle(`${client.user.username} help:`)
|
||||||
.setDescription(commands)
|
|
||||||
.setFooter(`"${client.config.prefix}help <command>" to see more information about a command.`)
|
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
|
.setDescription(commands + `\n "${client.config.prefix}help <command>" to see more information about a command.`)
|
||||||
|
.setFooter('EximiaBots by Warén Media');
|
||||||
msg.channel.send(embed);
|
msg.channel.send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ module.exports = {
|
|||||||
execute(msg, args, client, Discord, prefix) {
|
execute(msg, args, client, Discord, prefix) {
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle(`Invite ${client.user.username} to your Discord server!`)
|
.setTitle(`Invite ${client.user.username} to your Discord server!`)
|
||||||
.setURL(client.config.invite)
|
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
|
.setURL(client.config.invite)
|
||||||
|
.setFooter('EximiaBots by Warén Media');
|
||||||
return msg.channel.send(embed);
|
return msg.channel.send(embed);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -11,11 +11,14 @@ module.exports = {
|
|||||||
if (!radio.playing) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.');
|
if (!radio.playing) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.');
|
||||||
radio.time = radio.connection.dispatcher.streamTime;
|
radio.time = radio.connection.dispatcher.streamTime;
|
||||||
const completed = (radio.time.toFixed(0));
|
const completed = (radio.time.toFixed(0));
|
||||||
|
|
||||||
|
const stations = await client.funcs.radiostations();
|
||||||
|
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setTitle("__Now playing__")
|
.setTitle("<a:aNotes:674602408105476106> Now Playing")
|
||||||
.setDescription(`<a:aNotes:674602408105476106>**Now playing:** ${radio.url}\n\`${client.funcs.msToTime(completed, "hh:mm:ss")}\``)
|
|
||||||
.setColor(client.config.embedColor)
|
.setColor(client.config.embedColor)
|
||||||
|
.setDescription(`**${stations[radio.station].name}** \n Owner: ${stations[radio.station].owner} \n\`${client.funcs.msToTime(completed, "hh:mm:ss")}\``)
|
||||||
|
.setFooter('EximiaBots by Warén Media');
|
||||||
return msg.channel.send(embed);
|
return msg.channel.send(embed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, prefix) {
|
||||||
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
const station = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
||||||
const radio = client.radio.get(msg.guild.id);
|
const radio = client.radio.get(msg.guild.id);
|
||||||
const voiceChannel = msg.member.voice.channel;
|
const voiceChannel = msg.member.voice.channel;
|
||||||
if (!radio) {
|
if (!radio) {
|
||||||
@ -25,25 +25,26 @@ module.exports = {
|
|||||||
|
|
||||||
if (radio) {
|
if (radio) {
|
||||||
radio.connection.dispatcher.destroy();
|
radio.connection.dispatcher.destroy();
|
||||||
client.funcs.play(msg.guild, client, url);
|
radio.station = station;
|
||||||
|
client.funcs.play(msg.guild, client, station);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const construct = {
|
const construct = {
|
||||||
textChannel: msg.channel,
|
textChannel: msg.channel,
|
||||||
voiceChannel: voiceChannel,
|
voiceChannel: voiceChannel,
|
||||||
connection: null,
|
connection: null,
|
||||||
playing: false,
|
playing: false,
|
||||||
url: url,
|
station: station-1,
|
||||||
name: null,
|
name: null,
|
||||||
volume: client.config.volume,
|
volume: client.config.volume,
|
||||||
};
|
};
|
||||||
client.radio.set(msg.guild.id, construct);
|
client.radio.set(msg.guild.id, construct);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const connection = await voiceChannel.join();
|
const connection = await voiceChannel.join();
|
||||||
construct.connection = connection;
|
construct.connection = connection;
|
||||||
client.funcs.play(msg.guild, client, url);
|
client.funcs.play(msg.guild, client, station);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
client.radio.delete(msg.guild.id);
|
client.radio.delete(msg.guild.id);
|
||||||
client.debug_channel.send("Error with connecting to voice channel: " + error);
|
client.debug_channel.send("Error with connecting to voice channel: " + error);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"discord.js": "^12.0.1",
|
"discord.js": "^12.0.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
"path": "^0.12.7"
|
"path": "^0.12.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const { Client, Collection } = require('discord.js');
|
const { Client, Collection } = require('discord.js');
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
const events = '../events/';
|
const events = '../events/';
|
||||||
|
|
||||||
module.exports = class extends Client {
|
module.exports = class extends Client {
|
||||||
@ -29,10 +29,6 @@ module.exports = class extends Client {
|
|||||||
this.commandAliases.set(command.alias, command);
|
this.commandAliases.set(command.alias, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.devMode) {
|
|
||||||
this.config.token = this.config.devToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.on('ready', () => {
|
this.on('ready', () => {
|
||||||
require(`${events}ready`).execute(this, Discord);
|
require(`${events}ready`).execute(this, Discord);
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
module.exports = async function (guild, client, url) {
|
module.exports = async function (guild, client, station) {
|
||||||
|
|
||||||
const radio = client.radio.get(guild.id);
|
const radio = client.radio.get(guild.id);
|
||||||
|
const stations = await client.funcs.radiostations();
|
||||||
|
let url = "";
|
||||||
|
|
||||||
|
if(isNaN(station)){
|
||||||
|
radio.voiceChannel.leave();
|
||||||
|
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(station-1 > stations.length-1){
|
||||||
|
radio.voiceChannel.leave();
|
||||||
|
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
||||||
|
}
|
||||||
|
|
||||||
|
url = stations[station-1].stream[stations[station-1].stream.default];
|
||||||
|
|
||||||
|
if(!url) {
|
||||||
|
radio.voiceChannel.leave();
|
||||||
|
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
||||||
|
}
|
||||||
|
|
||||||
const dispatcher = radio.connection
|
const dispatcher = radio.connection
|
||||||
.play(url, { bitrate: 1024, passes: 10, volume: 1, highWaterMark: 1 << 25 })
|
.play(url, { bitrate: 1024, passes: 10, volume: 1, highWaterMark: 1 << 25 })
|
||||||
.on("finish", () => {
|
.on("finish", () => {
|
||||||
@ -8,16 +28,21 @@ module.exports = async function (guild, client, url) {
|
|||||||
client.radio.delete(guild.id);
|
client.radio.delete(guild.id);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatcher.on('start', () => {
|
dispatcher.on('start', () => {
|
||||||
dispatcher.player.streamingData.pausedTime = 0;
|
dispatcher.player.streamingData.pausedTime = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatcher.on('error', error => {
|
dispatcher.on('error', error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
radio.voiceChannel.leave();
|
radio.voiceChannel.leave();
|
||||||
client.radio.delete(guild.id);
|
client.radio.delete(guild.id);
|
||||||
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatcher.setVolume(radio.volume / 10);
|
dispatcher.setVolume(radio.volume / 10);
|
||||||
|
|
||||||
radio.textChannel.send('Start playing');
|
radio.textChannel.send('Start playing');
|
||||||
radio.playing = true;
|
radio.playing = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
9
struct/funcs/radiostations.js
Normal file
9
struct/funcs/radiostations.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = async function () {
|
||||||
|
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
let data = fetch('https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json')
|
||||||
|
.then(res => res.json());
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user