Initial commit: bot Discord Vicy V1.8
This commit is contained in:
commit
56958c5832
70 changed files with 8469 additions and 0 deletions
38
commandes/message_tous.py
Normal file
38
commandes/message_tous.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
class MessageTous(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(
|
||||
name="messagetous",
|
||||
description="Envoyer un message privé à tous les membres du serveur."
|
||||
)
|
||||
@app_commands.checks.has_permissions(administrator=True)
|
||||
async def message_tous(self, interaction: discord.Interaction, message: str):
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
|
||||
succes = 0
|
||||
erreurs = 0
|
||||
|
||||
await interaction.followup.send("Envoi du message en cours...", ephemeral=False)
|
||||
|
||||
for member in interaction.guild.members:
|
||||
if not member.bot and member != interaction.user:
|
||||
try:
|
||||
await member.send(message)
|
||||
succes += 1
|
||||
except discord.Forbidden:
|
||||
erreurs += 1
|
||||
except Exception as e:
|
||||
erreurs += 1
|
||||
|
||||
await interaction.followup.send(
|
||||
f"✅ Message envoyé à {succes} membres.\n❌ {erreurs} erreurs.",
|
||||
ephemeral=False
|
||||
)
|
||||
|
||||
async def setup(bot: commands.Bot):
|
||||
await bot.add_cog(MessageTous(bot))
|
||||
Loading…
Add table
Add a link
Reference in a new issue