提醒所有人,请勿在您的机器人或客户端中的 on_ready 中更改_presence(或进行 API 调用)。
Discord 很有可能在 READY 或 GUILD_CREATE 事件(1006 或 1000 关闭代码)期间完全断开您的连接,并且您无能为力。
相反,在这些类的构造函数中设置 activity
和 status
kwargs。
播放 ->
活动 = discord.Game(name="!help")
流媒体 ->
活动 = discord.Streaming(name="!help",url="twitch_url_here")
听力 ->
活动 = discord.Activity(type=discord.ActivityType.listening,name="!help")
观看 ->
活动 = discord.Activity(type=discord.ActivityType.watching,name="!help")
bot = commands.Bot(command_prefix="!",activity=activity,status=discord.Status.idle)
基本上:不要在 on_ready 中做事。
,
您可以使用此Ezz!
# 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"))
,
根据this issue,Client.change_presence中的游戏关键字参数已重命名为activity,因此您的代码应类似于
activity = discord.Game(name="Just")
await client.change_presence(status=discord.Status.idle,activity=activity)
,
尽管否自定义状态
,该漫游器仍可以是
Playing X
或
Streaming Y
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.change_presence
,
history.push(localhost:3000/invite/leadueid-1
,
只需使用:
@client.event
async def on_ready():
await client.change_presence(activity=discord.Streaming(name='Fortnite',url='https://www.twitch.tv/UR_TWITCH_GOES_HERE You cant do YT only Twitch.'))
print("Bot is connected to all of the available servers in the bots mainframe.")
对于流媒体,但对于其他人,我无能为力。
,
如果你想要正常的存在,那么这样做:
await bot.change_presence(activity=discord.Streaming(name="My Stream",url=my_twitch_url))
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening,name="a song"))
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching,name="a movie"))```
#but if you want to make the bot change status every 5 minutes try this :
async def ch_pr():
await client.wait_until_ready()
statuses = ["Vodka Or beer? || bb:help",f"listening on {len(client.guilds)} server's","Still need help? do bb:guide for more help!"]
while not client.is_closed():
status = random.choice(statuses)
await client.change_presence(activity=discord.Game(name=status))
await asyncio.sleep(5)
client.loop.create_task(ch_pr())
本文链接:https://www.f2er.com/2998710.html