当前位置: 首页 > 知识库问答 >
问题:

不和谐中的自我机器人。找不到py rewrite命令

蒲昊
2023-03-14

我试图在重写discord.py不和谐的自我机器人,它给了我这个错误:

忽略命令None中的异常不协调。外部命令。错误。CommandNotFound:未找到命令“me”

这是我的代码:

from discord.ext import commands

selfbot = commands.Bot(command_prefix = "<.", self_bot = True)

selfbot.event
async def on_ready():
    print(f'IDK Running on: {selfbot.user}')

selfbot.command()
async def test(ctx):
    await ctx.send('Off.')

selfbot.command()
async def me(ctx):
    ctx.send(f'You are {selfbot.user}')

token = 'token here'
selfbot.run(token, bot = False)```

共有1个答案

卫烨烁
2023-03-14

您缺少@。应该是

from discord.ext import commands

selfbot = commands.Bot(command_prefix = "<.", self_bot = True)

@selfbot.event
async def on_ready():
    print(f'IDK Running on: {selfbot.user}')

@selfbot.command()
async def test(ctx):
    await ctx.send('Off.')

@selfbot.command()
async def me(ctx):
    ctx.send(f'You are {selfbot.user}')

token = 'token here'
selfbot.run(token, bot = False)

注意:您缺少命令装饰器的主要功能,@,没有它,您的命令将不会注册为命令或事件

 类似资料:
  • 我已经创建了一个bot,它现在在我的discord服务器中,使用下面的代码。 我的问题是,一旦我在与bot不和谐的聊天中,我如何调用命令让bot运行代码,为用户列表收集csv?我不确定如何调用机器人,一旦它在聊天/服务器中获得列表。

  • 我开始写一个Discord机器人,但我已经设法遇到了一个问题。我只是写了他写的东西,做了一些小改动,不会对程序产生太大影响。我有两个类,主类只获取bot的令牌,然后使用 下面是MyBot.cs: 它可以连接,机器人也可以在线。这是我的控制台中的输出: 当我现在打字的时候。一般来说,什么都不会发生。控制台中没有,一般情况下也没有。我已经看过了,但它并没有解决我的问题 编辑:我知道我应该使用Comma

  • 我们正在创建一个不和谐机器人。 问题是控制台中没有错误,但不和谐聊天也是空的。所以完全没有回应。你能帮我说说我的错误是什么以及如何解决这个问题吗 祝你一切顺利,尼克斯

  • 我使用repl。它让我的不和机器人。我使用Python并遵循本教程: https://www.youtube.com/watch?v=SPTfmiYiuok 这是我的代码:

  • 我试图让我的自我机器人加入服务器。我知道self-bots反对discordtos,但我想学习一些新的东西。 这是我尝试过的命令: 错误:

  • 当我在discord内部运行以下脚本(“cmd中的node musicbot.js”)和“!play ytlink”时,bot加入语音通道,并在控制台中记录命令和链接。然而,音乐并没有开始播放。我安装了ffmpeg、ytdl核心和discord。js。 有人能帮我吗?我不知道是哪一部分搞砸了。