added random color for help messages

This commit is contained in:
KGT1 2020-09-05 08:59:09 +02:00
parent 1235298d98
commit 6d1ac84be0

View File

@ -2,13 +2,43 @@ const CONFIG = require('../config.json');
const Discord = require('discord.js'); const Discord = require('discord.js');
const {getAudioDispatcher,setAudioDispatcher} = require('./dispachermanager'); const {
getAudioDispatcher,
setAudioDispatcher
} = require('./dispachermanager');
const discordclientmanager = require('./discordclientmanager'); const discordclientmanager = require('./discordclientmanager');
const discordClient=discordclientmanager.getDiscordClient(); const discordClient = discordclientmanager.getDiscordClient();
function handleChannelMessage(message){ //random Color of the Jellyfin Logo Gradient
function getRandomDiscordColor() {
function randomNumber(b,a){
return Math.floor((Math.random()*Math.pow(Math.pow((b-a),2),1/2))+(b>a?a:b))
}
const GRANDIENT_START='#AA5CC3';
const GRANDIENT_END='#00A4DC';
let rS=GRANDIENT_START.slice(1,3);
let gS=GRANDIENT_START.slice(3,5);
let bS=GRANDIENT_START.slice(5,7);
rS=parseInt(rS,16);
gS=parseInt(gS,16);
bS=parseInt(bS,16);
let rE=GRANDIENT_END.slice(1,3);
let gE=GRANDIENT_END.slice(3,5);
let bE=GRANDIENT_END.slice(5,7);
rE=parseInt(rE,16);
gE=parseInt(gE,16);
bE=parseInt(bE,16);
return ('#'+('00'+(randomNumber(rS,rE)).toString(16)).substr(-2)+('00'+(randomNumber(gS,gE)).toString(16)).substr(-2)+('00'+(randomNumber(bS,bE)).toString(16)).substr(-2));
}
function handleChannelMessage(message) {
getRandomDiscordColor()
if (message.content.startsWith(CONFIG["discord-prefix"] + 'summon')) { if (message.content.startsWith(CONFIG["discord-prefix"] + 'summon')) {
if (message.channel.type === 'dm') { if (message.channel.type === 'dm') {
@ -30,25 +60,34 @@ function handleChannelMessage(message){
element.disconnect(); element.disconnect();
}); });
} else if (message.content.startsWith(CONFIG["discord-prefix"] + 'pause')) { } else if (message.content.startsWith(CONFIG["discord-prefix"] + 'pause')) {
if(getAudioDispatcher()!==undefined){ if (getAudioDispatcher() !== undefined) {
if(getAudioDispatcher().paused) if (getAudioDispatcher().paused)
getAudioDispatcher().resume(); getAudioDispatcher().resume();
else else
getAudioDispatcher().pause(true); getAudioDispatcher().pause(true);
}else{ } else {
console.log("WHYYYYYYY") console.log("WHYYYYYYY")
console.log(getAudioDispatcher()); console.log(getAudioDispatcher());
} }
}else if (message.content.startsWith(CONFIG["discord-prefix"] + 'help')) { } else if (message.content.startsWith(CONFIG["discord-prefix"] + 'help')) {
const reply = new Discord.MessageEmbed() const reply = new Discord.MessageEmbed()
.setColor('#00A4DC') .setColor(getRandomDiscordColor())
.addFields( .addFields({
{ name: `${CONFIG['discord-prefix']}summon`, value: 'Join the channel the author of the message' }, name: `${CONFIG['discord-prefix']}summon`,
{ name: `${CONFIG['discord-prefix']}disconnect`, value: 'Disconnect from all current Voice Channels' }, value: 'Join the channel the author of the message'
{ name: `${CONFIG['discord-prefix']}play`, value: 'Play the following item' }, }, {
{ name: `${CONFIG['discord-prefix']}pause/resume`, value: 'Pause/Resume audio' }, name: `${CONFIG['discord-prefix']}disconnect`,
{ name: `${CONFIG['discord-prefix']}help`, value: 'Display this help message' } value: 'Disconnect from all current Voice Channels'
) }, {
name: `${CONFIG['discord-prefix']}play`,
value: 'Play the following item'
}, {
name: `${CONFIG['discord-prefix']}pause/resume`,
value: 'Pause/Resume audio'
}, {
name: `${CONFIG['discord-prefix']}help`,
value: 'Display this help message'
})
message.channel.send(reply); message.channel.send(reply);
} }
} }