简体   繁体   English

Discord.pycord 库,命令已同步两次

[英]Discord pycord librariy, Commands have synced twice

I have managed to sync my commands/cogs twice.我已经成功地同步了我的命令/齿轮两次。 here is my code (Error, Application command names must be unique)这是我的代码(错误,应用程序命令名称必须是唯一的)

<pre>import discord
import os
from dotenv import load_dotenv
from discord.ext import commands
from discord import slash_command

bot = commands.Bot(command_prefix='>', intents=discord.Intents.all(),debug_guilds=[964126154774679582,740616442034258002,965533467557371944], activity=discord.Activity(type=discord.ActivityType.watching, name='Over The Felbcord'))
load_dotenv()
directories = ["./commands", "./Embeds"]

for directory in directories:
   for filename in os.listdir(directory):
      if filename.endswith(".py"):
       bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
@bot.event
async def on_ready():
    print('Connected to bot: {}'.format(bot.user.name))

@bot.event
async def on_application_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.respond(error)
    else:
        raise error
@bot.event
async def on_message(message):
    if bot.user in message.mentions:
        Welcome=discord.Embed(title="Felbot",url="https://github.com/VividBlue1/Felbcord-Py/tree/discord",description="Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @ignfoolish#0396 - my creator \n Join Felbcord here! \n https://discord.gg/ab5cxuQu7E",color=discord.Color.blue())
        Welcome.set_author(name="FelBot", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="https://i.ibb.co/tz7VQJw/felb.jpg")
        await message.channel.send(embed=Welcome)
    await bot.process_commands(message)



bot.run(os.getenv("TOKEN"))<pre>

It does start but no commands work because of this它确实开始了,但没有命令因此而起作用

You didn't enabled the message content intent To enable go to discord developer portal and enable then come back to your code and do您没有启用消息内容意图启用 go 至discord 开发人员门户并启用然后返回您的代码并执行

intents = discord.Intents.all()
intents.message_content=True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM