Skip to content

Commit

Permalink
fix: Fixes sub perms
Browse files Browse the repository at this point in the history
  • Loading branch information
yagomichalak committed Aug 4, 2024
1 parent 73c4741 commit 15ebf83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cogs/slothsubscriber.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import discord
from discord.ext import commands
from discord.enums import EntitlementType

import os

sloth_subscriber_role_id = int(os.getenv("SLOTH_SUBSCRIBER_ROLE_ID", 123))
sloth_subscriber_sub_id = int(os.getenv("SLOTH_SUBSCRIBER_SUB_ID", 123))
on_sloth_sub_log_channel_id = int(os.getenv("ON_SLOTH_SUB_LOG_CHANNEL_ID", 123))
on_sloth_sub_log_channel_id = int(os.getenv("ON_SLOTH_SUB_CHANNEL_ID", 123))
server_id = int(os.getenv('SERVER_ID', 123))
guild_ids = [server_id]

Expand All @@ -25,7 +25,7 @@ async def on_entitlement_create(self, entitlement: discord.Entitlement) -> None:
""" Handles subscriptions to the Sloth Subscriber subscription.
:param entitlement: The entitlement/subscription. """

if entitlement.sku_id != sloth_subscriber_sub_id:
if not isinstance(entitlement.type, EntitlementType):
return

guild = self.client.get_guild(server_id)
Expand Down Expand Up @@ -60,7 +60,7 @@ async def on_entitlement_delete(self, entitlement: discord.Entitlement) -> None:
""" Handles subscriptions to the Sloth Subscriber subscription.
:param entitlement: The entitlement/subscription. """

if entitlement.sku_id != sloth_subscriber_sub_id:
if not isinstance(entitlement.type, EntitlementType):
return

guild = self.client.get_guild(server_id)
Expand Down
7 changes: 2 additions & 5 deletions extra/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import discord
from discord.enums import EntitlementType
from discord.ext import commands
from datetime import datetime
import aiohttp
Expand All @@ -12,9 +13,6 @@
from extra.customerrors import CommandNotReady, NotSubscribed
from collections import OrderedDict
import shlex
import os

sloth_subscriber_sub_id = int(os.getenv("SLOTH_SUBSCRIBER_SUB_ID", 123))

session = aiohttp.ClientSession()

Expand Down Expand Up @@ -86,8 +84,7 @@ async def real_check(ctx: Optional[commands.Context] = None, channel: Optional[d

entitlements = await member.entitlements().flatten()
for entitlement in entitlements:
print(entitlement.sku_id)
if int(entitlement.sku_id) == sloth_subscriber_sub_id:
if isinstance(entitlement.type, EntitlementType.application_subscription):
return True

if throw_exc:
Expand Down

0 comments on commit 15ebf83

Please sign in to comment.