由于某些原因,send_message在我的Discord机器人上运行不正常,我无论如何也无法找到它.
import asyncio
import discord
client = discord.Client()
@client.async_event
async def on_message(message):
author = message.author
if message.content.startswith('!test'):
print('on_message !test')
await test(author, message)
async def test(author, message):
print('in test function')
await client.send_message(message.channel, 'Hi %s, i heard you.' % author)
client.run("key")
Run Code Online (Sandbox Code Playgroud)
on_message !test
in test function
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\indit\AppData\Roaming\Python\Python36\site-packages\discord\client.py", line 223, in _run_event
yield from coro(*args, **kwargs)
File "bot.py", line 15, in on_message
await test(author, message)
File "bot.py", line 21, in test
await client.send_message(message.channel, …Run Code Online (Sandbox Code Playgroud) 在我的 Discord 服务器上,我有一个 #selfies 频道,人们可以在这里分享照片并讨论它们。时不时地,我想以某种方式修剪所有不包含文件/图像的消息。我试过检查文档,但我看不出有任何方法可以做到这一点。不可能吗?
我试图弄清楚如何从UserID中获取单个值并在控制台中将其打印出来。我当前的代码段始终返回“ None”,即使我正在搜索的UserID的Currency值也是如此。
cursor.execute("SELECT Currency FROM ServerUsers WHERE USERID = %s" % (userid))
if cursor.fetchone():
a = cursor.fetchone()
print(a)
Run Code Online (Sandbox Code Playgroud) 我在我的Discord机器人上添加了配置文件卡,因此用户可以在嵌入时选择他们想要的颜色,但每次我尝试使用discord.Colour变量时,都会出错.
color = '0x2897ff'
embed = discord.Embed(title="Profile", colour=discord.Colour(color))
Run Code Online (Sandbox Code Playgroud)
总是导致这个:
BAD REQUEST(状态代码:400)
然而,
embed = discord.Embed(title="Profile", colour=discord.Colour(0x2897ff))
Run Code Online (Sandbox Code Playgroud)
工作良好.但我需要能够以某种方式放置变量,以便我可以让用户更改其配置文件颜色.
任何帮助都意味着很多,谢谢.