if(command === '示例'){
client.commands.get('exaple').execute(message, args);
message.channel.send('https://i.redd.it/6nkyme7ayi631.jpg');
module.exports = {
name: 'example',
description: "this is a test command",
execute(message, args, Discord){
message.channel.send('https://i.redd.it/6nkyme7ayi631.jpg');
}
}
答案 0 :(得分:0)
创建一个图像 URL 数组,然后从数组中随机选择一个项目发送
// Example using numbers
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
// module.exports etc
const randomNumber = numbers[Math.floor(Math.random() * numbers.length)]
// send the random number/url
// I'm using console.log() to avoid an error
console.log(randomNumber)
// implementation
// assuming you're using separate files for each command
// and using the code snippet you gave
module.exports = {
name: 'number',
description: "picks a random number",
execute(message, args, Discord){
// change this to your URLs
numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
// change the variable names if you want
const randomNumber = numbers[Math.floor(Math.random() * numbers.length)]
// send the chosen item
message.channel.send(randomNumber)
}
}