久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么別名沒有被執行?

why are aliases not getting executed?(為什么別名沒有被執行?)
本文介紹了為什么別名沒有被執行?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

您好,我在 discord.js 中遇到了別名問題,別名不起作用,我不知道為什么?

Hello, I'm having an issue with aliases in discord.js the aliases don't work, I don't know why?

client.on('message', message =>{
    // Exit when the message from the bot
    if (!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).trim().split(/ +/);
    const commandName = args.shift().toLowerCase();

    if (!client.commands.has(commandName)) return;

    const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));

    try {
        command.execute(message, args, commandName, client, Discord);
    } catch (error) {
        console.error(error);
        message.reply('there was an error trying to execute that command!');
    }
});

推薦答案

不能使用別名,因為你放了

You can’t use aliases because you put

if(!client.commands.has(commandName)) return;

如果您嘗試使用別名或其他任何不在您的 client.commands 鍵中的東西,這將返回 false.刪除此行并改用此行:

This returns false if you try an alias, or anything else that isn’t in your client.commands keys. Remove this line and use this instead:

const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases?.includes(commandName));
if(!command) return;
//...

這會查找命令首先,然后如果沒有找到命令、名稱或別名,則返回

This looks for the command first and then if no command is found, name or alias, it returns

這篇關于為什么別名沒有被執行?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 欧美一区二区三区久久精品视 | 羞视频在线观看 | 一区二区在线免费观看视频 | 激情婷婷 | 久久一区二区三区四区 | 日韩1区2区 | 国产日韩久久久久69影院 | 特a毛片| 国产欧美精品区一区二区三区 | 精品毛片| 国产一区影院 | 亚洲免费视频网址 | 欧美在线一区二区三区 | 免费精品视频在线观看 | 欧美日韩成人在线 | 日韩国产一区二区三区 | 免费av在线网站 | 成人av鲁丝片一区二区小说 | 午夜男人天堂 | 成年人视频免费在线观看 | 成人国产精品久久 | 福利视频一区二区 | 精品九九 | 一级欧美黄色片 | 中文字幕一区二区三区四区五区 | 精品视频久久久 | 中文字幕精品一区 | 日本三级精品 | 国产精品夜夜夜一区二区三区尤 | 日本a v在线播放 | 午夜av毛片| 日韩在线小视频 | 免费性视频 | 久久一二| 欧美色a v| 日韩福利 | 欧美精品一区二区三区在线 | 日韩在线观看网站 | 久久久精品一区 | 三级在线免费观看 | 久久久国产一区二区三区四区小说 |