【问题标题】:My ticketing system for a server is not running on_message(message)我的服务器票务系统未运行 on_message(message)
【发布时间】:2020-12-11 19:22:16
【问题描述】:
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.

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    试试这样的

    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')
    

    【讨论】:

      猜你喜欢
      • 2012-05-02
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      • 1970-01-01
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      • 2021-12-01
      相关资源
      最近更新 更多