• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN Script - add role discord

Hello, I recently tried to create a script to add a discord role when someone reacts to a message.

Here is the script:

}, (_, config, meta) => {
const event = require('event')
const engine = require('engine')
const backend = require('backend')
const format = require('format')
const audio = require('audio')
const media = require('media')
const track = require('track')
const discord = require('discord.js');
const lineReply = require('discord-reply')
const client = require('client')

/** @property {DiscordMessage} [message] */
/** @param {(msg: string) => void} reply */
event.on('discord:MESSAGE_REACTION_ADD', (ev) => {
if (ev.channel_id == "895489651559792691") {
engine.log("Channel ID:" + ev.channel_id);
engine.log("User ID:" + ev.user_id);
ev.client.addToServerGroup("895489499310731294/895492607281598474");
}
});
})
But I have an error when on the "addToServerGroup" method, do you have the solution to fix this problem?
2021-10-14T20:10:26+02:00 error on callback func: Uncaught exception: TypeError: Cannot read property 'addToServerGroup' of undefined at reaction_rules:31:22 ev.client.addToServerGroup("895489499310731294/895492607281598474"); ^ Stack trace: TypeError: Cannot read property 'addToServerGroup' of undefined at event.on (reaction_rules:31:23)
2021-10-14T20:10:26+02:00 [ reaction_rules:30:20] User ID:869282555273314395
2021-10-14T20:10:26+02:00 [ reaction_rules:29:20] Channel ID:895489651559792691
2021-10-14T20:10:26+02:00 event: MESSAGE_REACTION_ADD {"user_id":"869282555273314395","message_id":"896692115952783413","member":{"user":{"username":"Swixo","id":"869282555273314395","discriminator":"7615","avatar":"60a400205bfefdcc96a7005ed5fa7bb5"},"roles":["895492446056759296","895492225767714836"],"premium_since":null,"pending":false,"nick":"A | Swixo","mute":false,"joined_at":"2021-10-07T05:44:36.948616+00:00","is_pending":false,"hoisted_role":"895492225767714836","deaf":false,"avatar":null},"emoji":{"name":"✅","id":null},"channel_id":"895489651559792691","guild_id":"895489499310731294"}
2021-10-14T20:10:25+02:00 unhandled discord message: MESSAGE_REACTION_REMOVE / {"user_id":"869282555273314395","message_id":"896692115952783413","emoji":{"name":"✅","id":null},"channel_id":"895489651559792691","guild_id":"895489499310731294"}
2021-10-14T20:10:25+02:00 event: MESSAGE_REACTION_REMOVE {"user_id":"869282555273314395","message_id":"896692115952783413","emoji":{"name":"✅","id":null},"channel_id":"895489651559792691","guild_id":"895489499310731294"}
Thank you in advance for your help ! :)
 
Top