status = None
@client.command()
async def setstatus(ctx, variable):
global status
print("Before", variable)
status = variable
await client.change_presence(activity=discord.Game(next(status)))
await ctx.send(status)
以上是我目前拥有的代码,但无法正常工作。
错误: “等待 client.change_presence(activity=discord.Game(next(status))) 类型错误:'str' 对象不是迭代器"
目标是使用 !setstatus 更改机器人的存在文本。
请帮忙。
答案 0 :(得分:0)
此错误告诉您 status
是一个字符串,而不是可以迭代的列表。
更改这一行:
await client.change_presence(activity=discord.Game(next(status)))
到:
await client.change_presence(activity=discord.Game(status))
答案 1 :(得分:0)
await client.change_presence(activity=discord.Game(name="status"))
await client.change_presence(activity=discord.Streaming(name="My Stream", url="stream url"))
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="song"))
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a video"))
答案 2 :(得分:0)
看看how to change discord.py bot activity
# 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"))