Skip to content

Commit

Permalink
Merge pull request #50 from ltzmax/main
Browse files Browse the repository at this point in the history
[RoleUtils] Fix `Must be 2000 or fewer in length.`
  • Loading branch information
japandotorg authored May 23, 2024
2 parents 598c237 + bbead93 commit d69988c
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions roleutils/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from redbot.core.utils.chat_formatting import humanize_number as hn
from redbot.core.utils.chat_formatting import pagify, text_to_file
from redbot.core.utils.mod import get_audit_reason
from redbot.core.utils.views import SimpleMenu
from TagScriptEngine import Interpreter, LooseVariableGetterBlock, MemberAdapter

from .abc import CompositeMetaClass, MixinMeta
Expand Down Expand Up @@ -279,6 +280,7 @@ async def role_remove(
async def addmulti(self, ctx: commands.Context, role: StrictRole, *members: TouchableMember):
"""Add a role to multiple members."""
reason = get_audit_reason(ctx.author)
pages = []
already_members = []
success_members = []
for member in members:
Expand All @@ -292,7 +294,19 @@ async def addmulti(self, ctx: commands.Context, role: StrictRole, *members: Touc
msg.append(f"Added **{role}** to {humanize_roles(success_members)}.")
if already_members:
msg.append(f"{humanize_roles(already_members)} already had **{role}**.")
await ctx.send("\n".join(msg))

# Define the number of lines per page
lines_per_page = 10
# Split the msg list into chunks of lines_per_page
msg_chunks = [msg[i:i + lines_per_page] for i in range(0, len(msg), lines_per_page)]
# Add each chunk to the pages list
for chunk in msg_chunks:
pages.append('\n'.join(chunk))
await SimpleMenu(
pages,
disable_after_timeout=True,
timeout=120,
).start(ctx)

@commands.has_guild_permissions(manage_roles=True)
@commands.bot_has_permissions(manage_roles=True)
Expand All @@ -302,6 +316,7 @@ async def removemulti(
):
"""Remove a role from multiple members."""
reason = get_audit_reason(ctx.author)
pages = []
already_members = []
success_members = []
for member in members:
Expand All @@ -315,7 +330,20 @@ async def removemulti(
msg.append(f"Removed **{role}** from {humanize_roles(success_members)}.")
if already_members:
msg.append(f"{humanize_roles(already_members)} didn't have **{role}**.")
await ctx.send("\n".join(msg))

# Define the number of lines per page
lines_per_page = 10
# Split the msg list into chunks of lines_per_page
msg_chunks = [msg[i:i + lines_per_page] for i in range(0, len(msg), lines_per_page)]
# Add each chunk to the pages list
for chunk in msg_chunks:
pages.append('\n'.join(chunk))

await SimpleMenu(
pages,
disable_after_timeout=True,
timeout=120,
).start(ctx)

@commands.has_guild_permissions(manage_roles=True)
@commands.bot_has_permissions(manage_roles=True)
Expand Down

0 comments on commit d69988c

Please sign in to comment.