久久久久久久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?)
主站蜘蛛池模板: 欧美综合一区二区三区 | 综合网视频 | 国产人免费人成免费视频 | 国产精品久久国产精品 | 久久男女视频 | 在线一级片 | 久久久人 | 亚洲精品4| 国产精品久久久久不卡 | 国产99视频精品免费视频7 | 国产在线视频一区二区董小宛性色 | 免费看片在线播放 | 久久综合成人精品亚洲另类欧美 | 日一区二区三区 | 亚洲精品白浆高清久久久久久 | www.色综合| 亚洲网站免费看 | 欧美黄在线观看 | 精品国产乱码久久久久久丨区2区 | 欧美成人a| 亚洲美乳中文字幕 | 日韩一区二区福利视频 | 国产成人a亚洲精品 | 日本视频在线播放 | 黄a网站 | 国产一区二区三区色淫影院 | 中文字幕二区 | 国产综合网站 | 亚州精品天堂中文字幕 | 久久午夜精品福利一区二区 | 99亚洲视频 | 久久亚洲经典 | 91久久爽久久爽爽久久片 | 成人性生交大片免费看中文带字幕 | 99re在线视频观看 | www.亚洲一区 | 色视频www在线播放国产人成 | 亚洲精品一区中文字幕乱码 | 亚洲激情第一页 | 五月综合久久 | 日韩在线一区二区 |