Continuous nickname change with Discord bot

Hey everyone! I’m trying to make a Discord bot that keeps changing a friend’s nickname over and over. But I can’t get it to work right. I’ve looked everywhere for help but no luck.

Here’s what I’ve tried so far:

@MyBot.command()
async def change_nick_forever(ctx, user: discord.Member, new_nick):
    await ctx.message.delete()
    while True:
        await user.edit(nick=new_nick)
        await asyncio.sleep(5)

The problem is when I try to use another command it stops the loop. Any ideas how to keep it going? I’m pretty new to this so any help would be awesome. Thanks!

While I understand the desire to create something amusing, constantly changing nicknames can be disruptive and potentially violate Discord’s terms of service. It’s best to avoid actions that could spam or harass users, even unintentionally.

Instead, consider implementing a nickname change feature that’s triggered by specific events or user interactions. This could be more engaging and less likely to cause issues. For example, you could create a command that allows users to temporarily change their own nicknames or have the bot assign themed nicknames for special occasions.

If you’re set on frequent changes, implement a cooldown system to limit how often the nickname can be modified. This approach would be more respectful to users and less likely to overload Discord’s API. Remember, the key is to enhance the server experience, not potentially detract from it.

As someone who’s messed around with Discord bots quite a bit, I can tell you that continuously changing nicknames isn’t a great idea. It can really annoy users and potentially get your bot in trouble.

Instead, why not try something more fun and less disruptive? You could create a command that changes the nickname to a random choice from a predefined list, or have it change based on certain events or time of day.

If you really want to keep the nickname changing, consider using a separate thread or task for it, so it doesn’t block other commands. But honestly, I’d advise against it. There are much cooler things you can do with a Discord bot that won’t irritate your server members.

Remember, the goal of a bot should be to enhance the Discord experience, not make it frustrating for users. Maybe brainstorm some other ideas that could be both fun and useful?