After looking at several sites, including the official discord documentation, I had several options.
1 – json.
I’ve tried adding a slash command via the requests
library. But getting no error or result, I threw json
2- discord-py-slash-command
. similar result with json.
After the final failure, I went to stackoverflow
, and now I’m asking a question.
Codes:
Json –
import requests
url = 'https: //discord.com/api/v8/applications/#id_application/guilds/#guild_id/commands'
json = {
"name": "test",
"description": "Super test",
}
headers = {
"Authorization": "Bot # token"
}
r = requests.post (url, headers = headers, json = json)
discord-py-slash-command (IN COGS) –
import discord
from discord.ext import commands
from discord_slash import cog_ext, SlashContext
class Slash1 (commands.Cog):
def __init __ (self, bot: commands.Bot):
self.bot = bot
@ cog_ext.cog_slash (name = "ping")
async def ping (self, ctx: SlashContext):
await ctx.send (content = "Pong!")
def setup (bot: commands.Bot):
bot.add_cog (Slash1 (bot))
Answer 1
After updating the slash commands code, you need to wait some time, since the rate limit is triggered and you need to re-invite the bot to the server with slash commands already enabled, you can enable them on the website https://discord.com/developers/