All messages in separate file.

This commit is contained in:
Christer Warén
2020-03-13 00:53:23 +02:00
parent 695c5a1e40
commit 7f2a1755eb
14 changed files with 105 additions and 42 deletions

View File

@ -1,12 +1,11 @@
module.exports = function (client, msg, command) {
const radio = client.radio.get(msg.guild.id);
const permissions = msg.channel.permissionsFor(msg.author);
if (!radio || !radio.playing) return msg.channel.send('There is nothing playing!');
if (msg.author.id !== client.config.devId) {
if (msg.member.voice.channel !== radio.voiceChannel) return msg.channel.send(`You need to be in the same voice channel as RadioX to use this command!`);
if (!permissions.has(command.permission)) {
msg.channel.send(`You need the \`${command.permission}\` permission to use this command!`);
return false;
} else return true;
if (!radio || !radio.playing) return msg.channel.send(client.messages.notPlaying);
if (msg.member.voice.channel !== radio.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
if (!permissions.has(command.permission)) {
client.messages.noPerms = client.messages.noPerms.replace("%commands.permissions%", commands.permissions);
msg.channel.send(client.messages.noPerms);
return false;
} else return true;
};

View File

@ -15,8 +15,8 @@ module.exports = class extends Client {
this.radio = new Map();
this.funcs = {};
this.dispatcher = {};
this.config = require('./config.js');
this.config = require('../config.js');
this.messages = require('./messages.js');
this.funcs.check = require('./check.js');
const commandFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands')).filter(f => f.endsWith('.js'));

View File

@ -1,22 +0,0 @@
require('dotenv/config');
module.exports = {
//credentials
token: process.env.DISCORD_TOKEN,
//support
supportGuild: "https://discord.gg/rRA65Mn",
devId: [
"493174343484833802",
"360363051792203779"
],
//misc
embedColor: "#88aa00",
invite: "https://discordapp.com/api/oauth2/authorize?client_id=684109535312609409&permissions=3427328&scope=bot",
//Settings
prefix: "rx>",
volume: 5
}

32
struct/messages.js Normal file
View File

@ -0,0 +1,32 @@
module.exports = {
wrongVoiceChannel: "You need to be in the same voice channel as RadioX to use this command!",
noPerms: "You need the %command.permission% permission to use this command!",
notPlaying: "There is nothing playing!",
runningCommandFailed: "Running this command failed!",
noPermsEmbed: "I cannot send embeds (Embed links).",
bugTitle: "Found a bug with %client.user.username%?\nDM one of the core developers:",
bugDescription: "%client.developers%\nOr join the support server: %client.config.supportGuild%",
helpTitle: "%client.user.username% help:",
helpDescription: "%commands% \n %client.config.prefix%help <command> to see more information about a command.",
helpCommandTitle: "%client.config.prefix%%command.name% %command.usage%",
helpCommandDescription: "%command.description% \n Command Alias: %command.alias%",
inviteTitle: "Invite %client.user.username% to your Discord server!",
listTitle: "Radio Stations",
nowplayingTitle: "Now Playing",
nowplayingDescription: "**%radio.station.name%** \n Owner: %radio.station.owner% \n %msToTime(completed, \"hh:mm:ss\")%",
noVoiceChannel: "You need to be in a voice channel to play music!",
noQuery: "You need to use a number or search for a supported station!",
noPermsConnect: "I cannot connect to your voice channel.",
noPermsSpeak: "I cannot speak in your voice channel.",
wrongStationNumber: "No such station!",
tooShortSearch: "Station must be over 2 characters!",
noSearchResults: "No stations found!",
errorPlaying: "An error has occured while playing radio!",
play: "Start playing: %radio.station.name%",
stop: "Stopped playback!",
currentVolume: "Current volume: **%radio.volume%**",
maxVolume: "The max volume is `100`!",
invalidVolume: "You need to enter a valid __number__.",
negativeVolume: "The volume needs to be a positive number!",
newVolume: "Volume is now: **%volume%**"
};