I am new to JavaScript, I decided to start with discord.js to make my first projects, I was trying to make a spam command as a challenge, but this doesn't seem to work
client.on('message', msg => {
if (msg.content == 'spam') {
while (true) {
msg.channel.send('@everyone');
}
}
});
Nevermind, I fixed, if you're interested this is how I did it:
client.on("message", async (msg) => {
if (msg.content === "spam") {
while (true) {
await msg.channel.send("@everyone");
}
}
})
First things first you shouldn't do this, you're basically abusing the api and will end up getting rate limited
secondly, you need to await, keep in mind dont spam:D
cleint.on('message', async msg => {
let spam = false;
if (msg.content.toLowerCase() === 'spam') spam = true;
else if (msg.content.toLowerCase() === 'stop spam') spam = false;
while (spam == true)
await msg.channel.send('spamming is bad');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.