removed @everyone unnecessary thing

This commit is contained in:
esef committed 2026-07-05 20:37:41 +03:00
1 parent 12275fdb2c
commit 64ccb125ee
1 file changed
+13 -6
+13 -6
View File
@@ -29,7 +29,9 @@ from discord.ext import commands
# ── constants ──────────────────────────────────────────────────────────────── # ── constants ────────────────────────────────────────────────────────────────
ROLE_TAG = "" # Invisible Unicode sentinel appended to every managed role name.
# Users never see it; we use it to identify roles this bot created.
ROLE_TAG = "\u2060" # WORD JOINER — zero-width, invisible in Discord
TIMEOUT = 120 # seconds per DM question TIMEOUT = 120 # seconds per DM question
COLOR_PRESETS: dict[str, int] = { COLOR_PRESETS: dict[str, int] = {
@@ -92,10 +94,15 @@ class RoleWizardView(discord.ui.View):
self, interaction: discord.Interaction, button: discord.ui.Button self, interaction: discord.Interaction, button: discord.ui.Button
): ):
member: discord.Member = interaction.user # type: ignore member: discord.Member = interaction.user # type: ignore
guild = interaction.guild
# Acknowledge the interaction immediately so Discord doesn't show an error # Acknowledge the interaction immediately so Discord doesn't show an error
await interaction.response.defer(ephemeral=True) await interaction.response.defer(ephemeral=True)
if guild is None:
await interaction.followup.send("this only works inside a server.", ephemeral=True)
return
if member.id in self.cog._active: if member.id in self.cog._active:
await interaction.followup.send( await interaction.followup.send(
"you already have a wizard open, check your DMs.", ephemeral=True "you already have a wizard open, check your DMs.", ephemeral=True
@@ -103,7 +110,7 @@ class RoleWizardView(discord.ui.View):
return return
# Start wizard as a background task # Start wizard as a background task
self.cog.bot.loop.create_task(self.cog._wizard(member, interaction.guild)) asyncio.create_task(self.cog._wizard(member, guild))
# ── cog ────────────────────────────────────────────────────────────────────── # ── cog ──────────────────────────────────────────────────────────────────────
@@ -178,7 +185,7 @@ class Roles(commands.Cog):
return return
def dm_check(m: discord.Message) -> bool: def dm_check(m: discord.Message) -> bool:
return m.author.id == member.id and isinstance(m.channel, discord.DMChannel) return m.author.id == member.id and m.channel.id == dm.id
async def ask(prompt: str) -> str | None: async def ask(prompt: str) -> str | None:
"""Send a DM prompt and return the stripped reply, or None on timeout/cancel.""" """Send a DM prompt and return the stripped reply, or None on timeout/cancel."""
@@ -198,7 +205,7 @@ class Roles(commands.Cog):
existing = _find_managed_role(member) existing = _find_managed_role(member)
if existing: if existing:
raw_existing_name = existing.name.replace(ROLE_TAG + " ", "") raw_existing_name = existing.name.replace(ROLE_TAG, "").strip()
reply = await ask( reply = await ask(
f"hey, you already have a role called \"{raw_existing_name}\". " f"hey, you already have a role called \"{raw_existing_name}\". "
f"do you want to change it? say yes or no." f"do you want to change it? say yes or no."
@@ -252,7 +259,7 @@ class Roles(commands.Cog):
hoisted = hoist_reply.lower() in ("yes", "y") hoisted = hoist_reply.lower() in ("yes", "y")
# ── apply ───────────────────────────────────────────────────────────── # ── apply ─────────────────────────────────────────────────────────────
full_name = f"{ROLE_TAG} {name_raw}" full_name = f"{name_raw}{ROLE_TAG}" # sentinel is appended, invisible to users
colour_obj = discord.Colour(colour_int) colour_obj = discord.Colour(colour_int)
try: try:
@@ -273,7 +280,7 @@ class Roles(commands.Cog):
reason=f"custom decorative role for {member}", reason=f"custom decorative role for {member}",
) )
# Place just above @everyone # Place just above @everyone
await guild.edit_role_positions({role: 1}) await guild.edit_role_positions([(role, 1)])
await member.add_roles(role, reason="custom decorative role") await member.add_roles(role, reason="custom decorative role")
except discord.Forbidden: except discord.Forbidden: