【发布时间】:2021-08-21 19:52:24
【问题描述】:
(忽略愚蠢的消息回复,内部笑话) - 我想知道为什么我的硬币翻转不起作用。我得到了第一个消息功能可以正常工作,没有任何问题,但是硬币翻转一个根本不起作用。 (我已经包含了几乎所有经过审查的完整代码)这是在 VSC 中使用 JS、Node 和 Discord.js。
console.log('gamercum');
const Discord = require('discord.js');
const client = new Discord.Client();
client.login('ODUwMDI5MjUxMzIyNTc2OTI0.YLjxbg.EZBRMra3o8Srs4gBCwLz_1NQgTU');
client.on('ready', readyDiscord);
function readyDiscord() {
console.log('boolin');
}
function coinFlip() {
var flip = Math.floor(Math.random());
if(flip = 1) {
msg.reply('heads');
} else {
msg.reply('tails');
}
}
client.on('message', gotMessage);
function gotMessage(msg) {
console.log(msg.content);
if(msg.content === 'gamercum' || msg.content === 'Gamercum' || msg.content === 'gamer cum'
|| msg.content === 'Gamer cum') {
msg.reply('we pimp chimpin');
}
}
client.on('message', getMessage);
function getMessage(msg) {
console.log(msg.content);
if(msg.content === 'coinflip') {
coinFlip();
}
}
【问题讨论】:
-
我对 javascript 不太熟悉,但你说 if (flip = 1) 但不应该是 if(flip == 1) 吗?
-
定义“不工作”
标签: javascript discord discord.js