Add new rating notifications
This commit is contained in:
43
events/ratingReact.js
Normal file
43
events/ratingReact.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
const { Events, Partials } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: Events.MessageReactionAdd,
|
||||||
|
async execute(reaction, user) {
|
||||||
|
if (reaction.partial) {
|
||||||
|
try {
|
||||||
|
await reaction.fetch();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Reacted message can not be fecthed:', error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let channelWhitelist = [
|
||||||
|
'1220653860251762688', //musik hier
|
||||||
|
'1221748800671191050', //track der woche
|
||||||
|
'1220685344341757952', //playlists
|
||||||
|
'1159103323018891264' //test
|
||||||
|
];
|
||||||
|
|
||||||
|
if(!channelWhitelist.includes(reaction.message.channel.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let title = 'Unknown';
|
||||||
|
if(reaction.message.author.id == "816228963285860373") {
|
||||||
|
title = reaction.message.embeds[0].title;
|
||||||
|
} else {
|
||||||
|
console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`);
|
||||||
|
title = reaction.message.content.split("\n")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(title.startsWith('https://')) {
|
||||||
|
title = `<${title}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
await reaction.message.channel.send({
|
||||||
|
content: `${user.displayName} rated **${title}** with ${reaction._emoji.toString()}`,
|
||||||
|
reply: { messageReference: reaction.message.id }
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
5
main.js
5
main.js
@@ -1,10 +1,11 @@
|
|||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const { Client, Collection, Events, GatewayIntentBits, Options } = require('discord.js');
|
const { Client, Collection, Events, GatewayIntentBits, Options, Partials } = require('discord.js');
|
||||||
const { token } = require('./config.json');
|
const { token } = require('./config.json');
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences],
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessageReactions],
|
||||||
|
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
|
||||||
sweepers: {
|
sweepers: {
|
||||||
...Options.DefaultSweeperSettings,
|
...Options.DefaultSweeperSettings,
|
||||||
reactions: { interval: 300, filter: () => () => { return true } }
|
reactions: { interval: 300, filter: () => () => { return true } }
|
||||||
|
|||||||
Reference in New Issue
Block a user