Skip to content

Commit cf3a42d

Browse files
committed
Add arbitrary perms to cmds
1 parent b001858 commit cf3a42d

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

modules/genius/genius.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
component_callback,
55
slash_command,
66
slash_option,
7+
slash_permission
78
)
89
from dis_snek.models.context import InteractionContext
910
from dis_snek.models.discord_objects.embed import EmbedAttachment, EmbedField
@@ -18,6 +19,7 @@
1819
from storage.genius import Genius
1920
from utils.config import GUILD, PARTICIPANT_ROLE, MAX_TICKETS, ADMIN_ROLE
2021
from utils.embeds import GENIUS_BAR
22+
from utils.perms import NOT_EVERYBODY, ADMIN_ONLY, BOT_DEV_ONLY
2123

2224

2325
class GeniusBar(Scale):
@@ -35,14 +37,14 @@ async def on_ready(self):
3537

3638

3739
@slash_command(
38-
name="genius",
39-
sub_cmd_name="setup",
40-
sub_cmd_description="Setup the Genius Bar in a text channel")
40+
name="genius_setup",
41+
description="Setup the Genius Bar in a text channel")
4142
@slash_option(
4243
"channel",
4344
"ChannelID of channel to set up Genius Bar",
4445
OptionTypes.CHANNEL,
4546
required=True)
47+
@slash_permission(NOT_EVERYBODY, BOT_DEV_ONLY)
4648
async def genius_setup(self, ctx: InteractionContext, channel):
4749
await ctx.defer()
4850

@@ -60,9 +62,9 @@ async def genius_setup(self, ctx: InteractionContext, channel):
6062

6163

6264
@slash_command(
63-
name="genius",
64-
sub_cmd_name="kill",
65-
sub_cmd_description="Kill all occupied and currently queued tickets")
65+
name="genius_kill",
66+
description="Kill all occupied and currently queued tickets")
67+
@slash_permission(NOT_EVERYBODY, BOT_DEV_ONLY)
6668
async def genius_kill(self, ctx):
6769
await ctx.defer()
6870

modules/nerfgun/nerfgun.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
component_callback,
77
slash_command,
88
slash_option,
9+
slash_permission
910
)
1011
from dis_snek.models.context import InteractionContext
1112
from dis_snek.models.discord_objects.channel import GuildText
@@ -14,8 +15,10 @@
1415
from dis_snek.models.enums import ButtonStyles
1516

1617
from storage.nerf import Nerf
18+
from utils.config import BOT_DEV_ROLE
1719

1820
from utils.embeds import NERF_GUN
21+
from utils.perms import ADMIN_ONLY, BOT_DEV_ONLY, NOT_EVERYBODY
1922

2023

2124
class Nerfgun(Scale):
@@ -32,9 +35,8 @@ async def on_ready(self):
3235
await self._update_leaderboard()
3336

3437
@slash_command(
35-
name="nerf",
36-
sub_cmd_name="setup",
37-
sub_cmd_description="Setup the Nerf Gun queue in a specified text channel"
38+
name="nerf_setup",
39+
description="Setup the Nerf Gun queue in a specified text channel"
3840
)
3941
@slash_option(
4042
"queuechannel",
@@ -48,6 +50,7 @@ async def on_ready(self):
4850
OptionTypes.CHANNEL,
4951
required=True,
5052
)
53+
@slash_permission(NOT_EVERYBODY, BOT_DEV_ONLY)
5154
async def nerf_setup(self, ctx: InteractionContext, queuechannel, boardchannel):
5255
await ctx.defer()
5356

@@ -100,10 +103,10 @@ async def _setup_leaderboard_channel(self, boardchannel):
100103
self.nerf.set_leaderboard_message(leaderboard_msg)
101104

102105
@slash_command(
103-
name="nerf",
104-
sub_cmd_name="next",
105-
sub_cmd_description="Call up the next individual in the queue"
106+
name="nerf_next",
107+
description="Call up the next individual in the queue"
106108
)
109+
@slash_permission(NOT_EVERYBODY, ADMIN_ONLY)
107110
async def nerf_next(self, ctx: InteractionContext):
108111
if self.nerf.queue_is_empty():
109112
await ctx.send("Queue currently empty!")
@@ -167,9 +170,8 @@ async def _update_queue(self):
167170
await self.nerf.queue_msg.edit(text)
168171

169172
@slash_command(
170-
name="nerf",
171-
sub_cmd_name="score",
172-
sub_cmd_description="Score a player"
173+
name="nerf_score",
174+
description="Score a player"
173175
)
174176
@slash_option(
175177
"score",
@@ -183,6 +185,7 @@ async def _update_queue(self):
183185
OptionTypes.USER,
184186
required=False
185187
)
188+
@slash_permission(NOT_EVERYBODY, ADMIN_ONLY)
186189
async def nerf_score(self, ctx: InteractionContext, score, player = None):
187190
await ctx.defer()
188191

utils/perms.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from dis_snek.models.application_commands import Permission
2+
from utils.config import BOT_DEV_ROLE, ADMIN_ROLE, PARTICIPANT_ROLE, GUILD
3+
4+
NOT_EVERYBODY = Permission(
5+
id=PARTICIPANT_ROLE,
6+
guild_id=GUILD,
7+
type=1,
8+
permission=False
9+
)
10+
11+
ADMIN_ONLY = Permission(
12+
id=ADMIN_ROLE,
13+
guild_id=GUILD,
14+
type=1,
15+
permission=True
16+
17+
)
18+
19+
BOT_DEV_ONLY = Permission(
20+
id=BOT_DEV_ROLE,
21+
guild_id=GUILD,
22+
type=1,
23+
permission=True
24+
)

0 commit comments

Comments
 (0)