Reputation: 11
I cant figure out how to fix this
members = 0
o = "o"
for guild in client.guilds:
members += guild.member_count
statusmessages = [
"Made with ❤️ by epdev",
"Watching over the epdev server",
f"Helping {members} members!",
]
status = random.choice(statusmessages)
# Random status messages
async def randomstatus():
while o == "o":
await asyncio.sleep(10)
status = random.choice(statusmessages)
# Events
@bot.event
async def on_ready():
print('Main Bot Status: Running')
await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game(name=status))
I expected it to change the status every 10seconds. It is just making it a random status once and not changing it
Upvotes: 0
Views: 289
Reputation: 353
The reason why it's not changing is because randomstatus is never getting called. Also, there's a better way to call something every 10 seconds. You can use Pycord's tasks
library. For example, your code would be
from discord.ext import tasks
members = 0
o = "o"
for guild in client.guilds:
members += guild.member_count
statusmessages = [
"Made with ❤️ by epdev",
"Watching over the epdev server",
f"Helping {members} members!",
]
# status = random.choice(statusmessages)
# Random status messages
@tasks.loop(seconds=10)
async def randomstatus():
status = random.choice(statusmessages)
await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game(name=status))
# Events
@bot.event
async def on_ready():
print('Main Bot Status: Running')
# await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game(name=status))
randomstatus.start()
Upvotes: 1