-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.py
56 lines (43 loc) · 1.43 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from enum import IntEnum
import config
from dbots.cmd import Check
__all__ = (
"PremiumLevel",
"premium_required",
"entitlement_required",
"PREMIUM_REQUIRED_TEXT",
"can_upsell"
)
PREMIUM_REQUIRED_TEXT = "You **need** to buy **Xenon Premium** to be able to use this bot and its commands.\n\n" \
"You can **buy Premium [here](<https://patreon.com/merlinfuchs>)** and " \
"get a full list of features [here](<https://wiki.xenon.bot/premium>).\n\n\n" \
"*If you have already bought Xenon Premium please click " \
"[here](<https://wiki.xenon.bot/premium#redeem-perks>)*."
class PremiumLevel(IntEnum):
NONE = 0
ONE = 1
TWO = 2
THREE = 3
def can_upsell(ctx):
return config.CAN_UPSELL and ctx.entitlement_sku_ids is not None
@Check
async def premium_required(ctx, **_):
if ctx.premium_level == PremiumLevel.NONE:
await ctx.respond(
content=PREMIUM_REQUIRED_TEXT,
ephemeral=True
)
return False
return True
@Check
async def entitlement_required(ctx, **_):
if not ctx.entitlement_sku_ids and ctx.premium_level == PremiumLevel.NONE:
if can_upsell(ctx):
await ctx.upsell()
else:
await ctx.respond(
content=PREMIUM_REQUIRED_TEXT,
ephemeral=True
)
return False
return True