mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-24 10:31:56 +01:00
Update messages sent to users
This commit is contained in:
parent
de043b479f
commit
94f765af0d
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020 KGT1
|
Copyright (c) 2020 KGT1, zadi15
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -41,6 +41,7 @@ function getRandomDiscordColor () {
|
|||||||
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));
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Song Search, return the song itemID
|
||||||
async function searchForItemID (searchString) {
|
async function searchForItemID (searchString) {
|
||||||
const response = await jellyfinClientManager.getJellyfinClient().getSearchHints({
|
const response = await jellyfinClientManager.getJellyfinClient().getSearchHints({
|
||||||
searchTerm: searchString,
|
searchTerm: searchString,
|
||||||
@ -59,15 +60,38 @@ function summon (voiceChannel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function summonMessage (message) {
|
function summonMessage (message) {
|
||||||
|
getRandomDiscordColor();
|
||||||
if (!message.member.voice.channel) {
|
if (!message.member.voice.channel) {
|
||||||
message.reply("please join a voice channel to summon me!");
|
message.reply("please join a voice channel to summon me!");
|
||||||
} else if (message.channel.type === "dm") {
|
} else if (message.channel.type === "dm") {
|
||||||
message.reply("no dms");
|
message.reply("no dms");
|
||||||
} else {
|
} else {
|
||||||
|
var desc = "**Joined Voice Channel** `";
|
||||||
|
desc = desc.concat(message.member.voice.channel.name).concat("`");
|
||||||
|
|
||||||
summon(message.member.voice.channel);
|
summon(message.member.voice.channel);
|
||||||
|
|
||||||
|
const vcJoin = new Discord.MessageEmbed()
|
||||||
|
.setColor(getRandomDiscordColor())
|
||||||
|
.setTitle('Joined Channel')
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription("<:loudspeaker:757929476993581117> " + desc);
|
||||||
|
message.channel.send(vcJoin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function songPlayMessage (message, itemID, argument){
|
||||||
|
getRandomDiscordColor();
|
||||||
|
//const imageUrl = getImageUrl(itemID);
|
||||||
|
const play = new Discord.MessageEmbed()
|
||||||
|
.setColor(getRandomDiscordColor())
|
||||||
|
.setTitle('Now Playing')
|
||||||
|
//.setImage(imageUrl)
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription("<:mag_right:757935694403338380> " + 'Top result for: ' + argument);
|
||||||
|
message.channel.send(play);
|
||||||
|
}
|
||||||
|
|
||||||
async function playThis (message) {
|
async function playThis (message) {
|
||||||
const indexOfItemID = message.content.indexOf(CONFIG["discord-prefix"] + "play") + (CONFIG["discord-prefix"] + "play").length + 1;
|
const indexOfItemID = message.content.indexOf(CONFIG["discord-prefix"] + "play") + (CONFIG["discord-prefix"] + "play").length + 1;
|
||||||
const argument = message.content.slice(indexOfItemID);
|
const argument = message.content.slice(indexOfItemID);
|
||||||
@ -80,13 +104,19 @@ async function playThis (message) {
|
|||||||
try {
|
try {
|
||||||
itemID = await searchForItemID(argument);
|
itemID = await searchForItemID(argument);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.reply(e.message);
|
const noSong = new Discord.MessageEmbed()
|
||||||
|
.setColor(0xff0000)
|
||||||
|
.setTitle('Error!')
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription("<:x:757935515445231651> " + e);
|
||||||
|
message.channel.send(noSong);
|
||||||
playbackmanager.stop(discordClient.user.client.voice.connections.first());
|
playbackmanager.stop(discordClient.user.client.voice.connections.first());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
discordClient.user.client.voice.connections.forEach((element) => {
|
discordClient.user.client.voice.connections.forEach((element) => {
|
||||||
|
songPlayMessage(message, itemID, argument);
|
||||||
playbackmanager.startPlaying(element, itemID, isSummendByPlay);
|
playbackmanager.startPlaying(element, itemID, isSummendByPlay);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -106,11 +136,28 @@ function handleChannelMessage (message) {
|
|||||||
discordClient.user.client.voice.connections.forEach((element) => {
|
discordClient.user.client.voice.connections.forEach((element) => {
|
||||||
element.disconnect();
|
element.disconnect();
|
||||||
});
|
});
|
||||||
|
var desc = "**Left Voice Channel** `";
|
||||||
|
desc = desc.concat(message.member.voice.channel.name).concat("`");
|
||||||
|
const vcJoin = new Discord.MessageEmbed()
|
||||||
|
.setColor(getRandomDiscordColor())
|
||||||
|
.setTitle('Left Channel')
|
||||||
|
.setTimestamp()
|
||||||
|
.setDescription("<:wave:757938481585586226> " + desc);
|
||||||
|
message.channel.send(vcJoin);
|
||||||
} else if ((message.content.startsWith(CONFIG["discord-prefix"] + "pause")) || (message.content.startsWith(CONFIG["discord-prefix"] + "resume"))) {
|
} else if ((message.content.startsWith(CONFIG["discord-prefix"] + "pause")) || (message.content.startsWith(CONFIG["discord-prefix"] + "resume"))) {
|
||||||
if (getAudioDispatcher() !== undefined) {
|
if (getAudioDispatcher() !== undefined) {
|
||||||
playbackmanager.playPause();
|
playbackmanager.playPause();
|
||||||
|
const noPlay = new Discord.MessageEmbed()
|
||||||
|
.setColor(0xff0000)
|
||||||
|
.setTitle("<:play_pause:757940598106882049> " +'Paused/Resumed.')
|
||||||
|
.setTimestamp()
|
||||||
|
message.channel.send(noPlay);
|
||||||
} else {
|
} else {
|
||||||
message.reply("there is nothing playing!");
|
const noPlay = new Discord.MessageEmbed()
|
||||||
|
.setColor(0xff0000)
|
||||||
|
.setTitle("<:x:757935515445231651> " +'There is nothing Playing right now!')
|
||||||
|
.setTimestamp()
|
||||||
|
message.channel.send(noPlay);
|
||||||
}
|
}
|
||||||
} else if (message.content.startsWith(CONFIG["discord-prefix"] + "play")) {
|
} else if (message.content.startsWith(CONFIG["discord-prefix"] + "play")) {
|
||||||
if (discordClient.user.client.voice.connections.size < 1) {
|
if (discordClient.user.client.voice.connections.size < 1) {
|
||||||
@ -130,6 +177,7 @@ function handleChannelMessage (message) {
|
|||||||
} 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(getRandomDiscordColor())
|
.setColor(getRandomDiscordColor())
|
||||||
|
.setTitle("<:musical_note:757938541123862638> " + 'Jellyfin Discord Music Bot' + " <:musical_note:757938541123862638> ")
|
||||||
.addFields({
|
.addFields({
|
||||||
name: `${CONFIG["discord-prefix"]}summon`,
|
name: `${CONFIG["discord-prefix"]}summon`,
|
||||||
value: "Join the channel the author of the message"
|
value: "Join the channel the author of the message"
|
||||||
@ -145,6 +193,9 @@ function handleChannelMessage (message) {
|
|||||||
}, {
|
}, {
|
||||||
name: `${CONFIG["discord-prefix"]}help`,
|
name: `${CONFIG["discord-prefix"]}help`,
|
||||||
value: "Display this help message"
|
value: "Display this help message"
|
||||||
|
}, {
|
||||||
|
name: `GitHub`,
|
||||||
|
value: "Find the code for this bot at: https://github.com/KGT1/jellyfin-discord-music-bot"
|
||||||
});
|
});
|
||||||
message.channel.send(reply);
|
message.channel.send(reply);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user