最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Discord.js - How to spam messages in a text channel? - Stack Overflow

programmeradmin5浏览0评论

I'm trying to make a discord bot and my client wants me to have a mand that spams something into a text channel.

I have tried using a for loop on its own and a while loop with a for loop as seen below:

With for and while loop:

    case "mand":
    for(var i = 0; i >=20; i++){
        while(i <20){
            message.channel.send("spam");
        }
    }
    break;

With for loop:

case "mand":
for(var i = 0; i >=20; i++){
        message.channel.send("spam");
}
break;

When I place a message.channel.send outside of the loop, then it shows up once.

Any help would be greatly appreciated, thanks.

I'm trying to make a discord bot and my client wants me to have a mand that spams something into a text channel.

I have tried using a for loop on its own and a while loop with a for loop as seen below:

With for and while loop:

    case "mand":
    for(var i = 0; i >=20; i++){
        while(i <20){
            message.channel.send("spam");
        }
    }
    break;

With for loop:

case "mand":
for(var i = 0; i >=20; i++){
        message.channel.send("spam");
}
break;

When I place a message.channel.send outside of the loop, then it shows up once.

Any help would be greatly appreciated, thanks.

Share Improve this question edited Dec 2, 2017 at 11:20 André Dion 21.8k7 gold badges58 silver badges60 bronze badges asked Dec 2, 2017 at 11:06 Ryan SRyan S 1292 gold badges4 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Neither loop will execute because i starts at 0 and your loop condition states i >= 20; i++...

Fix your logic so that it makes sense:

case "mand":
    for (var i = 0; i < 20; i++) {
        message.channel.send("spam");
    }
    break;
发布评论

评论列表(0)

  1. 暂无评论