【发布时间】:2018-08-05 09:06:20
【问题描述】:
这是目前我的 bot.js
var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with `!`
if (message.substring(0, 1) == ';') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
console.info(cmd);
switch(cmd) {
// !ping
case 'killerbean':
// bot.sendFile({
// to: channelID,
// files: ['./emojis/killerbean.png']
// });
logger.info(bot.channels);
User.sendFile('./emojis/killerbean.png');
//bot.channels[0].send('', new Discord.Attachment( './emojis/killerbean.png'));
break;
// Just add any case commands if you want to..
}
}
});
注释的代码是我尝试过的一些没有用的东西。 bot.sendFile 显然不是一种方法。我目前正在考虑使用 User.send,但我不知道如何使用它。
当有人输入命令';killerbean'时,我该如何发送图像
编辑:抛出 package.json 以防依赖关系或其他任何问题
{
"name": "emoji-bot",
"version": "1.0",
"description": "Emojis+",
"main": "bot.js",
"author": "Joshua",
"dependencies": {
"discord-irc": "^2.5.1",
"discord.io": "github:woor/discord.io#gateway_v6",
"winston": "^2.4.0"
}
}
emoji-bot 用户也称为 emoji-bot。
【问题讨论】:
标签: javascript discord discord.io