No Errors Global Ban

Viewed 23

I don't know what is wrong with it, to me everything looks fine I get no errors in the console but when I try to global ban someone it doesn't even ban them from any of the servers!

@commands.command()
async def gban(self, ctx, user: discord.User, *, reason=None):
    role = discord.utils.get(ctx.guild.roles, name="<< Management Team")
    if role in ctx.author.roles:
        if reason == None:
                reasonem = discord.Embed(title="Specify a reason for logging purposes")
                await ctx.send(embed=reasonem)
                return
        for guild in bot.guilds:
            await guild.ban(user, reason=reason)
    else:
        await ctx.message.delete()
        em = discord.Embed(title="Permissions Required!", description=f"{ctx.author.name} You do not have the required Permissions to use this command", color=discord.Colour.red())
        await ctx.send(embed=em)
1 Answers

I let a simple error affect my code in which I only specified the if statement on reason and didn't give it a else statement if a reason was provided

@commands.command()
async def gban(self, ctx, user: discord.User, *, reason=None):
     role = discord.utils.get(ctx.guild.roles, name="<< Management Team")
     if role in ctx.author.roles:
                 if reason == None:
                    reasonem = discord.Embed(title="Specify a reason for logging purposes")
                    await ctx.send(embed=reasonem)
                    return
                 else:
                    for guild in bot.guilds:
                        await guild.ban(user, reason=reason)
     else:
         await ctx.message.delete()
         em = discord.Embed(title="Permissions Required!", description=f"{ctx.author.name} You do not have the required Permissions to use this command", color=discord.Colour.red())
         await ctx.send(embed=em)
Related