mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-22 22:13:16 +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()
|
||||
.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}`)
|
||||
.setColor(client.config.embedColor);
|
||||
.setFooter('EximiaBots by Warén Media');
|
||||
msg.channel.send(embed);
|
||||
},
|
||||
};
|
@ -11,9 +11,9 @@ module.exports = {
|
||||
const command = client.commands.get(args[1]);
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.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)
|
||||
.setDescription(command.description + `\n Command Alias: \`${command.alias}\``)
|
||||
.setFooter('EximiaBots by Warén Media')
|
||||
msg.channel.send(embed);
|
||||
} else {
|
||||
const categories = [];
|
||||
@ -26,9 +26,9 @@ module.exports = {
|
||||
}
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(`${client.user.username} help:`)
|
||||
.setDescription(commands)
|
||||
.setFooter(`"${client.config.prefix}help <command>" to see more information about a command.`)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,9 @@ module.exports = {
|
||||
execute(msg, args, client, Discord, prefix) {
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle(`Invite ${client.user.username} to your Discord server!`)
|
||||
.setURL(client.config.invite)
|
||||
.setColor(client.config.embedColor)
|
||||
.setURL(client.config.invite)
|
||||
.setFooter('EximiaBots by Warén Media');
|
||||
return msg.channel.send(embed);
|
||||
}
|
||||
};
|
@ -11,11 +11,14 @@ module.exports = {
|
||||
if (!radio.playing) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.');
|
||||
radio.time = radio.connection.dispatcher.streamTime;
|
||||
const completed = (radio.time.toFixed(0));
|
||||
|
||||
const stations = await client.funcs.radiostations();
|
||||
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setTitle("__Now playing__")
|
||||
.setDescription(`<a:aNotes:674602408105476106>**Now playing:** ${radio.url}\n\`${client.funcs.msToTime(completed, "hh:mm:ss")}\``)
|
||||
.setTitle("<a:aNotes:674602408105476106> Now Playing")
|
||||
.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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@ module.exports = {
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
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 voiceChannel = msg.member.voice.channel;
|
||||
if (!radio) {
|
||||
@ -25,7 +25,8 @@ module.exports = {
|
||||
|
||||
if (radio) {
|
||||
radio.connection.dispatcher.destroy();
|
||||
client.funcs.play(msg.guild, client, url);
|
||||
radio.station = station;
|
||||
client.funcs.play(msg.guild, client, station);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ module.exports = {
|
||||
voiceChannel: voiceChannel,
|
||||
connection: null,
|
||||
playing: false,
|
||||
url: url,
|
||||
station: station-1,
|
||||
name: null,
|
||||
volume: client.config.volume,
|
||||
};
|
||||
@ -43,7 +44,7 @@ module.exports = {
|
||||
try {
|
||||
const connection = await voiceChannel.join();
|
||||
construct.connection = connection;
|
||||
client.funcs.play(msg.guild, client, url);
|
||||
client.funcs.play(msg.guild, client, station);
|
||||
} catch (error) {
|
||||
client.radio.delete(msg.guild.id);
|
||||
client.debug_channel.send("Error with connecting to voice channel: " + error);
|
||||
|
@ -20,6 +20,7 @@
|
||||
"discord.js": "^12.0.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"fs": "0.0.1-security",
|
||||
"node-fetch": "^2.6.0",
|
||||
"path": "^0.12.7"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { Client, Collection } = require('discord.js');
|
||||
const Discord = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const path = require('path')
|
||||
const path = require('path');
|
||||
const events = '../events/';
|
||||
|
||||
module.exports = class extends Client {
|
||||
@ -29,10 +29,6 @@ module.exports = class extends Client {
|
||||
this.commandAliases.set(command.alias, command);
|
||||
}
|
||||
|
||||
if (this.config.devMode) {
|
||||
this.config.token = this.config.devToken;
|
||||
}
|
||||
|
||||
this.on('ready', () => {
|
||||
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 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
|
||||
.play(url, { bitrate: 1024, passes: 10, volume: 1, highWaterMark: 1 << 25 })
|
||||
.on("finish", () => {
|
||||
@ -8,16 +28,21 @@ module.exports = async function (guild, client, url) {
|
||||
client.radio.delete(guild.id);
|
||||
return;
|
||||
});
|
||||
|
||||
dispatcher.on('start', () => {
|
||||
dispatcher.player.streamingData.pausedTime = 0;
|
||||
});
|
||||
|
||||
dispatcher.on('error', error => {
|
||||
console.error(error);
|
||||
radio.voiceChannel.leave();
|
||||
client.radio.delete(guild.id);
|
||||
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
|
||||
});
|
||||
|
||||
dispatcher.setVolume(radio.volume / 10);
|
||||
|
||||
radio.textChannel.send('Start playing');
|
||||
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