Skip to content

Commit

Permalink
Only ratelimit non-ephemeral messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBSG committed Jun 24, 2024
1 parent 17e39d1 commit 1c7a1c7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions modules/social.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,6 @@ async def _profile(self, interaction: discord.Interaction, member: typing.Option
await self._profile_view(interaction, member)

async def _profile_view(self, interaction: discord.Interaction, member: discord.Member):
# If channel can be ratelimited
if interaction.channel.id not in [config.commandsChannel, config.debugChannel]:
channel_being_rate_limited = not self.profile_bucket.consume(str(interaction.channel.id))
if channel_being_rate_limited:
# Moderators consume a ratelimit token but are not limited
if not interaction.guild.get_role(config.moderator) in interaction.user.roles:
await interaction.response.send_message(
f'{config.redTick} That command is being used too often, try again in a few seconds.',
ephemeral=True,
)
return

db = mclient.bowser.users
dbUser = db.find_one({'_id': member.id})

Expand All @@ -218,6 +206,18 @@ async def _profile_view(self, interaction: discord.Interaction, member: discord.
)

else:
# If channel can be ratelimited
if interaction.channel.id not in [config.commandsChannel, config.debugChannel]:
channel_being_rate_limited = not self.profile_bucket.consume(str(interaction.channel.id))
if channel_being_rate_limited:
# Moderators consume a ratelimit token but are not limited
if not interaction.guild.get_role(config.moderator) in interaction.user.roles:
await interaction.response.send_message(
f'{config.redTick} That command is being used too often, try again in a few seconds.',
ephemeral=True,
)
return

await interaction.response.defer()
card = await self._generate_profile_card_from_member(member)
await interaction.followup.send(file=card)
Expand Down

0 comments on commit 1c7a1c7

Please sign in to comment.