13得票4回答
如何在discord.py中使命令不区分大小写

如何使命令不区分大小写,而不需要添加多个不同大小写的别名,例如:@bot.command(pass_context = True, name = 'test', aliases=['Test', 'tEst', 'teSt', 'tesT', 'TEst', 'TeSt', 'TesT', '...

13得票7回答
Discord.py的颜色代码

我发现在discord.py中更改颜色有点困难和烦人(比如嵌入的颜色)。因此,我创建了一个类来处理discord.py中使用的不同颜色代码,并可以将其导入到主文件中。class colors: default = 0 teal = 0x1abc9c dark_teal ...

13得票4回答
如何使discord.py的意图(intents)起作用?

我正在尝试创建一个机器人,欢迎来到它所在的服务器的人,除了on_member_join事件之外,所有代码都可以工作。因为它使用了新的意图(intents),所以这部分无法正常工作。我搜索了如何使用意图的方法并尝试了一切,但还是不能正常工作。intents = discord.Intents.d...

12得票4回答
如何使用discord.py在没有命令的情况下发送消息

import discord import asyncio client = discord.Client() @client.event async def on_ready(): print("I'm ready.") async def send(mess...

12得票3回答
Python asyncio - 循环退出并显示“Task was destroyed but it is pending”错误信息

这是我Python程序的相关代码:import discord import asyncio class Bot(discord.Client): def __init__(self): super().__init__() @asyncio.corouti...

12得票3回答
我想让我的Discord机器人发送图片/动态图。

我一直在尝试找到能够工作的代码,但是无论我找了多少代码,要么命令不能加载(它会显示机器人正在输入,然后停止),要么机器人本身就无法工作。我正在使用Python。

11得票2回答
Discord机器人只能看到自己,而不能看到公会中的其他用户

最近我一直在关注这个教程,以便开始使用Discord的API。不幸的是,在我遇到要打印公会中所有用户时,我卡住了。 当我尝试打印所有用户的名称时,它只打印机器人的名称,没有其他内容。参考一下,该公会共有六个用户。机器人具有管理员权限。import os import discord TOKE...

11得票3回答
获取所有成员 discord.py

我有一个问题,需要获取所有服务器的在线机器人成员列表(我正在使用discord.py重写版)。目前我有以下代码片段:@bot.command() async def members(ctx): for guild in bot.guilds: for member in...

11得票3回答
如何在非异步函数中使用Await?

我正在开发一个Discord机器人并试图解决这个问题。我想知道如何在非异步函数中使用"await" 或者 是否可以在代码的最后一行lambda表达式中等待一个函数。 我尝试过对player变量使用asyncio.run,也尝试过asyncio.run_coroutine_threadsafe...

11得票3回答
属性错误:'Client'对象没有属性'send_message'(Discord机器人)

由于某些原因,我的Discord机器人上的send_message功能无法正常工作,我找不到任何方法来修复它。import asyncio import discord client = discord.Client() @client.async_event async def on_m...