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

新的 Discord 斜線命令

New Discord Slash Commands(新的 Discord 斜線命令)
本文介紹了新的 Discord 斜線命令的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

最近,discord 為您自己的應用程序添加了對斜杠命令的支持.我通讀了它的文檔,并嘗試搜索一些視頻(但是該功能剛剛出現),但我不明白我實際上需要做什么才能使其正常工作.我正在使用 WebStorm(js,node.js).有沒有人成功發出過斜線命令,如果有,如何?

Recently, discord added support for slash commands for your own application. I read through the documentation for it, and I've tried to search for some videos (however the feature did JUST come out) but I do not understand what I actually have to do to get it working. I am using WebStorm (js, node.js). Has anyone successfully made a slash command, and if so, how?

文檔

推薦答案

您可以使用常規的 discord.js,現在它的 v12.5.1.

You can use the regular discord.js, by now its v12.5.1.

這只是一個示例,但對我有用.

This is just a sample, but worked for me.

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
    client.api.applications(client.user.id).guilds(YOUR_GUILD_ID_HERE).commands.post({
        data: {
            name: "hello",
            description: "hello world command"
            // possible options here e.g. options: [{...}]
        }
    });


    client.ws.on('INTERACTION_CREATE', async interaction => {
        const command = interaction.data.name.toLowerCase();
        const args = interaction.data.options;

        if (command === 'hello'){ 
            // here you could do anything. in this sample
            // i reply with an api interaction
            client.api.interactions(interaction.id, interaction.token).callback.post({
                data: {
                    type: 4,
                    data: {
                        content: "hello world!!!"
                    }
                }
            })
        }
    });
});

client.login(token);

當然你可以有選擇,見文檔...

Of course you can have options, see documentation...

IDE 不會注冊新代碼...至少我的 phpstorm 目前沒有 :)

IDE won't register the new code...at least my php storm currently does'nt :)

但是,給予機器人正確的權限以使用這種類型的命令很重要!

However, its important to give the bot the correct permissions to use this type of command!

所以轉到 Discord.com/developers,選擇您的應用程序,轉到 OAuth2 并選擇

So go to Discord.com/developers, select your application, go to OAuth2 and select

application.commands

application.commands

來自范圍部分.這應該在中間列的底部.您還應該選擇 bot 并在 Bot Permissions 下設置一些其他特定權限.然后使用新的邀請鏈接重新邀請機器人.

from the scope section. This should be at the bottom of the middle column. You should select bot as well and under Bot Permissionsyou set some other specific permissions. Then use that new invite link to reinvite the bot.

如果沒有 application.commands 權限,該命令將不起作用,您將收到一些錯誤,如 Missing Access 或類似的.

Without application.commands permission, the command won't work and you will receive some error like Missing Access or some similar.

重要事項

  1. 使用 .guilds('11231...').comma 來測試這些命令.不使用它時,大約需要 1 小時才能激活.使用它會立即激活它.

  1. Use .guilds('11231...').comma to test these commands. When not using this, it takes round about 1h to get active. Using it will activate it immediately.

給機器人正確的權限.application.commands

這篇關于新的 Discord 斜線命令的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應)
Check if user ID exists in Discord server(檢查 Discord 服務器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 青青草精品视频 | www.色偷偷| 国产91页 | 亚洲精品福利 | 黄色av观看 | 日本高清视频www | 亚洲一区二区久久 | 国产精品一区av | 国产精品久久久久久久久久久久久 | 国产精品成人国产乱 | 玖草视频 | 一区二区三区国产视频 | 国产福利在线播放 | 九九九视频 | 欧美激情视频一区 | 久久久久亚洲精品 | 欧洲黄色网 | 999精品视频| 成年在线观看 | 精品国产区一区二 | 久久天天 | 91精品国产一区二区三区 | 中文一级片| 国产乱码一区二区 | 亚洲一级免费视频 | 亚洲成人免费在线 | 中文在线观看免费网站 | 欧美成人毛片 | www.日本在线观看 | 国产精品久久久久久久久久久久久久久 | 日韩在线精品视频 | 中文字幕在线看片 | 三级视频在线 | 一区两区小视频 | 欧美日韩国产中文字幕 | www.色日本| 小镇姑娘国语版在线观看免费 | 一区两区小视频 | 欧美黄色一级大片 | 欧美aaaaa | 免费看黄网 |