const{SlashCommandBuilder}=require('discord.js');constwait=require('node:timers/promises').setTimeout;// 注意这里!!!module.exports={data:newSlashCommandBuilder().setName('ping4').setDescription('Replies with Pong, but deferred!'),asyncexecute(interaction){// 延迟回复,此时会有个初始回复“应用...
代码commands/subCmd.js: const{SlashCommandBuilder}=require('discord.js');module.exports={data:newSlashCommandBuilder().setName('subcmd').setDescription('Subcommand! Reply with user\'s or server \'s info.').addSubcommand(subcommand=>subcommand.setName('user').setDescription('Info about a user...
commandFiles[i] = fs.readdirSync(cmdPaths[i]).filter(file => file.endsWith(".js")); // fs.readdirSync() 的结果是个数组,所以 commandFiles是个二维数组 for (let j = 0; j < commandFiles[i].length; j++) { commandFiles[i][j] = cmdPaths[i] + "/" + commandFiles[i][j]; } }...
const{SlashCommandBuilder}=require('@discordjs/builders');const{REST}=require('@discordjs/rest');const{Routes}=require('discord-api-types/v9');const{token,pasteUser,pastePass,pasteKey}=require('../config.json');constpaste=require('better-pastebin');constrest=newREST({version:'9'}).setToke...
我也认为@user16 16…方法更简单,但是当您使用SlashCommandBuilder时,您不需要在定义时使用builders子...
const{SlashCommandBuilder}=require('discord.js');module.exports={data:newSlashCommandBuilder().setName('quote').setDescription('获取今天的励志名言'),asyncexecute(interaction){constquotes=["千里之行,始于足下。","机会总是垂青于那些有准备的人。","成功并非终点,勇气才是继续前行的力量。",];constra...
import type { SlashCommandProps, CommandOptions } from 'commandkit'; import { SlashCommandBuilder } from "discord.js" export const data = new SlashCommandBuilder() .setName("reload") .setDescription("Reload the command handler") export async function run({ interaction, client, handler }: Sla...
data: new SlashCommandBuilder() .setName('embedattachment') .setDescription('Replies with embed!'), async execute(interaction) { // 这里的工作目录 “./” 是 "discord_bot_example" const dogeCoffee = new AttachmentBuilder('assets/dogeCoffee.jpg'); ...
Slash Command: import{Command,Client,InteractionCommand}from"discord.js-ext-command";import{CommandInteraction,GatewayIntentBits,SlashCommandBuilder}from"discord.js";constclient=newDiscordCommands({prefix:"!"},{intents:[GatewayIntentBits.Guilds]});client.login("token");@CommandclassHelloWorldCommandimpleme...
Have a bot with the following slash command configured: new SlashCommandBuilder() .setName('monitor_node') .setDescription('Register a new validator node to monitor') .addStringOption(option => option.setName('id') .setDescription('The Node ID to monitor') .setRequired(true) .setMaxLength...