I have just created a simple bot with that code:
client.on('message', async message => {
if (!message.author.bot) {
if (!getClub(message) && (message.channel.id == channel_bot || message.channel.type != "dm")) { //
getRadio(message);
}
} else if (message.channel.id = channel_dev && message.author.bot) {
getDevCommands(message);
}
});
and I check bot command with
function getClub(msg) {
const args = msg.content.slice(msg.content.includes(config.prefix) ? config.prefix.length : 0).trim().split(/ +/g);
let isClub = false;
club_commands.forEach(function (element) {
if (element.id == "club" && element.commands.includes(args[0])) {
isClub = true;
}
});
if (!isClub) {
return false;
}
club_commands.forEach(function (element) {
// element is parsed object from JSON: {"id":"join", "commands":"join,attach,invite..."}
if (element.commands.includes(args[1])) {
switch (element.id) {
case "stats":
clubStats(msg);
return true;
case "join":
clubParticipation(msg, 1);
return true;
case "leave":
clubParticipation(msg, 0);
return true;
default:
// do nothing
break;
}
}
});
return false;
}
So in clubPartisipation() im getting in msg.channel.id - actual channel id but only "true" for the all next messages
function clubParticipation(msg, status) {
const args = msg.content.trim().split(/ +/g).splice(2, 2).join("");
if (args.length <= 3) {
msg.channel.send("test0");
} else {
let member = guild.members.get(msg.author.id);
if (status == "1") {
msg.channel.send("test1").catch(console.log);
} else {
msg.channel.send("test3").catch(console.log);
}
getHTTPResponce(config.server_url + 'add/club/participation?channel_id=' + msg.channel.id + '&status=' + status + '&user_id=' + member.id + '&club_id=' + Base64.encode(Base64.encode(args)) + '&token=' + config.server_token, msg)
.catch(console.log);
}
}
Error code is
{ DiscordAPIError: Invalid Form Body
channel_id: Value "true" is not snowflake.
at item.request.gen.end (/root/curatortojps/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
)
at then (/root/curatortojps/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
name: 'DiscordAPIError',
message: 'Invalid Form Body\nchannel_id: Value "true" is not snowflake.',
path: '/api/v7/channels/true/messages',
code: 50035,
method: 'POST' }