discord.py的斜杠命令引发了一个异常,指出用户名不能包含“discord”。

huangapple go评论67阅读模式
英文:

discord.py slash commands raise an exception that username cannot contain "discord"

问题

当我使用斜杠命令时,出现了一个异常,指出用户名不能包含“discord”,尽管机器人和用户的名字中都没有包含“discord”。

异常信息如下:

discord.app_commands.errors.CommandInvokeError: Command 'ping' raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In name: Username cannot contain "discord"

我尝试过使用不同的机器人名称和用户名,也尝试过使用discord.ext.commands.Bot,但都返回了相同的异常。

英文:

When I use slash commands I get an exception that Username cant contain "discord" even though neither the bot nor the user have "discord" in their names

import os
import discord
from dotenv import load_dotenv
from discord import app_commands

load_dotenv()

token = os.getenv('TOKEN')

intents = discord.Intents.all()

client = discord.Client(intents=intents)

tree = app_commands.CommandTree(client)

@client.event
async def on_ready():
    await tree.sync(guild=discord.Object(id=1128263298152927294))
    print('Command tree synced.')

@tree.command(description="Sends the bot's latency.",name='ping',guild=discord.Object(1128263298152927294))
async def ping(ctx):
    await ctx.response.send_message("Hello!")

client.run(token)

Exception is:

discord.app_commands.errors.CommandInvokeError: Command 'ping' raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In name: Username cannot contain "discord"

Ive tried using different bots/names and different users. Ive also tried using discord.ext.commands.Bot and it also returned the same exception

答案1

得分: 0

错误发生是因为您在Discord开发者门户中将您的应用程序命名为Discord,无论是作为用户名(/bot)还是应用程序名称(/information)。

只需重新命名其中一个即可解决错误!在此处了解更多信息。

英文:

The error occurs because you named your application Discord either as the username (/bot) or name of the application name (/information) in the Discord Developer Portal.

Simply renaming one of them will resolve the error! Read more about it here

huangapple
  • 本文由 发表于 2023年7月13日 18:23:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678323.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定