Глядя на документы Discord.io, не будет ли uploadFile
? Я могу ошибаться, так как я не использовал Discord.io, скорее я использую Discord.js, поэтому заранее прошу прощения. Как то так:
bot.uploadFile({
to: id,
file: FileBuffer
}).catch(console.error);
Вам также не нужно два прослушивателя сообщений. Вы можете иметь все в одном событии сообщения.
bot.on('message', (user, userID, channelID, message, evt) => {
if (user.bot) return; // prevents bots interacting with one another or itself.
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch (cmd) {
case 'ping':
bot.sendMessage({
to: channelID,
message: 'Pong'
}).catch(console.error);
break;
case 'img':
bot.uploadFile({
to: channelID,
file: FileBuffer
}).catch(console.error);
};
};
});
Дополнительное примечание: если поставить .catch()
в конце функции отправки, будут получены ошибки Promise.