async def kick(ctx, member: discord.Member, *, reason="N/A"): log.cmd('kick', ctx.author, ctx.guild) await member.kick() embed = done_embed(successfull_kick()) await ctx.send(embed=embed) embed = error_embed(dm_kick(ctx.guild, reason)) await member.send(embed=embed)
async def ban(ctx, member: discord.Member, *, reason="N/A"): log.cmd('ban', ctx.author, ctx.guild) await member.ban(reason=reason) embed = done_embed(successfull_ban()) await ctx.send(embed=embed) embed = error_embed(dm_ban(ctx.guild, reason)) await member.send(embed=embed)
async def prefix(ctx, prefix): log.cmd('prefix', ctx.author, ctx.guild) with open('prefixes.json', 'r') as f: prefixes = json.load(f) prefixes[str(ctx.guild.id)] = prefix with open('prefixes.json', 'w') as f: json.dump(prefixes, f, indent=4) embed = done_embed(successfull_prefix()) await ctx.send(embed=embed)
async def unban(ctx, *, member): log.cmd('unban', ctx.author, ctx.guild) banned_users = await ctx.guild.bans() member_name, member_discriminator = member.split('#') for ban_entry in banned_users: user = ban_entry.user if (user.name, user.discriminator) == (member_name, member_discriminator): await ctx.guild.unban(user) embed = done_embed(successfull_unban()) await ctx.send(embed=embed) return embed = error_embed(user_not_found()) await ctx.send(embed=embed)
async def help(ctx): log.cmd('help', ctx.author, ctx.guild) prefix = get_prefix(ctx, ctx) embed = discord.Embed( title='**List of commands**', description='Command syntax: `[about. argument] <required argument>`', color=0xC36EF6) embed.set_thumbnail( url= 'https://cdn.discordapp.com/avatars/738279888674357298/0a8114760177033f90ddfa2ac9b5c93d.png?size=64' ) for i in range(len(help_titles)): embed.add_field(name=help_titles[i], value=help_texts[i].format(prefix), inline=False) await ctx.message.add_reaction(emoji='🍌') await ctx.message.author.send(embed=embed)
async def info_error(ctx, error): log.cmd('info', ctx.author, ctx.guild) if isinstance(error, commands.MissingRequiredArgument): id = str(ctx.message.author.id) tag = ctx.message.author hash = ctx.message.author.avatar joined_at = ctx.message.author.joined_at.strftime('%d.%m.%Y') created_at = ctx.message.author.created_at.strftime('%d.%m.%Y') if ctx.message.author.bot: is_bot = type_bot else: is_bot = type_user embed = discord.Embed(title=about_user(), description=user_info(id, tag, is_bot, created_at, joined_at), color=0xff5757) embed.set_thumbnail( url='https://cdn.discordapp.com/avatars/{0}/{1}.png?size=64'. format(id, hash)) await ctx.send(embed=embed)
async def ping(ctx): log.cmd('ping', ctx.author, ctx.guild) latency = int(round(bot.latency * 100, 1)) embed = done_embed(pong(str(latency))) await ctx.send(embed=embed)
async def purge(ctx, arg: int): log.cmd('purge', ctx.author, ctx.guild) await ctx.channel.purge(limit=arg + 1) embed = done_embed(successfull_clear(arg)) await ctx.send(embed=embed)