Skip to content

Commit 0517ad8

Browse files
committed
added the guildonly template and fixed a bug in the embpagere template
1 parent 1e2dee9 commit 0517ad8

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

snippets/snippets.code-snippets

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@
230230
"@commands.has_permissions(${1:permission_name}=True)"
231231
]
232232
},
233+
"discord.py guild_only template": {
234+
"prefix": "!guild_only",
235+
"body": [
236+
"@commands.guild_only()",
237+
]
238+
},
233239
"discord.py wait_for template for on_reaction_add": {
234240
"prefix": "!waitforreaction",
235241
"body": [
@@ -241,7 +247,6 @@
241247
" $0"
242248
]
243249
},
244-
245250
"discord.py wait_for template for on_message": {
246251
"prefix": "!waitformessage",
247252
"body": [
@@ -253,7 +258,6 @@
253258
" $0"
254259
]
255260
},
256-
257261
"discord.py embed page reaction template": {
258262
"prefix": "!embpagere",
259263
"body": [
@@ -284,59 +288,59 @@
284288
" await msg.add_reaction(bt)",
285289
" except:",
286290
" pass",
287-
"try:",
288-
" reaction, user = await ${1|bot,client,self.bot|}.wait_for('reaction_add', check=lambda r, u: ${13:u == ctx.author and r.message.channel.id == ctx.channel.id and and r.emoji in buttons}, timeout=${14|15,30,45,60,120,300,900|})",
289-
"except asyncio.TimeoutError:",
290-
" for btn in buttons:",
291-
" try:",
292-
" await msg.clear_reaction(btn)",
293-
" except:",
294-
" pass",
295-
"else:",
296-
" previous_page = curent",
297-
" if reaction.emoji == buttons[0]:",
298-
" curent = 0",
299-
" try:",
300-
" await msg.remove_reaction(str(reaction.emoji), user)",
301-
" except:",
302-
" pass",
303-
" await msg.edit(embed=${10:embeds}[curent])",
304-
" elif reaction.emoji == buttons[1]:",
305-
" if curent > 0:",
306-
" curent -= 1",
307-
" try:",
308-
" await msg.remove_reaction(str(reaction.emoji), user)",
309-
" except:",
310-
" pass",
311-
" if curent != previous_page:",
312-
" await msg.edit(embed=${10:embeds}[curent])",
313-
" elif reaction.emoji == buttons[3]:",
314-
" if curent < num_of_${10:embeds} - 1:",
315-
" curent += 1",
316-
" try:",
317-
" await msg.remove_reaction(str(reaction.emoji), user)",
318-
" except:",
319-
" pass",
320-
" if curent != previous_page:",
321-
" await msg.edit(embed=${10:embeds}[curent])",
322-
" elif reaction.emoji == buttons[4]:",
323-
" curent = num_of_${10:embeds} - 1",
324-
" try:",
325-
" await msg.remove_reaction(str(reaction.emoji), user)",
326-
" except:",
327-
" pass",
328-
" if curent != previous_page:",
291+
"while True:",
292+
" try:",
293+
" reaction, user = await ${1|bot,client,self.bot|}.wait_for('reaction_add', check=lambda r, u: ${13:u == ctx.author and r.message.channel.id == ctx.channel.id and and r.emoji in buttons}, timeout=${14|15,30,45,60,120,300,900|})",
294+
" except asyncio.TimeoutError:",
295+
" for btn in buttons:",
296+
" try:",
297+
" await msg.clear_reaction(btn)",
298+
" except:",
299+
" pass",
300+
" else:",
301+
" previous_page = curent",
302+
" if reaction.emoji == buttons[0]:",
303+
" curent = 0",
304+
" try:",
305+
" await msg.remove_reaction(str(reaction.emoji), user)",
306+
" except:",
307+
" pass",
329308
" await msg.edit(embed=${10:embeds}[curent])",
330-
" elif reaction.emoji == buttons[2]:",
331-
" await msg.remove_reaction(buttons[2], ctx.author)",
332-
" for btns in buttons:",
309+
" elif reaction.emoji == buttons[1]:",
310+
" if curent > 0:",
311+
" curent -= 1",
312+
" try:",
313+
" await msg.remove_reaction(str(reaction.emoji), user)",
314+
" except:",
315+
" pass",
316+
" if curent != previous_page:",
317+
" await msg.edit(embed=${10:embeds}[curent])",
318+
" elif reaction.emoji == buttons[3]:",
319+
" if curent < num_of_${10:embeds} - 1:",
320+
" curent += 1",
321+
" try:",
322+
" await msg.remove_reaction(str(reaction.emoji), user)",
323+
" except:",
324+
" pass",
325+
" if curent != previous_page:",
326+
" await msg.edit(embed=${10:embeds}[curent])",
327+
" elif reaction.emoji == buttons[4]:",
328+
" curent = num_of_${10:embeds} - 1",
333329
" try:",
334-
" await msg.clear_reaction(btns)",
330+
" await msg.remove_reaction(str(reaction.emoji), user)",
335331
" except:",
336332
" pass",
333+
" if curent != previous_page:",
334+
" await msg.edit(embed=${10:embeds}[curent])",
335+
" elif reaction.emoji == buttons[2]:",
336+
" await msg.remove_reaction(buttons[2], ctx.author)",
337+
" for btns in buttons:",
338+
" try:",
339+
" await msg.clear_reaction(btns)",
340+
" except:",
341+
" pass",
337342
]
338343
},
339-
340344
"discord.py Exception":{
341345
"prefix": "!except",
342346
"body": [
@@ -347,7 +351,6 @@
347351
],
348352
"description": "Add a basic exception."
349353
},
350-
351354
"discord.py UI Button":{
352355
"prefix": "!button",
353356
"body": [
@@ -358,8 +361,6 @@
358361
],
359362
"description": "Add a basic button."
360363
},
361-
362-
363364
"discord.py Custom UI Button":{
364365
"prefix": "!cbutton",
365366
"body": [
@@ -378,7 +379,6 @@
378379
],
379380
"description": "Add a button with a custom constructor.."
380381
},
381-
382382
"discord.py UI Select":{
383383
"prefix": "!select",
384384
"body": [

0 commit comments

Comments
 (0)