staticky-bot/main.py

50 lines
1.5 KiB
Python

from typing import Optional, List
from os import getenv, listdir
import re
import discord
from discord import app_commands
from discord.app_commands import Choice
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
class MyClient(commands.Bot):
def __init__(self):
intents = discord.Intents.none()
intents.guilds = True
intents.messages = True
intents.message_content = True
super().__init__(intents=intents, command_prefix=".")
self.MY_GUILD = discord.Object(id=getenv("GUILD_ID"))
self.initial_extensions = ["cogs." + f[:-3] for f in listdir("./cogs") if
f.endswith(".py") and f.__str__() != "__init__.py"]
#self.add_listener(self.on_message)
async def setup_hook(self):
# cogs
for extension in self.initial_extensions:
await self.load_extension(extension)
self.tree.copy_global_to(guild=self.MY_GUILD)
await self.tree.sync(guild=self.MY_GUILD)
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print(f"Discord version : {discord.__version__}")
print('------')
async def on_message(self, msg):
p = re.compile("[qQ]uoi[ \\.!?;]*$")
print(f"{msg!r}")
if p.search(msg.content) is not None:
await msg.reply("Quoicoubeh !")
if __name__ == "__main__":
client = MyClient()
client.run(getenv("TOKEN"))