2022-12-08 22:21:53 +01:00
|
|
|
import discord
|
|
|
|
|
import re
|
|
|
|
|
import asyncio
|
|
|
|
|
import openai
|
2022-12-10 23:50:17 +01:00
|
|
|
from config import debug, c, max_uses, cp, conn, connp
|
2022-12-10 00:28:20 +01:00
|
|
|
import random
|
2022-12-12 12:54:04 +01:00
|
|
|
import threading
|
2023-01-30 22:57:47 +01:00
|
|
|
import makeprompt as mp
|
2022-12-08 22:21:53 +01:00
|
|
|
class Chat (discord.Cog) :
|
|
|
|
|
def __init__(self, bot: discord.Bot):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self.bot = bot
|
|
|
|
|
@discord.Cog.listener()
|
|
|
|
|
async def on_message(self, message: discord.Message):
|
2023-03-01 23:46:54 +01:00
|
|
|
await mp.chat_process(self, message)
|
2022-12-12 12:58:45 +01:00
|
|
|
|
2022-12-08 22:21:53 +01:00
|
|
|
@discord.slash_command(name="say", description="Say a message")
|
|
|
|
|
async def say(self, ctx: discord.ApplicationContext, message: str):
|
|
|
|
|
await ctx.respond("Message sent !", ephemeral=True)
|
2022-12-10 09:36:06 +01:00
|
|
|
await ctx.send(message)
|
2023-01-30 22:57:47 +01:00
|
|
|
|
2022-12-16 12:51:46 +01:00
|
|
|
@discord.slash_command(name="redo", description="Redo a message")
|
|
|
|
|
async def redo(self, ctx: discord.ApplicationContext):
|
2022-12-16 15:43:32 +01:00
|
|
|
history = await ctx.channel.history(limit=2).flatten()
|
|
|
|
|
message_to_delete = history[0]
|
|
|
|
|
message_to_redo = history[1]
|
|
|
|
|
if message_to_delete.author.id == self.bot.user.id:
|
|
|
|
|
await message_to_delete.delete()
|
2022-12-16 12:51:46 +01:00
|
|
|
else:
|
2023-03-01 23:46:54 +01:00
|
|
|
message_to_redo=history[0]
|
2022-12-19 19:55:25 +01:00
|
|
|
await ctx.respond("Message redone !", ephemeral=True)
|
2023-03-01 23:46:54 +01:00
|
|
|
await mp.chat_process(self, message_to_redo)
|