This repository was archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from is-a-dev/developments
Developments
- Loading branch information
Showing
2 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from string import ascii_letters | ||
from typing import TYPE_CHECKING | ||
from typing import TYPE_CHECKING, Final | ||
|
||
from nextcord.ext import commands | ||
|
||
if TYPE_CHECKING: | ||
import nextcord | ||
|
||
NUMBERS: Final[str] = "1234567890" | ||
normal_characters: Final[str] = ascii_letters + NUMBERS | ||
|
||
class Antihoist(commands.Cog): | ||
|
||
class AutoMod(commands.Cog): | ||
def __init__(self, bot: commands.Bot) -> None: | ||
self._bot: commands.Bot = bot | ||
try: | ||
assert self._bot.intents.auto_moderation is True | ||
except AssertionError: | ||
logging.getLogger("nextcord").warn( | ||
"auto_moderation intents is not enabled. Fix it or else no nword notifications." | ||
) | ||
|
||
@commands.Cog.listener("on_member_join") | ||
async def check_nickname_on_join(self, member: nextcord.Member) -> None: | ||
if member.display_name[0] not in ascii_letters: | ||
await member.edit(nick="kid", reason="imagine attention seeking") | ||
if member.display_name[0] not in normal_characters: | ||
await member.edit( | ||
nick="kid", reason="having a strong craving to be a discord ecelebrity" | ||
) | ||
|
||
@commands.Cog.listener("on_member_edit") | ||
@commands.Cog.listener("on_member_update") | ||
async def check_nickname_on_edit( | ||
self, _: nextcord.Member, after: nextcord.Member | ||
) -> None: | ||
if after.display_name[0] not in ascii_letters: | ||
await after.edit(nick="kid", reason="imagine attention seeking") | ||
if after.display_name[0] not in normal_characters: | ||
await after.edit( | ||
nick="kid", reason="having a strong craving to be a discord ecelebrity" | ||
) | ||
|
||
|
||
def setup(bot: commands.Bot) -> None: | ||
bot.add_cog(Antihoist(bot)) | ||
bot.add_cog(AutoMod(bot)) |