Example #1
0
    async def add_filtered_word(self, fw: FilterWord) -> None:
        existing = self.guild().filter_words.filter(word=fw.word)
        if (len(existing) > 0):
            return False

        Guild.objects(_id=self.guild_id).update_one(push__filter_words=fw)
        return True
Example #2
0
 async def add_raid_phrase(self, phrase: str) -> bool:
     existing = self.guild().raid_phrases.filter(word=phrase)
     if (len(existing) > 0):
         return False
     Guild.objects(_id=self.guild_id).update_one(
         push__raid_phrases=FilterWord(word=phrase, bypass=5, notify=True))
     return True
Example #3
0
 async def remove_ignored_channel(self, id: int):
     g = Guild.objects(_id=self.guild_id)
     g2 = g.first()
     if id in g2.filter_excluded_channels:
         g.update_one(pull__filter_excluded_channels=id)
         return True
     return False
Example #4
0
 async def remove_whitelisted_guild(self, id: int):
     g = Guild.objects(_id=self.guild_id)
     g2 = g.first()
     if id in g2.filter_excluded_guilds:
         g.update_one(pull__filter_excluded_guilds=id)
         return True
     return False
Example #5
0
 async def get_tag(self, name: str):
     g = Guild.objects(_id=self.guild_id).first()
     for t in g.tags:
         if t.name == name:
             t.use_count += 1
             g.save()
             return t
     return None
 async def get_tag_by_name(self, name: str, args: bool):
     g = Guild.objects(_id=self.guild_id).first()
     for t in g.tags:
         if t.name == name and t.args == args:
             t.use_count += 1
             g.save()
             return t
     return None
 async def get_tag(self, _id: int):
     g = Guild.objects(_id=self.guild_id).first()
     for t in g.tags:
         if t._id == _id:
             t.use_count += 1
             g.save()
             return t
     return None
Example #8
0
    def guild(self) -> Guild:
        """Returns the state of the main guild from the database.

        Returns
        -------
        Guild
            The Guild document object that holds information about the main guild.
        """

        return Guild.objects(_id=self.guild_id).first()
Example #9
0
 async def edit_tag(self, tag):
     return Guild.objects(_id=self.guild_id,
                          tags__name=tag.name).update_one(set__tags__S=tag)
Example #10
0
 async def remove_tag(self, tag: str):
     return Guild.objects(_id=self.guild_id).update_one(
         pull__tags__name=Tag(name=tag).name)
Example #11
0
    async def inc_caseid(self) -> None:
        """Increments Guild.case_id, which keeps track of the next available ID to
        use for a case.
        """

        Guild.objects(_id=self.guild_id).update_one(inc__case_id=1)
Example #12
0
 async def save_emoji_webhook(self, id):
     g = Guild.objects(_id=self.guild_id).first()
     g.emoji_logging_webhook = id
     g.save()
 async def remove_tag(self, _id: int):
     return Guild.objects(_id=self.guild_id).update_one(pull__tags___id=Tag(
         _id=_id)._id)
Example #14
0
 async def add_locked_channels(self, channel):
     Guild.objects(_id=self.guild_id).update_one(
         push__locked_channels=channel)
Example #15
0
 async def remove_filtered_word(self, word: str):
     return Guild.objects(_id=self.guild_id).update_one(
         pull__filter_words__word=FilterWord(word=word).word)
Example #16
0
 async def remove_locked_channels(self, channel):
     Guild.objects(_id=self.guild_id).update_one(
         pull__locked_channels=channel)
Example #17
0
 async def update_filtered_word(self, word: FilterWord):
     return Guild.objects(
         _id=self.guild_id,
         filter_words__word=word.word).update_one(set__filter_words__S=word)
Example #18
0
 async def remove_raid_phrase(self, phrase: str):
     Guild.objects(_id=self.guild_id).update_one(
         pull__raid_phrases__word=FilterWord(word=phrase).word)
Example #19
0
 async def add_tag(self, tag: Tag) -> None:
     Guild.objects(_id=self.guild_id).update_one(push__tags=tag)
Example #20
0
 async def set_spam_mode(self, mode) -> None:
     Guild.objects(_id=self.guild_id).update_one(
         set__ban_today_spam_accounts=mode)
Example #21
0
 async def add_filtered_word(self, fw: FilterWord) -> None:
     Guild.objects(_id=self.guild_id).update_one(push__filter_words=fw)