dev #4

Merged
Arthur merged 12 commits from dev into main 2024-06-02 15:04:56 +02:00
2 changed files with 12 additions and 7 deletions
Showing only changes of commit b82d1bbf86 - Show all commits

View File

@ -1,7 +1,8 @@
import discord
from discord import app_commands
from discord import app_commands, Interaction
from discord.app_commands import Choice
from discord.ext import commands
from typing import cast
from classes.my_cog import MyCog
@ -11,6 +12,10 @@ class CogGroup(app_commands.Group, name="cog", description="Gérer les cogs"):
super().__init__()
self.bot = bot
async def interaction_check(self, interaction: Interaction, /) -> bool:
team = cast(discord.Team, self.bot.application.team)
return any(interaction.user.id == team_member.id for team_member in team.members)
@app_commands.command(name="load")
async def cog_load(self, interaction: discord.Interaction, extension: str):
"""
@ -111,10 +116,6 @@ class Admin(MyCog):
# Add cogs commands group to cog
self.bot.tree.add_command(CogGroup(self.bot))
async def cog_check(self, ctx):
admins = self.bot.owner_ids
return ctx.author.id in admins
async def setup(bot):
await bot.add_cog(Admin(bot))

View File

@ -1,8 +1,8 @@
from typing import Optional, List
from os import getenv, listdir
import re
import discord
from typing import cast
from discord import app_commands
from discord.app_commands import Choice
from discord.ext import commands
@ -23,7 +23,7 @@ class MyClient(commands.Bot):
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)
# self.add_listener(self.on_message)
async def setup_hook(self):
# cogs
@ -35,8 +35,11 @@ class MyClient(commands.Bot):
await self.tree.sync(guild=guild)
async def on_ready(self):
team = cast(discord.Team, self.application.team)
print(f'Logged in as {self.user} (ID: {self.user.id})')
print(f"Discord version : {discord.__version__}")
print(f"Admins : {', '.join([m.name for m in team.members])}")
print('------')
async def on_message(self, msg):
@ -45,6 +48,7 @@ class MyClient(commands.Bot):
if p.search(msg.content) is not None:
await msg.reply("Quoicoubeh !")
if __name__ == "__main__":
client = MyClient()
client.run(getenv("TOKEN"))