Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #92 from is-a-dev/developments
Browse files Browse the repository at this point in the history
Developments
  • Loading branch information
MaskDuck authored Jun 28, 2024
2 parents 93494b2 + 7fd731b commit 9d6ca75
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
4 changes: 3 additions & 1 deletion _orangcbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import nextcord
from nextcord import ApplicationError, Intents
from nextcord.ext import application_checks as ac
from nextcord.ext import commands, help_commands
from nextcord.ext import commands, help_commands # type: ignore

prefix = "oct/" if os.getenv("TEST") else "oc/"

Expand Down Expand Up @@ -87,6 +87,7 @@ def convert_none_to_0(key: Optional[ConvertibleToInt] = None) -> int:
# print(traceback.format_exception(error))

# TODO: Remove onami when nextcord 3.0 release
# WARNING: Do not remove this if!
if nextcord.version_info < (3, 0, 0):
bot.load_extension("onami")
bot.load_extension("extensions.antihoist")
Expand All @@ -107,6 +108,7 @@ def convert_none_to_0(key: Optional[ConvertibleToInt] = None) -> int:
bot.load_extension("extensions.stars")
bot.load_extension("extensions.ping_cutedog")
bot.load_extension("extensions.chatbot")
bot.load_extension("extensions.antighostpinging")
if os.getenv("HASDB"):
bot.load_extension("extensions.tags_reworked")
# bot.load_extension("extensions.forum")
Expand Down
30 changes: 22 additions & 8 deletions _orangcbot/extensions/antihoist.py
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))

0 comments on commit 9d6ca75

Please sign in to comment.