diff --git a/_orangcbot/__main__.py b/_orangcbot/__main__.py index 9bbe2ec..2674d64 100644 --- a/_orangcbot/__main__.py +++ b/_orangcbot/__main__.py @@ -9,7 +9,7 @@ import os import nextcord -from nextcord import ApplicationError, Intents +from nextcord import ApplicationError, Game, Intents from nextcord.ext import application_checks as ac from nextcord.ext import commands, help_commands # type: ignore @@ -81,6 +81,7 @@ def convert_none_to_0(key: Optional[ConvertibleToInt] = None) -> int: case_insensitive=True, owner_ids=owner_ids, allowed_mentions=nextcord.AllowedMentions.none(), + activity=Game("Busy being a Barbie Girl"), ) # @bot.event # async def on_command_error(ctx, error): diff --git a/_orangcbot/extensions/nonsense.py b/_orangcbot/extensions/nonsense.py index 69e5646..6dc254e 100644 --- a/_orangcbot/extensions/nonsense.py +++ b/_orangcbot/extensions/nonsense.py @@ -5,7 +5,8 @@ import aiohttp import nextcord -from nextcord import HTTPException, Interaction, SlashOption, slash_command +from nextcord import HTTPException, Interaction, Object, SlashOption, slash_command +from nextcord.ext import application_checks as ac from nextcord.ext import commands from .converters import ( @@ -290,6 +291,23 @@ class NonsenseSlash(commands.Cog): def __init__(self, bot: commands.Bot) -> None: self._bot: commands.Bot = bot + @nextcord.slash_command() + @ac.is_owner() + async def make_degen( + self, + interaction: Interaction, + user: nextcord.Member = SlashOption( + description="The degen-like user.", required=True + ), + reason=SlashOption( + description="Why this person should be a degen? Idrk.", required=True + ), + ) -> None: + await user.add_roles(Object(id=1238746465111642122), reason=reason) + await interaction.send( + f"Master, I have made {str(user)} to be a degenerate. I'm sorry for all your loss, Master." + ) + @nextcord.slash_command() async def ban( self, diff --git a/_orangcbot/extensions/oneword.py b/_orangcbot/extensions/oneword.py index 28ccf54..91f25c3 100644 --- a/_orangcbot/extensions/oneword.py +++ b/_orangcbot/extensions/oneword.py @@ -1,7 +1,7 @@ from __future__ import annotations import asyncio -from typing import Final +from typing import Final, cast import nextcord from nextcord.ext import commands @@ -14,6 +14,12 @@ class Oneword(commands.Cog): def __init__(self, bot: commands.Bot) -> None: self._bot: commands.Bot = bot + async def check_if_sending_consecutive_messages( + self, channel: nextcord.TextChannel + ): + messages: list[nextcord.Message] = await channel.history(limit=2).flatten() + return messages[1].author == messages[0].author + @commands.Cog.listener() async def on_message(self, message: nextcord.Message) -> None: if message.author.bot: @@ -22,13 +28,28 @@ async def on_message(self, message: nextcord.Message) -> None: return # type: ignore[reportAttributeAccessIssue] if message.channel.id != ONEWORD_CHANNEL_ID: return - if " " in message.content: + ONEWORD_CHANNEL = cast( # noqa: F841 + nextcord.TextChannel, self._bot.get_channel(ONEWORD_CHANNEL_ID) + ) + + # r = await self.check_if_sending_consecutive_messages(ONEWORD_CHANNEL) + if " " in message.content or "\n" in message.content: await message.delete() - r = await message.channel.send( - "Message which have space(s) are not allowed." + s = await message.channel.send( + "Message which have space(s) or newlines are not allowed." ) await asyncio.sleep(5) - await r.delete() + await s.delete() + return + + # if r: + # await message.delete() + # s = await message.channel.send("Nice try, kid.") + # await asyncio.sleep(5) + # await s.delete() + # return + + return @commands.Cog.listener() async def on_message_edit( @@ -48,6 +69,18 @@ async def on_message_edit( @commands.Cog.listener() async def on_message_delete(self, message: nextcord.Message) -> None: + # audit_log = await message.guild.audit_logs(limit=1).flatten() + # audit_log_entry: nextcord.AuditLogEntry = audit_log[0] + # try: + # assert audit_log_entry.action == nextcord.AuditLogAction.message_delete + # except AssertionError: + # return + # if ( + # (audit_log_entry.action == nextcord.AuditLogAction.message_delete) + # and (audit_log_entry.user == message.guild.me) + # and (audit_log_entry.extra.channel.id == ONEWORD_CHANNEL_ID) # type: ignore + # ): + # return if message.author.bot: return if " " in message.content: