【发布时间】:2021-01-31 23:49:16
【问题描述】:
每个命令都有单独的文件夹。我将它们连接到 main.js - 这是我的 GIF 文件夹。
module.exports = {
name: 'gif',
description: "this is a gif!",
execute(message, args){
if (message.content === "-gif") { // checks if the message says "?random"
const number = Math.random(); // generates a random number
message.channel.send(number.toString()); // sends a message to the channel with the number
}
}
}
现在它会生成随机数。我希望它生成随机 GIF(但我想通过链接添加它选择的所有随机 GIF)。
【问题讨论】:
-
我会制作一个 gif 链接数组(我不确定你从哪里得到它们,所以我不知道你是否可以自动构建数组)并使用数字来引用和索引在那个数组中。拥有数组后,使用 [int](math.random() * myArray.length) 获取相关索引。
-
我是从 tenor.com 获取的
-
我是制作不和谐机器人的新手。你能给我看一个示例代码吗?
标签: discord discord.js