how to kick and ban members with discord py

Solutions on MaxInterview for how to kick and ban members with discord py by the best coders in the world

showing results for - "how to kick and ban members with discord py"
Haley
12 Jan 2017
1#this was in a cog   
2# The below code bans player.
3@commands.command()
4@commands.has_permissions(ban_members=True)
5  async def ban(self, ctx, member: discord.Member, *, reason=None):
6     await member.ban(reason=reason)
7     await ctx.send(f'User {member} has been kick')
8
9# The below code unbans player.
10@commands.command()
11@commands.has_permissions(administrator=True)
12  async def unban(self, ctx, *, member):
13     banned_users = await ctx.guild.bans()
14     member_name, member_discriminator = member.split("#")
15
16        for ban_entry in banned_users:
17            user = ban_entry.user
18
19            if (user.name, user.discriminator) == (member_name, member_discriminator):
20                await ctx.guild.unban(user)
21                await ctx.send(f'Unbanned {user.mention}')
22                return
23
24# The below code kicks player
25@commands.command()
26@commands.has_permissions(kick_members=True)
27    async def kick(self, ctx, member: discord.Member, *, reason=None):
28        await member.kick(reason=reason)
29        await ctx.send(f'User {member} has been kick')
Miranda
08 Nov 2016
1@client.command()
2@commands.has_permissions(kick_members=True)
3async def kick(ctx, member: discord.Member, *, reason=None):
4    if reason==None:
5      reason=" no reason provided"
6    await ctx.guild.kick(member)
7    await ctx.send(f'User {member.mention} has been kicked for {reason}')
queries leading to this page
discord py ban wordshow ot ban discord pyget the user ban reason discord pydiscord discord bot ban and kick code pythonhow to kick members with bot discord pyuser kick reason discord pydiscord py banreasons discord pyban players discord pydiscord py ban codekick discord pythonhow to add reason to discord bot commandhow to make ban command discord pypython discord ban useddiscord py kick function doesn 27t workdiscord py ban memberban everyone discord pyban in discord pymaking ban in discord pypython discord how to give kick reasonhow to make a kick ban command discord pyban with discord pyban discord pyon kicked 2fbanned from guild discord pyhow to get bot kick reason discord pyban user in discord pypython discord ban commanddiscord python kick commandban everyone discord pykick in discord pyhow to have a bot ban people on discord pydiscord py kick and ban commandban and kick not working discord pycommand kick bot discord pythonhow to get all bans discord pypython member ban discord pykick 26 ban discord pydiscord bot ban and kick command pythonhow to create a ban command on discord pydiscord py ban userdiscord py working ban commandhow to auto kick or ban user on discord pyban command discord pypython discord bot kick with idsee when bot gets kick from server discord pyban command discord pypython ban command discordban members discord pypython ban function discorddiscord py kick and ban commanddiscord py kick codekick ban unban discord pyon member kick discord pykick ban expection discord bot pythonhow to kick using discord pydiscord py bandiscord py ban members with idhow to make a ban and kick command discord pyhow to block mass bans discord pydiscord py kick memberkick function discord py pythonkick member discord pypython ban discord commandsdiscord py kick memberspython discord bot kick memberkick and ban command discord pyhow to ban members in discord pyban command in discord pykick code discord pydiscord py ban comandbot command to kick people in discord pyhow to kick people discord pyhow to ban in discord using discord pykick discord py rewritekick function discord pyhow to kick everyone in a server discord pydiscord py reason kickdiscord python ban commandhow to make kick and ban command in discord pykick 2f ban discord bot pythonpython discord how to kick userban member discord pyhow to make discord bot ban and kick with specific roles in discord pyban command dm embed discord pykick member from server discord pyhow to ban member discord pythonhow to kick someone for a message discord pythondiscord py kickpython discord py kick memberhow to kick and ban members with discord pyhow to make a ban script discord bot pykick discord pykick members discord pykick pythond discord botdiscord py kickablehow to make a ban command discord pyhow to ban in discord pyhow to kick and ban people in discord pydiscord py how to bandiscord py ban all membersban discord pyban command discord pydiscord py ban with iddiscord py how to bandiscord ban and kick command discord pyhow to kick someone with discord pyban kick and ban users discord pydiscord py kick from discordhow to kick and ban people in disocrd pyhow to ban member discord pydiscord py kick and banmember ban discord pydiscord py 22who do you want to kick 22 3fdiscord py ban on bot event kick discord pykick member discord pydiscord py ban user from messagediscord py ban commanddiscord py ban members kick log discord pydiscord py how to say a message on a member bandiscord py ban commandhow to kick member discord pykick ban discord pyhow to ban a player discord pykick from server discord pydiscord python bandiscord py kick and ban commandsdiscord py ban from eventban discord bot pythonkick command discord pyhow to make a kick command discord pyban words discord pyban members discord pyhow to make a kick command in discord pyhow to kick a player discord bot pyhow to kick and ban members with discord py