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

Fix bot #98

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _orangcbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
20 changes: 19 additions & 1 deletion _orangcbot/extensions/nonsense.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
43 changes: 38 additions & 5 deletions _orangcbot/extensions/oneword.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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(
Expand All @@ -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:
Expand Down
Loading