python - 我的服务器票务系统未运行 on_message(message)
问题描述
import discord
client = discord.Client()
@client.event
async def on_ready():
print('ALERT: {0.user} has connected and is now ready for use.'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('$request-whitelisting'):
print("1")
x = author.has_permissions(administrator)
print(author)
if x == False:
print("2")
await message.channel.send("OK, I am now alerting the admins who can approve your request.")
channel = bot.getchannel(784863111579435019)
idiot = message.author()
await message.channel.send("Alert: "+idiot+" has requested whitelist.")
client.run('Token')
这就是代码 - 它不起作用,我试图让它只这样做然后运行机器人并且它拒绝,我尝试移动东西,使用 print() 标记问题,但最后,函数不是正在运行。我从 shell 中得到的只是启动消息:
ALERT: Bot#NumID has connected and is now ready for use.
解决方案
尝试这样的事情
import discord
intents = Intents.default()
intents.members = True
client = discord.Client(intents = intents)
@client.event
async def on_ready():
print('ALERT: {0.user} has connected and is now ready for use.'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('$request-whitelisting'):
print("1")
x = author.has_permissions(administrator)
print(author)
if x == False:
print("2")
await message.channel.send("OK, I am now alerting the admins who can approve your request.")
channel = bot.getchannel(784863111579435019)
idiot = message.author()
await message.channel.send("Alert: "+idiot+" has requested whitelist.")
client.run('Token')
推荐阅读
- keras - ValueError: ('session_kwargs 中的某些键目前不支持:%s', dict_keys(['class_mode'])
- kubernetes - 如何需要为 traefik 注释入口以生成letsencrypt证书
- angular - ExpressionChangedAfterItHasBeenCheckedError,有条件地设置元素属性时
- angular6 - 我们可以通过从服务中的 http 调用中获取值来动态地将 APP_BASE_HREF 设置为 Angular 6 吗?
- mule - 从 json 中排除一些已经映射到其中的键值
- regex - 正则表达式从不带空格的括号中获取名称
- amazon-web-services - Lambda 读取 DynamoDB 并发送到 ML Endpoint
- flexbox - 我可以改变 Bootstrap 放置列的方式吗?
- python - How to convert aggregates in pandas into string?
- android - 使用文件传输插件从科尔多瓦的 s3 服务器下载图像文件