With Discord.io I'm trying to send a message to a different channel than what it is sent from, but after a lot of Googling and experimenting I still can't seem to find a way to do so.
I tried to simply change the channelID to the channel I want it to send to and overide the channelID to the channel I want it to send to, but with no success
For example:
bot.on('message', function (user, userID, channelID, message, evt) {
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0].toLowerCase();
args = args.splice(1);
switch(cmd) {
case 'test':
bot.sendMessage({
to: // channel id here,
message: 'If all went well this got sent in another channel'
});
break;
default:
bot.sendMessage({
to: channelID,
message: 'I wasn\'t able to understand this command, please try again...'
});
break;
}
}
});
Hopefully you can help me out. If there is something not clear for you, feel free to ask.
Thanks in advance.
So I found out why it didn't work, in the documentation it says channelID is Snowflake. What I didn't know is that this looks a lot like just a regular string. So when I tried to overide channelID by a string, it seemed to work. Like this:
bot.on('message', function (user, userID, channelID, message, evt) {
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0].toLowerCase();
args = args.splice(1);
switch(cmd) {
case 'test':
bot.sendMessage({
to: 'your channel id here',
message: 'If all went well this got sent in another channel'
});
break;
default:
bot.sendMessage({
to: channelID,
message: 'I wasn\'t able to understand this command, please try again...'
});
break;
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.