コード例 #1
0
    async def silentban(self,
                        ctx,
                        target: discord.Member,
                        *,
                        reason: str = ""):
        """Bans a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't ban this user as "
                                  "they're a member of staff.")

        userlog(target.id, ctx.author, reason, "bans", target.name)

        safe_name = await commands.clean_content().convert(ctx, str(target))

        await target.ban(reason=f"{ctx.author}, reason: {reason}",
                         delete_message_days=0)
        chan_message = f"⛔ **Silent ban**: {ctx.author.mention} banned "\
                       f"{target.mention} | {safe_name}\n"\
                       f"🏷 __User ID__: {target.id}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future"\
                            ", it is recommended to use `.ban <user> [reason]`"\
                            " as the reason is automatically sent to the user."

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
コード例 #2
0
    async def hackban(self, ctx, target: int, *, reason: str = ""):
        """Bans a user with their ID, doesn't message them, staff only."""
        target_user = await self.bot.get_user_info(target)
        target_member = ctx.guild.get_member(target)
        # Hedge-proofing the code
        if target == ctx.author.id:
            return await ctx.send("You can't do mod actions on yourself.")
        elif target_member and self.check_if_target_is_staff(target_member):
            return await ctx.send("I can't ban this user as "
                                  "they're a member of staff.")

        userlog(target, ctx.author, reason, "bans", target_user.name)

        safe_name = await commands.clean_content().convert(ctx, str(target))

        await ctx.guild.ban(target_user,
                            reason=f"{ctx.author}, reason: {reason}",
                            delete_message_days=0)
        chan_message = f"⛔ **Hackban**: {ctx.author.mention} banned "\
                       f"{target_user.mention} | {safe_name}\n"\
                       f"🏷 __User ID__: {target}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future"\
                            ", it is recommended to use "\
                            "`.hackban <user> [reason]`."

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{safe_name} is now b&. 👍")
コード例 #3
0
ファイル: mod_timed.py プロジェクト: Fadhel00/Komet-CL
    async def timemute(self,
                       ctx,
                       target: discord.Member,
                       duration: str,
                       *,
                       reason: str = ""):
        """Mutes a user for a specified amount of time, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't mute this user as "
                                  "they're a member of staff.")

        expiry_timestamp = self.bot.parse_time(duration)
        expiry_datetime = datetime.utcfromtimestamp(expiry_timestamp)
        duration_text = self.bot.get_relative_timestamp(
            time_to=expiry_datetime, include_to=True, humanized=True)

        userlog(target.id, ctx.author, f"{reason} (Timed, until "
                f"{duration_text})", "mutes", target.name)

        safe_name = await commands.clean_content().convert(ctx, str(target))

        dm_message = f"You were muted!"
        if reason:
            dm_message += f" The given reason is: \"{reason}\"."
        dm_message += f"\n\nThis mute will expire {duration_text}."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents kick issues in cases where user blocked bot
            # or has DMs disabled
            pass

        mute_role = ctx.guild.get_role(config.mute_role)

        await target.add_roles(mute_role, reason=str(ctx.author))

        chan_message = f"🔇 **Timed Mute**: {ctx.author.mention} muted "\
                       f"{target.mention} for {duration_text} | {safe_name}\n"\
                       f"🏷 __User ID__: {target.id}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future, "\
                            "it is recommended to use `.mute <user> [reason]`"\
                            " as the reason is automatically sent to the user."

        add_job("unmute", target.id, {"guild": ctx.guild.id}, expiry_timestamp)

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{target.mention} can no longer speak. "
                       f"It will expire {duration_text}.")
        add_restriction(target.id, config.mute_role)
コード例 #4
0
ファイル: mod.py プロジェクト: choppymaster/ryuko-ng
    async def kick(self, ctx, target: discord.Member, *, reason: str = ""):
        """Kicks a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif target == self.bot.user:
            return await ctx.send(
                f"I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
            )
        elif self.check_if_target_is_staff(target):
            return await ctx.send(
                "I can't kick this user as they're a member of staff."
            )

        userlog(target.id, ctx.author, reason, "kicks", target.name)

        safe_name = await commands.clean_content(escape_markdown=True).convert(
            ctx, str(target)
        )

        dm_message = f"You were kicked from {ctx.guild.name}."
        if reason:
            dm_message += f' The given reason is: "{reason}".'
        dm_message += (
            "\n\nYou are able to rejoin the server,"
            " but please be sure to behave when participating again."
        )

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents kick issues in cases where user blocked bot
            # or has DMs disabled
            pass

        await target.kick(reason=f"{ctx.author}, reason: {reason}")
        chan_message = (
            f"👢 **Kick**: {str(ctx.author)} kicked "
            f"{target.mention} | {safe_name}\n"
            f"🏷 __User ID__: {target.id}\n"
        )
        if reason:
            chan_message += f'✏️ __Reason__: "{reason}"'
        else:
            chan_message += (
                "Please add an explanation below. In the future"
                ", it is recommended to use "
                "`.kick <user> [reason]`"
                " as the reason is automatically sent to the user."
            )

        chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"

        log_channel = self.bot.get_channel(config.modlog_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"👢 {safe_name}, 👍.")
コード例 #5
0
ファイル: mod.py プロジェクト: choppymaster/ryuko-ng
    async def ban(self, ctx, target: discord.Member, *, reason: str = ""):
        """Bans a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            if target.id == 181627658520625152:
                return await ctx.send(
                    "https://cdn.discordapp.com/attachments/286612533757083648/403080855402315796/rehedge.PNG"
                )
            return await ctx.send("hedgeberg#7337 is now b&. 👍")
        elif target == self.bot.user:
            return await ctx.send(
                f"I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
            )
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't ban this user as they're a member of staff.")

        userlog(target.id, ctx.author, reason, "bans", target.name)

        safe_name = await commands.clean_content(escape_markdown=True).convert(
            ctx, str(target)
        )

        dm_message = f"You were banned from {ctx.guild.name}."
        if reason:
            dm_message += f' The given reason is: "{reason}".'
        dm_message += "\n\nThis ban does not expire."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents ban issues in cases where user blocked bot
            # or has DMs disabled
            pass

        await target.ban(
            reason=f"{ctx.author}, reason: {reason}", delete_message_days=0
        )
        chan_message = (
            f"⛔ **Ban**: {str(ctx.author)} banned "
            f"{target.mention} | {safe_name}\n"
            f"🏷 __User ID__: {target.id}\n"
        )
        if reason:
            chan_message += f'✏️ __Reason__: "{reason}"'
        else:
            chan_message += (
                "Please add an explanation below. In the future"
                ", it is recommended to use `.ban <user> [reason]`"
                " as the reason is automatically sent to the user."
            )

        chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"

        log_channel = self.bot.get_channel(config.modlog_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{safe_name} is now b&. 👍")
コード例 #6
0
ファイル: mod.py プロジェクト: choppymaster/ryuko-ng
    async def mute(self, ctx, target: discord.Member, *, reason: str = ""):
        """Mutes a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif target == self.bot.user:
            return await ctx.send(
                f"I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
            )
        elif self.check_if_target_is_staff(target):
            return await ctx.send(
                "I can't mute this user as they're a member of staff."
            )

        userlog(target.id, ctx.author, reason, "mutes", target.name)

        safe_name = await commands.clean_content(escape_markdown=True).convert(
            ctx, str(target)
        )

        dm_message = f"You were muted!"
        if reason:
            dm_message += f' The given reason is: "{reason}".'

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents kick issues in cases where user blocked bot
            # or has DMs disabled
            pass

        mute_role = ctx.guild.get_role(config.mute_role)

        await target.add_roles(mute_role, reason=str(ctx.author))

        chan_message = (
            f"🔇 **Muted**: {str(ctx.author)} muted "
            f"{target.mention} | {safe_name}\n"
            f"🏷 __User ID__: {target.id}\n"
        )
        if reason:
            chan_message += f'✏️ __Reason__: "{reason}"'
        else:
            chan_message += (
                "Please add an explanation below. In the future, "
                "it is recommended to use `.mute <user> [reason]`"
                " as the reason is automatically sent to the user."
            )

        chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"

        log_channel = self.bot.get_channel(config.modlog_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{target.mention} can no longer speak.")
        add_restriction(target.id, config.mute_role)
コード例 #7
0
    async def timemute(self,
                       ctx,
                       target: discord.Member,
                       hours: int,
                       *,
                       reason: str = ""):
        """Mutes a user for a specified amount of hours, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't mute this user as "
                                  "they're a member of staff.")

        userlog(target.id, ctx.author, f"{reason} (Timed, for {hours}h)",
                "mutes", target.name)

        safe_name = self.bot.escape_message(str(target))

        dm_message = f"You were muted!"
        if reason:
            dm_message += f" The given reason is: \"{reason}\"."
        dm_message += f"\n\nThis mute will expire in {hours} hours."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents kick issues in cases where user blocked bot
            # or has DMs disabled
            pass

        mute_role = ctx.guild.get_role(config.mute_role)

        await target.add_roles(mute_role, reason=str(ctx.author))

        chan_message = f"🔇 **Timed Mute**: {ctx.author.mention} muted "\
                       f"{target.mention} for {hours} hours | {safe_name}\n"\
                       f"🏷 __User ID__: {target.id}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future, "\
                            "it is recommended to use `.mute <user> [reason]`"\
                            " as the reason is automatically sent to the user."

        expiry_timestamp = time.time() + (hours * 3600)
        add_job("unmute", target.id, {"guild": ctx.guild.id}, expiry_timestamp)

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{target.mention} can no longer speak.")
        add_restriction(target.id, config.mute_role)
コード例 #8
0
    async def timeban(self,
                      ctx,
                      target: discord.Member,
                      hours: int,
                      *,
                      reason: str = ""):
        """Bans a user for a specified amount of hours, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't ban this user as "
                                  "they're a member of staff.")

        userlog(target.id, ctx.author, f"{reason} (Timed, for {hours}h)",
                "bans", target.name)

        safe_name = self.bot.escape_message(str(target))

        dm_message = f"You were banned from {ctx.guild.name}."
        if reason:
            dm_message += f" The given reason is: \"{reason}\"."
        dm_message += f"\n\nThis ban will expire in {hours} hours."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents ban issues in cases where user blocked bot
            # or has DMs disabled
            pass

        await target.ban(reason=f"{ctx.author}, reason: {reason}",
                         delete_message_days=0)
        chan_message = f"⛔ **Timed Ban**: {ctx.author.mention} banned "\
                       f"{target.mention} for {hours} hours | {safe_name}\n"\
                       f"🏷 __User ID__: {target.id}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future"\
                            ", it is recommended to use `.ban <user> [reason]`"\
                            " as the reason is automatically sent to the user."

        expiry_timestamp = time.time() + (hours * 3600)
        add_job("unban", target.id, {"guild": ctx.guild.id}, expiry_timestamp)

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{safe_name} is now b& for {hours} hours. 👍")
コード例 #9
0
    async def warn(self, ctx, target: discord.Member, *, reason: str = ""):
        """Warns a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't warn this user as "
                                  "they're a member of staff.")

        log_channel = self.bot.get_channel(config.log_channel)
        warn_count = userlog(target.id, ctx.author, reason, "warns",
                             target.name)

        safe_name = await commands.clean_content().convert(ctx, str(target))
        chan_msg = f"⚠️ **Warned**: {ctx.author.mention} warned "\
                   f"{target.mention} (warn #{warn_count}) "\
                   f"| {safe_name}\n"

        msg = f"You were warned on {ctx.guild.name}."
        if reason:
            msg += " The given reason is: " + reason
        msg += f"\n\nPlease read the rules in {config.rules_url}. "\
               f"This is warn #{warn_count}."
        if warn_count == 2:
            msg += " __The next warn will automatically kick.__"
        if warn_count == 3:
            msg += "\n\nYou were kicked because of this warning. "\
                   "You can join again right away. "\
                   "Two more warnings will result in an automatic ban."
        if warn_count == 4:
            msg += "\n\nYou were kicked because of this warning. "\
                   "This is your final warning. "\
                   "You can join again, but "\
                   "**one more warn will result in a ban**."
            chan_msg += "**This resulted in an auto-kick.**\n"
        if warn_count == 5:
            msg += "\n\nYou were automatically banned due to five warnings."
            chan_msg += "**This resulted in an auto-ban.**\n"
        try:
            await target.send(msg)
        except discord.errors.Forbidden:
            # Prevents log issues in cases where user blocked bot
            # or has DMs disabled
            pass
        if warn_count == 3 or warn_count == 4:
            await target.kick()
        if warn_count >= 5:  # just in case
            await target.ban(reason="exceeded warn limit",
                             delete_message_days=0)
        await ctx.send(f"{target.mention} warned. "
                       f"User has {warn_count} warning(s).")

        if reason:
            chan_msg += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_msg += "Please add an explanation below. In the future"\
                        ", it is recommended to use `.ban <user> [reason]`"\
                        " as the reason is automatically sent to the user."
        await log_channel.send(chan_msg)
コード例 #10
0
    async def ban(self, ctx, target: discord.Member, *, reason: str = ""):
        """Bans a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            if target.id == 181627658520625152:
                return await ctx.send("No, not again.")
            return await ctx.send("hedgeberg#7337 is now b&. 👍")
        elif target == self.bot.user:
            return await ctx.send(f"I'm sorry {ctx.author.mention}, "
                                  "I'm afraid I can't do that.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't ban this user as "
                                  "they're a member of staff.")

        userlog(target.id, ctx.author, reason, "bans", target.name)

        safe_name = await commands.clean_content().convert(ctx, str(target))

        dm_message = f"You were banned from {ctx.guild.name}."
        if reason:
            dm_message += f" The given reason is: \"{reason}\"."
        dm_message += "\n\nThis ban does not expire."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents ban issues in cases where user blocked bot
            # or has DMs disabled
            pass

        await target.ban(reason=f"{ctx.author}, reason: {reason}",
                         delete_message_days=0)
        chan_message = f"⛔ **Ban**: {ctx.author.mention} banned "\
                       f"{target.mention} | {safe_name}\n"\
                       f"🏷 __User ID__: {target.id}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future"\
                            ", it is recommended to use `.ban <user> [reason]`"\
                            " as the reason is automatically sent to the user."

        log_channel = self.bot.get_channel(config.modlog_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{safe_name} is now b&. 👍")
コード例 #11
0
ファイル: mod.py プロジェクト: choppymaster/ryuko-ng
    async def massban(self, ctx, *, targets: str):
        """Bans users with their IDs, doesn't message them, staff only."""
        targets_int = [int(target) for target in targets.strip().split(" ")]
        for target in targets_int:
            target_user = await self.bot.fetch_user(target)
            target_member = ctx.guild.get_member(target)
            # Hedge-proofing the code
            if target == ctx.author.id:
                await ctx.send(f"(re: {target}) You can't do mod actions on yourself.")
                continue
            elif target == self.bot.user:
                await ctx.send(
                    f"(re: {target}) I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
                )
                continue
            elif target_member and self.check_if_target_is_staff(target_member):
                await ctx.send(
                    f"(re: {target}) I can't ban this user as they're a member of staff."
                )
                continue

            userlog(target, ctx.author, f"massban", "bans", target_user.name)

            safe_name = await commands.clean_content(escape_markdown=True).convert(
                ctx, str(target)
            )

            await ctx.guild.ban(
                target_user,
                reason=f"{ctx.author}, reason: massban",
                delete_message_days=0,
            )
            chan_message = (
                f"⛔ **Massban**: {str(ctx.author)} banned "
                f"{target_user.mention} | {safe_name}\n"
                f"🏷 __User ID__: {target}\n"
                "Please add an explanation below."
            )

            chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"

            log_channel = self.bot.get_channel(config.modlog_channel)
            await log_channel.send(chan_message)
        await ctx.send(f"All {len(targets_int)} users are now b&. 👍")
コード例 #12
0
ファイル: mod.py プロジェクト: choppymaster/ryuko-ng
    async def hackban(self, ctx, target: int, *, reason: str = ""):
        """Bans a user with their ID, doesn't message them, staff only."""
        target_user = await self.bot.fetch_user(target)
        target_member = ctx.guild.get_member(target)
        # Hedge-proofing the code
        if target == ctx.author.id:
            return await ctx.send("You can't do mod actions on yourself.")
        elif target == self.bot.user:
            return await ctx.send(
                f"I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
            )
        elif target_member and self.check_if_target_is_staff(target_member):
            return await ctx.send("I can't ban this user as they're a member of staff.")

        userlog(target, ctx.author, reason, "bans", target_user.name)

        safe_name = await commands.clean_content(escape_markdown=True).convert(
            ctx, str(target)
        )

        await ctx.guild.ban(
            target_user, reason=f"{ctx.author}, reason: {reason}", delete_message_days=0
        )
        chan_message = (
            f"⛔ **Hackban**: {str(ctx.author)} banned "
            f"{target_user.mention} | {safe_name}\n"
            f"🏷 __User ID__: {target}\n"
        )
        if reason:
            chan_message += f'✏️ __Reason__: "{reason}"'
        else:
            chan_message += (
                "Please add an explanation below. In the future"
                ", it is recommended to use "
                "`.hackban <user> [reason]`."
            )

        chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"

        log_channel = self.bot.get_channel(config.modlog_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{safe_name} is now b&. 👍")
コード例 #13
0
    async def kick(self, ctx, target: discord.Member, *, reason: str = ""):
        """Kicks a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't kick this user as "
                                  "they're a member of staff.")

        userlog(target.id, ctx.author, reason, "kicks", target.name)

        safe_name = await commands.clean_content().convert(ctx, str(target))

        dm_message = f"You were kicked from {ctx.guild.name}."
        if reason:
            dm_message += f" The given reason is: \"{reason}\"."
        dm_message += "\n\nYou are able to rejoin the server,"\
                      " but please be sure to behave when participating again."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents kick issues in cases where user blocked bot
            # or has DMs disabled
            pass

        await target.kick(reason=f"{ctx.author}, reason: {reason}")
        chan_message = f"👢 **Kick**: {ctx.author.mention} kicked "\
                       f"{target.mention} | {safe_name}\n"\
                       f"🏷 __User ID__: {target.id}\n"
        if reason:
            chan_message += f"✏️ __Reason__: \"{reason}\""
        else:
            chan_message += "Please add an explanation below. In the future"\
                            ", it is recommended to use "\
                            "`.kick <user> [reason]`"\
                            " as the reason is automatically sent to the user."

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
コード例 #14
0
ファイル: mod.py プロジェクト: choppymaster/ryuko-ng
    async def silentban(self, ctx, target: discord.Member, *, reason: str = ""):
        """Bans a user, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif target == self.bot.user:
            return await ctx.send(
                f"I'm sorry {ctx.author.mention}, I'm afraid I can't do that."
            )
        elif self.check_if_target_is_staff(target):
            return await ctx.send("I can't ban this user as they're a member of staff.")

        userlog(target.id, ctx.author, reason, "bans", target.name)

        safe_name = await commands.clean_content(escape_markdown=True).convert(
            ctx, str(target)
        )

        await target.ban(
            reason=f"{ctx.author}, reason: {reason}", delete_message_days=0
        )
        chan_message = (
            f"⛔ **Silent ban**: {str(ctx.author)} banned "
            f"{target.mention} | {safe_name}\n"
            f"🏷 __User ID__: {target.id}\n"
        )
        if reason:
            chan_message += f'✏️ __Reason__: "{reason}"'
        else:
            chan_message += (
                "Please add an explanation below. In the future"
                ", it is recommended to use `.ban <user> [reason]`"
                " as the reason is automatically sent to the user."
            )

        chan_message += f"\n🔗 __Jump__: <{ctx.message.jump_url}>"

        log_channel = self.bot.get_channel(config.modlog_channel)
        await log_channel.send(chan_message)
コード例 #15
0
ファイル: mod_note.py プロジェクト: LyfeOnEdge/Blastoise
 async def note(self, ctx, target: discord.Member, *, note: str = ""):
     """Adds a note to a user, staff only."""
     userlog(target.id, ctx.author, note, "notes", target.name)
     await ctx.send(f"{ctx.author.mention}: noted!")
コード例 #16
0
ファイル: mod_timed.py プロジェクト: cheesycod/robocop-ng
    async def timeban(self,
                      ctx,
                      target: discord.Member,
                      duration: str,
                      *,
                      reason: str = ""):
        """Bans a user for a specified amount of time, staff only."""
        # Hedge-proofing the code
        if target == ctx.author:
            return await ctx.send("You can't do mod actions on yourself.")
        elif self.check_if_target_is_staff(target):
            return await ctx.send(
                "I can't ban this user as they're a member of staff.")

        expiry_timestamp = self.bot.parse_time(duration)
        expiry_datetime = datetime.utcfromtimestamp(expiry_timestamp)
        duration_text = self.bot.get_relative_timestamp(
            time_to=expiry_datetime, include_to=True, humanized=True)

        userlog(
            target.id,
            ctx.author,
            f"{reason} (Timed, until "
            f"{duration_text})",
            "bans",
            target.name,
        )

        safe_name = await commands.clean_content().convert(ctx, str(target))

        dm_message = f"You were banned from {ctx.guild.name}."
        if reason:
            dm_message += f' The given reason is: "{reason}".'
        dm_message += f"\n\nThis ban will expire {duration_text}."

        try:
            await target.send(dm_message)
        except discord.errors.Forbidden:
            # Prevents ban issues in cases where user blocked bot
            # or has DMs disabled
            pass

        await target.ban(reason=f"{ctx.author}, reason: {reason}",
                         delete_message_days=0)
        chan_message = (f"⛔ **Timed Ban**: {ctx.author.mention} banned "
                        f"{target.mention} for {duration_text} | {safe_name}\n"
                        f"🏷 __User ID__: {target.id}\n")
        if reason:
            chan_message += f'✏️ __Reason__: "{reason}"'
        else:
            chan_message += (
                "Please add an explanation below. In the future"
                ", it is recommended to use `.ban <user> [reason]`"
                " as the reason is automatically sent to the user.")

        add_job("unban", target.id, {"guild": ctx.guild.id}, expiry_timestamp)

        log_channel = self.bot.get_channel(config.log_channel)
        await log_channel.send(chan_message)
        await ctx.send(f"{safe_name} is now b&. "
                       f"It will expire {duration_text}. 👍")
コード例 #17
0
ファイル: mod_note.py プロジェクト: LyfeOnEdge/Blastoise
 async def noteid(self, ctx, target: int, *, note: str = ""):
     """Adds a note to a user by userid, staff only."""
     userlog(target, ctx.author, note, "notes")
     await ctx.send(f"{target.mention}: noted!")