-
Notifications
You must be signed in to change notification settings - Fork 1
/
anonymessage.py
34 lines (28 loc) · 1.08 KB
/
anonymessage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from discord import ChannelType
from nextcord import Message
from nextcord.ext.commands import Bot, Cog, Context, command
from nextcord.abc import PrivateChannel
class AnonyMessageCog(Cog):
BOT_ID = 939668303683653692
RECEIVER = 229732075203330049
def __init__(self, bot: Bot):
self.bot = bot
self.connections: list[PrivateChannel] = []
@Cog.listener()
async def on_message(self, message: Message):
if (
message.author.id == self.BOT_ID
or message.author.id == self.RECEIVER
or message.channel.type != ChannelType.private
):
return
channel = await self.bot.fetch_user(self.RECEIVER)
echo = await channel.send(message.content)
index = len(self.connections)
self.connections.append(message.channel)
await echo.edit(content=f"{index}: {echo.content}")
@command()
async def reply(self, ctx: Context, index: int, *, message: str):
if ctx.message.author.id != self.RECEIVER:
return
await self.connections[index].send(message)