簡體   English   中英

Discord.JS - 我收到“應用程序沒有響應”但控制台中沒有錯誤

[英]Discord.JS - I am getting 'Application did not respond' but no errors in console

因此,我在控制台中沒有使用此代碼收到任何錯誤,但它在 discord 中導致錯誤,它只是說“應用程序沒有響應”。 我只是想知道我是否做錯了什么。 我已經嘗試按照 Discord.JS 官方文檔/指南來做到這一點。

這一切都在命令處理程序中。

我想要的結果提及郵件的作者

  const { Client, SlashCommandBuilder, GatewayIntentBits } = require('discord.js');
    const client = new Client({ intents: [GatewayIntentBits.Guilds] });
    
    module.exports = {
        data: new SlashCommandBuilder()
            .setName('cleanthedecks')
            .setDescription('Tells a user to clean the decks'),
        async execute(interaction) {
            client.on('message', (message) => {
                const user = message.author;
                await interaction.reply(`${user} Get the decks cleaned immediately with /deckscrub`);
                console.log(user);
            })
        }
    }

好的,我想通了。 我可以只使用“交互” class 來獲取用戶以及用戶名。

所以我的工作代碼是

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('cleanthedecks')
        .setDescription('Tells a user to clean the decks'),
    async execute(interaction) {
        const user = interaction.user.username;
        await interaction.reply(`${user} Get the decks cleaned immediately with /deckscrub`);
        console.log(user);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM