コード例 #1
0
ファイル: mod.py プロジェクト: wafay/justice
    def mute_user(self,
                  event: CommandEvent,
                  member: GuildMember,
                  time: str = None):
        """Silence a member

        Create overwrites on all necessary channels, and prevent the user from typing there.
        You can also add a time limit, where after the time is over, it will unsilence them.

        This bot supports a variety of ways to provider users, so for example you can do:
        `]silence 09832098349` (Ban user from their ID, won't unslience after some time)
        `]silence @BadUser5456 1m 30s` (Ban user from mention, unsilence after 1 min and 30 seconds)
        `]silence BadUser5456#0001 10d 2h` (Ban user from name + discriminator, unsilence after 10 days and 2 hours)
        """
        if time:
            try:
                total_time = time_parse(time)
            except ParseError:
                return event.msg.reply(
                    "Sorry, I don't recognize '{0}' as a valid time.".format(
                        time))
            else:
                if total_time < 30 or total_time > 31 * 24 * 60 * 60:
                    return event.msg.reply(
                        "Sorry, the time must be >30sec and <1 month.")

                mute_record = self.bot.storage["MUTES"].data
                mute_record[member.id] = {
                    "start": int(t.time()),
                    "length": total_time
                }
                spawn(self.unmute, member.id, total_time)

        member.add_role(config.MUTE_ROLE_ID)
        event.msg.add_reaction("👍")
コード例 #2
0
ファイル: mod.py プロジェクト: wafay/justice
    def kick_user(self,
                  event: CommandEvent,
                  member: GuildMember,
                  reason: str = None):
        """Kick a member

        A simple way to remove someone from the guild, without getting you hands dirty.

        This bot supports a variety of ways to provider users, so for example you can do:
        `]kick 09832098349` (Ban user from their ID)
        `]kick @BadUser5456` (Ban user from mention)
        `]kick BadUser5456#0001` (Ban user from name + discriminator)

        You can also specify the reason for the ban:
        `]kick @BadUser5456 Provoking other members of the guild`
        """
        member.kick(reason=reason)
        event.msg.add_reaction("👍")
コード例 #3
0
ファイル: client.py プロジェクト: zw5/disco
 def guilds_members_list(self, guild, limit=1000, after=None):
     r = self.http(Routes.GUILDS_MEMBERS_LIST,
                   dict(guild=guild),
                   params=optional(
                       limit=limit,
                       after=after,
                   ))
     return GuildMember.create_hash(self.client,
                                    'id',
                                    r.json(),
                                    guild_id=guild)
コード例 #4
0
ファイル: mod.py プロジェクト: wafay/justice
    def ban_user(self,
                 event: CommandEvent,
                 member: GuildMember,
                 days: int,
                 reason: str = None):
        """Ban a member

        Easily and permanently ban a user from the guild

        You must provide the user, and the amount of messages to delete from the past X days.

        This bot supports a variety of ways to provider users, so for example you can do:
        `]ban 09832098349 0` (Ban user from their ID, don't remove any messages)
        `]ban @BadUser5456 1` (Ban user from mention, remove messages from the past day)
        `]ban BadUser5456#0001 14` (Ban user from name + discriminator, remove messages from past 2 weeks)

        You can also specify the reason for the ban:
        `]ban @BadUser5456 7 Spamming invite links in chat`
        """
        member.ban(delete_message_days=days, reason=reason)
        event.msg.add_reaction("👍")
コード例 #5
0
ファイル: client.py プロジェクト: sgtlaggy/disco
 def guilds_members_get(self, guild, member):
     r = self.http(Routes.GUILDS_MEMBERS_GET, dict(guild=guild, member=member))
     return GuildMember.create(self.client, r.json(), guild_id=guild)
コード例 #6
0
ファイル: client.py プロジェクト: sgtlaggy/disco
 def guilds_members_list(self, guild):
     r = self.http(Routes.GUILDS_MEMBERS_LIST, dict(guild=guild))
     return GuildMember.create_map(self.client, r.json(), guild_id=guild)