Migration de Kuby vers disnake
This commit is contained in:
parent
dc6e235f27
commit
c8c579eefe
36 changed files with 1205 additions and 1253 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
import disnake
|
||||
from disnake.ext import commands
|
||||
import sqlite3
|
||||
import aiohttp
|
||||
import io
|
||||
|
|
@ -145,9 +144,9 @@ class Welcome(commands.Cog):
|
|||
gif_url = "https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExNXV1NW02NTk0bGF2ZHcyMGFna2F6amRrbGpobGpsMHowOW5xa2E5eCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/ZtFuW4rsUbfrRzPauJ/giphy.gif"
|
||||
await member.send(f"{formatted_message}\n\n{gif_url}")
|
||||
kuby_logger.info(f"✅ [Welcome] DM envoyé avec succès à {member.name} (envoi groupé)")
|
||||
except discord.Forbidden:
|
||||
except disnake.Forbidden:
|
||||
kuby_logger.warning(f"🚫 [Welcome] Impossible d'envoyer le DM à {member.name} (DMs fermés)")
|
||||
except discord.HTTPException as e:
|
||||
except disnake.HTTPException as e:
|
||||
if e.code == 40003: # Rate limited (Opening DMs too fast)
|
||||
kuby_logger.warning(f"⏳ [Welcome] Limite de débit Discord atteinte pour les DMs : {member.name} n'a pas reçu son message.")
|
||||
else:
|
||||
|
|
@ -177,13 +176,13 @@ class Welcome(commands.Cog):
|
|||
member_count=member.guild.member_count
|
||||
) if welcome_channel_message else "Bienvenue dans le serveur !\nSi vous cherchez des RolePlay de qualité,\nVous êtes au bon endroit. <a:sip:1316891821858619452>"
|
||||
|
||||
embed = discord.Embed(title=f"Merci d'accueillir {member} 🤝",
|
||||
embed = disnake.Embed(title=f"Merci d'accueillir {member} 🤝",
|
||||
description=channel_description,
|
||||
color=discord.Color.dark_purple())
|
||||
color=disnake.Color.dark_purple())
|
||||
embed.set_image(url="attachment://welcome.png")
|
||||
await channel.send(content=member.mention, embed=embed, file=discord.File(img, filename="welcome.png"))
|
||||
await channel.send(content=member.mention, embed=embed, file=disnake.File(img, filename="welcome.png"))
|
||||
|
||||
async def save_banner_attachment(self, attachment: discord.Attachment, guild_id: int) -> str:
|
||||
async def save_banner_attachment(self, attachment: disnake.Attachment, guild_id: int) -> str:
|
||||
"""Sauvegarde l'attachment et retourne le chemin du fichier"""
|
||||
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "banners"))
|
||||
os.makedirs(base_dir, exist_ok=True)
|
||||
|
|
@ -215,9 +214,9 @@ class Welcome(commands.Cog):
|
|||
|
||||
return os.path.basename(banner_path)
|
||||
|
||||
@app_commands.command(name="setwelcome", description="Définit le salon, les messages de bienvenue et le fond de la bannière")
|
||||
@app_commands.checks.has_permissions(administrator=True)
|
||||
async def set_welcome(self, interaction: discord.Interaction, channel: discord.TextChannel, message_dm: str, message_salon: str, server_name: str, banner_file: discord.Attachment = None):
|
||||
@commands.slash_command(name="setwelcome", description="Définit le salon, les messages de bienvenue et le fond de la bannière")
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def set_welcome(self, interaction: disnake.ApplicationCommandInteraction, channel: disnake.TextChannel, message_dm: str, message_salon: str, server_name: str, banner_file: disnake.Attachment = None):
|
||||
banner_path = None
|
||||
|
||||
# Si un fichier est uploadé, le sauvegarder
|
||||
|
|
@ -237,7 +236,7 @@ class Welcome(commands.Cog):
|
|||
welcome_server_name=excluded.welcome_server_name,
|
||||
welcome_banner_background=COALESCE(excluded.welcome_banner_background, welcome_banner_background),
|
||||
welcome_channel_message=excluded.welcome_channel_message''',
|
||||
(interaction.guild_id, channel.id, message_dm, server_name, banner_path, message_salon))
|
||||
(interaction.guild_id, channel.id, message_dm, server_name, banner_path, message_salon))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue