mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 06:40:35 +01:00
Ajout de la commande !say pour permettre l'envoi de messages en tant que bot dans un canal spécifié, avec des instructions d'utilisation .
This commit is contained in:
@@ -18,7 +18,8 @@ from discordbot.moderation import (
|
||||
handle_inspect_command,
|
||||
handle_ban_list_command,
|
||||
handle_staff_help_command,
|
||||
handle_timeout_command
|
||||
handle_timeout_command,
|
||||
handle_say_command
|
||||
)
|
||||
from discordbot.welcome import sendWelcomeMessage, sendLeaveMessage, updateInviteCache
|
||||
from protondb import searhProtonDb
|
||||
@@ -136,6 +137,10 @@ async def on_message(message: Message):
|
||||
await handle_inspect_command(message, bot)
|
||||
return
|
||||
|
||||
if command_name == '!say':
|
||||
await handle_say_command(message, bot)
|
||||
return
|
||||
|
||||
if command_name in ['!aide', '!help']:
|
||||
await handle_staff_help_command(message, bot)
|
||||
return
|
||||
|
||||
@@ -1050,6 +1050,16 @@ async def handle_staff_help_command(message: Message, bot):
|
||||
)
|
||||
embed.add_field(name="👢 Expulsion", value=value, inline=False)
|
||||
|
||||
embed.add_field(
|
||||
name="💬 Autres",
|
||||
value=(
|
||||
"• `!say #channel message`\n"
|
||||
" Envoie un message en tant que bot\n"
|
||||
" Ex: `!say #annonces Nouvelle fonctionnalité !`"
|
||||
),
|
||||
inline=False
|
||||
)
|
||||
|
||||
try:
|
||||
sent = await message.channel.send(embed=embed)
|
||||
if is_staff:
|
||||
@@ -1335,3 +1345,48 @@ async def handle_inspect_command(message: Message, bot):
|
||||
await message.channel.send(embed=embed)
|
||||
await safe_delete_message(message)
|
||||
|
||||
async def handle_say_command(message: Message, bot):
|
||||
if not has_staff_role(message.author.roles):
|
||||
await send_access_denied(message.channel)
|
||||
return
|
||||
|
||||
parts = message.content.split(maxsplit=2)
|
||||
|
||||
if len(parts) < 3:
|
||||
embed = discord.Embed(
|
||||
title="📋 Utilisation de la commande",
|
||||
description="**Syntaxe :** `!say #channel message`",
|
||||
color=discord.Color.blue()
|
||||
)
|
||||
embed.add_field(name="Exemple", value="`!say #general Bonjour à tous !`", inline=False)
|
||||
msg = await message.channel.send(embed=embed)
|
||||
asyncio.create_task(delete_after_delay(msg))
|
||||
return
|
||||
|
||||
if not message.channel_mentions:
|
||||
embed = discord.Embed(
|
||||
title="❌ Erreur",
|
||||
description="Vous devez mentionner un canal avec #",
|
||||
color=discord.Color.red()
|
||||
)
|
||||
msg = await message.channel.send(embed=embed)
|
||||
asyncio.create_task(delete_after_delay(msg))
|
||||
return
|
||||
|
||||
target_channel = message.channel_mentions[0]
|
||||
text_to_send = parts[2]
|
||||
|
||||
try:
|
||||
await target_channel.send(text_to_send)
|
||||
await safe_delete_message(message)
|
||||
except discord.Forbidden:
|
||||
embed = discord.Embed(
|
||||
title="❌ Erreur",
|
||||
description="Je n'ai pas les permissions pour écrire dans ce canal.",
|
||||
color=discord.Color.red()
|
||||
)
|
||||
msg = await message.channel.send(embed=embed)
|
||||
asyncio.create_task(delete_after_delay(msg))
|
||||
except Exception as e:
|
||||
logging.error(f"Erreur lors de l'envoi du message: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user