简体   繁体   English

我希望机器人只发送随机消息,但一条消息只发送一次

[英]I want a bot to send random messages only but one message only once

It Is Something Like This是这样的

I have these 5 messages我有这 5 条消息

hello1 hello2 hello3 hello4 hello5你好1 你好2 你好3 你好4 你好5

And I want to send a random message我想发送一条随机消息

like hello3像你好3

But It Could Be Sent Only Once但它只能发送一次

I mean At first it send hello3 And After hello3 Could Not Be Sent我的意思是一开始它发送 hello3 之后 hello3 无法发送

I know this is crazy我知道这很疯狂

its like this就像这样

hello3 sent hello3 发送

And Next Time hello5 sent But Next Time hello3 Could Not Be Sent下一次 hello5 已发送,但下一次 hello3 无法发送

I want to do this in discord.js v14我想在 discord.js v14 中执行此操作

Your post is kinda confusing, but if you wanted to send a random message, use an array.您的帖子有点令人困惑,但是如果您想发送随机消息,请使用数组。

let randomStrings = ["message1", "message2", "message3", "message4", "message5"];
let randomLength = randomStrings.length;
let RN = Math.floor(Math.random() * randomLength);
let sendRandomString = randomStrings[RN]

Here's the snippet:这是片段:

 let randomStrings = ["message1", "message2", "message3", "message4", "message5"]; let randomLength = randomStrings.length; let RN = Math.floor(Math.random() * randomLength); let sendRandomString = randomStrings[RN] console.log(sendRandomString)

Since you don't provide any code of yours.因为你没有提供你的任何代码。 This is only the code I can give as tips.这只是我可以作为提示提供的代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Discord Bot 发送多条消息,但我只希望它发送一条 - Discord Bot sends multiple messages but I only want it to send one 我希望机器人只发送第一条消息 - I want bot to send first message only 我的 Discord 机器人多次响应一个命令,我想知道是否有办法只发送一次 - My Discord bot reponds multiple time to one command and I want to know if there's a way to send it only once 想让机器人只向特定的人发送消息 - Want to make bot only send messages to a specific person 我希望我的机器人仅在用户直接发送消息时向用户发送直接消息 - I want my bot to send direct message to a user ONLY if the user's direct message 让discord bot只用一个命令发送许多消息 - Have a discord bot send many messages with only one command 如果第二条是黑色的,如何只发送一条消息,但如果我填写了两个变量,如何发送两条消息? - How do I send only one message if the second is black, but send two messages if I fill up both variables? 我希望我的不和谐机器人向用户提供的文本房间发送随机消息 [按频道 ID 或频道名称] - I want my discord bot to send a random message to a text room given by user [by channel id or channel name] 如何只向与我的电报机器人互动的每个用户发送一次消息 - How to send message only once to every individual user who has engaged with my telegram bot Firebase:Javascript在切换接收器时多次获取消息,而数据库中只有一条消息 - Firebase: Javascript fetches messages more than once when switching receivers , while there is only one message in the db
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM