Skip to content

Commit

Permalink
Merge pull request python-discord#1648 from python-discord/voice-veri…
Browse files Browse the repository at this point in the history
…fy-pings

Don't voice verify ping users who join a stage channel
  • Loading branch information
ChrisLovering authored Jun 21, 2021
2 parents e74c6bf + b6279c7 commit 7fc9b77
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 89 deletions.
4 changes: 4 additions & 0 deletions bot/exts/moderation/voice_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ async def on_voice_state_update(self, member: Member, before: VoiceState, after:
log.trace("User not in a voice channel. Ignore.")
return

if isinstance(after.channel, discord.StageChannel):
log.trace("User joined a stage channel. Ignore.")
return

# To avoid race conditions, checking if the user should receive a notification
# and sending it if appropriate is delegated to an atomic helper
notification_sent, message_channel = await self._ping_newcomer(member)
Expand Down
13 changes: 8 additions & 5 deletions bot/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,25 @@ def __init__(
suffix: str = '```',
max_size: int = 2000,
scale_to_size: int = 2000,
max_lines: t.Optional[int] = None
max_lines: t.Optional[int] = None,
linesep: str = "\n"
) -> None:
"""
This function overrides the Paginator.__init__ from inside discord.ext.commands.
It overrides in order to allow us to configure the maximum number of lines per page.
"""
self.prefix = prefix
self.suffix = suffix

# Embeds that exceed 2048 characters will result in an HTTPException
# (Discord API limit), so we've set a limit of 2000
if max_size > 2000:
raise ValueError(f"max_size must be <= 2,000 characters. ({max_size} > 2000)")

self.max_size = max_size - len(suffix)
super().__init__(
prefix,
suffix,
max_size - len(suffix),
linesep
)

if scale_to_size < max_size:
raise ValueError(f"scale_to_size must be >= max_size. ({scale_to_size} < {max_size})")
Expand Down
Loading

0 comments on commit 7fc9b77

Please sign in to comment.