mod.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:dogbot 作者: slice 项目源码 文件源码
def ban(self, ctx, member: converters.RawMember, delete_days: DeleteDays=2, *, reason=None):
        """
        Bans someone.

        This command is special in that you may specify an ID to ban, instead of regularly specifying a
        member to ban. Banning users outside of the server is called "hackbanning", and is handy for banning
        users who are not present in the server.

        If you don't want to delete any messages, specify 0 for delete_days. delete_days has a
        maximum of 7. By default, 2 days worth of messages are deleted.
        """
        try:
            reason = reason or 'No reason provided.'
            await ctx.guild.ban(member, delete_message_days=delete_days, reason=f'(Banned by {ctx.author}) {reason}')
            ctx.bot.dispatch('member_dog_ban', member, ctx.author, reason)
        except discord.Forbidden:
            await ctx.send("I can't do that.")
        except discord.NotFound:
            await ctx.send("User not found.")
        else:
            banned = await ctx.bot.get_user_info(member.id) if isinstance(member, discord.Object) else member
            await ctx.send(f'\N{OK HAND SIGN} Banned {describe(banned)}.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号