Javascript Discord Bot 在输出中提及作者
Javascript Discord Bot mention author in output
我要:
我(维克):!投票
机器人:Veak 发起了投票
怎么样:
我(维克):!投票
机器人:undefined 开始投票
我使用的代码是'message.author + 'started a vote'
我试过 message.author.username 但我收到一条错误消息说我没有定义用户名。
代码:
bot.on('message', function (user, userID, channelID, message, evt) {
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!'
});
break;
case 'voting':
bot.sendMessage({
to: channelID,
message: ':ballot_box: **| ' + message.author + ' started a vote!**'
});
break;
}
}
});
当你使用discord.io
你想做的
bot.sendMessage({
to: channelID,
message: ':ballot_box: **| ' + user.username + ' started a vote!**'
});
我建议您切换到 discord.js
,因为 discord.io
老旧且无人维护
我要:
我(维克):!投票
机器人:Veak 发起了投票
怎么样:
我(维克):!投票
机器人:undefined 开始投票
我使用的代码是'message.author + 'started a vote'
我试过 message.author.username 但我收到一条错误消息说我没有定义用户名。
代码:
bot.on('message', function (user, userID, channelID, message, evt) {
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!'
});
break;
case 'voting':
bot.sendMessage({
to: channelID,
message: ':ballot_box: **| ' + message.author + ' started a vote!**'
});
break;
}
}
});
当你使用discord.io
你想做的
bot.sendMessage({
to: channelID,
message: ':ballot_box: **| ' + user.username + ' started a vote!**'
});
我建议您切换到 discord.js
,因为 discord.io
老旧且无人维护