gpt4 book ai didi

python - 如何更改discord.py 机器人的事件?

转载 作者:行者123 更新时间:2023-12-01 00:18:28 26 4
gpt4 key购买 nike

我想将机器人状态从播放更改为观看。我已经尝试过,但它仍然处于播放状态:

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio

PREFIX = ("$")
bot = commands.Bot(command_prefix=PREFIX, description='Hi')

@bot.event
async def on_ready():
activity = discord.Game(name="Netflix", type=3)
await bot.change_presence(status=discord.Status.idle, activity=activity)
print("Bot is ready!")

bot.run('TOKEN')

最佳答案

您可以使用以下代码行,具体取决于您要将机器人更改为哪个事件:

# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))

# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))

# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))

# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

引用:

bot.change_presence

关于python - 如何更改discord.py 机器人的事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59126137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com