Initial commit: bot Discord Vicy V1.8
This commit is contained in:
commit
56958c5832
70 changed files with 8469 additions and 0 deletions
45
commandes/change_nickname.py
Normal file
45
commandes/change_nickname.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
import re
|
||||
|
||||
class FormatAllNicknames(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(name="formatall", description="Force tous les pseudos au format 'Prénom Nom | Epic'")
|
||||
@app_commands.checks.has_permissions(manage_nicknames=True)
|
||||
async def format_all(self, interaction: discord.Interaction):
|
||||
await interaction.response.defer(thinking=True)
|
||||
guild = interaction.guild
|
||||
modified_count = 0
|
||||
|
||||
# Regex : deux mots avant le "|"
|
||||
pattern_correct = re.compile(r"^[^\|]+\s[^\|]+\s\| .+")
|
||||
|
||||
for member in guild.members:
|
||||
if member.bot:
|
||||
continue
|
||||
|
||||
current_nick = member.nick or member.name
|
||||
|
||||
# S'il respecte déjà le bon format ("Prénom Nom | Quelquechose"), on skip
|
||||
if pattern_correct.match(current_nick):
|
||||
continue
|
||||
|
||||
try:
|
||||
# Sinon, forcer à "Prénom Nom | Epic"
|
||||
new_nick = "Prénom Nom | Epic"
|
||||
|
||||
await member.edit(nick=new_nick)
|
||||
modified_count += 1
|
||||
|
||||
except discord.Forbidden:
|
||||
continue
|
||||
except discord.HTTPException:
|
||||
continue
|
||||
|
||||
await interaction.followup.send(f"✅ Renommage terminé : {modified_count} membres modifiés.")
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(FormatAllNicknames(bot))
|
||||
Loading…
Add table
Add a link
Reference in a new issue