【问题标题】:Discord.py set status (client)Discord.py 设置状态(客户端)
【发布时间】:2021-04-20 14:45:37
【问题描述】:

您好, 我如何为机器人设置状态?

import discord
import os
import asyncio
from keep_alive import keep_alive
from discord.ext import commands

client = discord.Client()

(我不想更改为 bot.event,因为我有 RolePlay bot 并且使用 bot.event 并且 bot 正在发送垃圾邮件。帮助我如何使用 client.event 设置状态。)

【问题讨论】:

    标签: python discord


    【解决方案1】:

    如果你想使用client,应该是这样的:

    import discord
    
    client = discord.Client()
    
    @client.event
    async def on_ready():
        print('We have logged in as {0.user}'.format(client))
        await client.change_presence(activity=discord.Game(name="a game"))    # Here we change it
    
    @client.event
    async def on_message(message):
        # Your code
    
    client.run('your token here')
    

    【讨论】:

    • 如果对您有帮助,记得将答案标记为已接受。
    猜你喜欢
    • 2019-06-18
    • 2013-04-05
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    • 2012-03-18
    • 2013-01-13
    相关资源
    最近更新 更多