Search code examples
pythondiscord.pydiscord

discord.py, Cogs: How Would I assign a nickname on join?


The title says the gist of what I'm asking.

I'm trying to make an on_member_join event that will assign a nickname to new users. It's not giving me any output other than the standard new user joining. It's in a cog.

Any and all help would be appreciated! I've scoured the internet and can't seem to find an answer for this.

Note: I've been coding off-and-on with python and d.py since 2020, self-taught. I'm decently advanced in it, so don't worry if the answer is complex.

I've tried the following code:

    @commands.Cog.listener()
    async def on_member_join(self, member):
      await member.edit(nick="[G-P]" + member.name)

But it doesn't work. No erros are shown in the console either.


Solution

  • I actually figured this out later. for some reason, the code just wasn't working. This actually did end up working as is!