• 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 why does this not work

Faddi

Member
Hello I made a script tha should react to any message in specific channels. It doesn't work can you please help me? :D

Code:
registerPlugin({
    name: 'Reaction',
    version: 'beta0.0.1',
    backends: ['ts3', 'discord'],
    description: 'Here you can make automatic reactions on specific channels',
    author: 'Faddi <[email protected]>',
    vars: []
}, (sinusbot, config) => {
    // import modules
    const engine = require('engine');
    const event = require('event');

    // listen for chat event
client.on("message", msg => {
    
  if(msg.channel.name === "memes") {
    msg.react('??')
        msg.react('??')
         msg.react('??')
  }
    if(msg.channel.name === "clips") {
    msg.react('??')
        msg.react('??')
         msg.react('??')
}
    });
});
 

Caudex

Insider
Insider
Try (not tested):
JavaScript:
registerPlugin({
    name: 'Reaction',
    version: 'beta0.0.1',
    backends: ['ts3', 'discord'],
    description: 'Here you can make automatic reactions on specific channels',
    author: 'Faddi <[email protected]>',
    vars: []
}, (sinusbot, config) => {
    // import modules
    const engine = require('engine');
    const event = require('event');

    // listen for chat event
event.on("chat", function(ev) {
   
  if(ev.channel.name === "memes") {
   //use https://sinusbot.github.io/scripting-docs/#discordmessagecreatereaction for reactions
  }
    if(ev.channel.name === "clips") {
   //use https://sinusbot.github.io/scripting-docs/#discordmessagecreatereaction for reactions, ev.createReaction(name:id) should work (idk exactly because I'm a Teamspeak-only user
}
    });
});
 

Caudex

Insider
Insider
Emojis can be created with the following or similiar to it:
JavaScript:
ev.createReaction(name:id)

Since I am only using Teamspeak and no Discord at all, I don't know how they have structured their API.
A quick research said the following:
There is a emoji called :beeg: (Source) which could be accessed by
JavaScript:
ev.createReaction(<a:beeg:587026903584735243>)
//or maybe
ev.createReaction(<:beeg:587026903584735243>)
//or maybe
ev.createReaction(<:beeg:587026903584735243>)
//or maybe
ev.createReaction(:beeg:587026903584735243)
//or maybe
ev.createReaction(beeg:587026903584735243)
//or maybe some of the above quoted as string with " "
According to the Source mentioned above there was a answer on how to find out a emoji id:
You can get the ID's with:

  • \:emojiname:
  • \#channelname
  • \@rolename
  • \@username



Maybe somebody else knows Discord. Otherwise you have to test for yourself until you can create a emoji.
And again I am referring to the docs of the Sinusbot https://sinusbot.github.io/scripting-docs/#discordmessagecreatereaction. Hopefully you will find the solution and share it with everybody else who will search for it in the future ;)
 

Caudex

Insider
Insider
I just found this in the docs:
JavaScript:
var event = require('event');

event.on('message', msg => {
    // like message
    msg.createReaction('👍');
});
 

Caudex

Insider
Insider
JavaScript:
var event = require('event');

event.on('message', msg => {
// like message
if(msg.channelID() == yourChannelID) {
    msg.createReaction('👍');
  }
});

[/code
 
Top