Skip to content

Commit 670a7bf

Browse files
authored
Merge pull request #11 from Ditttt/main
2 parents 1e2dee9 + ebc94ef commit 670a7bf

File tree

1 file changed

+72
-72
lines changed

1 file changed

+72
-72
lines changed

snippets/snippets.code-snippets

Lines changed: 72 additions & 72 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": "!guildonly",
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,90 +258,89 @@
253258
" $0"
254259
]
255260
},
256-
257261
"discord.py embed page reaction template": {
258262
"prefix": "!embpagere",
259263
"body": [
260264
"# Variable per page can be taken from the parameter command that you created",
261265
"emoji_nextpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$2\")",
262-
"emoji_backpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$4\")",
263-
"emoji_firstpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$5\")",
264-
"emoji_lastpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$6\")",
265-
"emoji_lock = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$7\")",
266-
"${8:formart_lb} = []",
267-
"for x in data:",
268-
" ${8:formart_lb}.append(\"$9\")",
269-
"num_of_${10:embeds} = ceil((len(${8:formart_lb}) + 1) / ${15|perpage,1,2,3,4,5,6,7,8,9,10|})",
270-
"${10:embeds} = []",
271-
"page_format = '(Page {}/{})'",
272-
"for i in range(1, num_of_${10:embeds} + 1):",
273-
" ${10:embeds}.append(discord.Embed($10).set_footer(text=page_format.format(i, num_of_${10:embeds})))",
274-
"${11:embed_index} = 0",
275-
"for index, element in enumerate(${10:formart_lb}):",
276-
" ${10:embeds}[${11:embed_index}].add_field(name=f'**{index + 1}.**', value='{}'.format(element), inline=${12|True,False|})",
277-
" if (index + 1) % ${15|perpage,1,2,3,4,5,6,7,8,9,10|} == 0:",
278-
" ${11:embed_index} += 1",
266+
"emoji_backpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$3\")",
267+
"emoji_firstpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$4\")",
268+
"emoji_lastpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$5\")",
269+
"emoji_lock = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$6\")",
270+
"${7:formart_lb} = []",
271+
"for x in data:",
272+
" ${7:formart_lb}.append(\"${8:this is for the embed description}\")",
273+
"num_of_${9:embeds} = ceil((len(${7:formart_lb}) + 1) / ${10|perpage,1,2,3,4,5,6,7,8,9,10|})",
274+
"${9:embeds} = []",
275+
"page_format = '(Page {}/{})'",
276+
"for i in range(1, num_of_${9:embeds} + 1):",
277+
" ${9:embeds}.append(discord.Embed(${11:\"this is for the description on each embed\"}).set_footer(text=page_format.format(i, num_of_${9:embeds})))",
278+
"${12:embed_index} = 0",
279+
"for ${13:index}, ${14:element} in enumerate(${7:formart_lb}):",
280+
" ${9:embeds}[${12:embed_index}].add_field(name=f'**{${13:index} + 1}.**', value='{}'.format(${14:element}), inline=${15|True,False|})",
281+
" if (${13:index} + 1) % ${10|perpage,1,2,3,4,5,6,7,8,9,10|} == 0:",
282+
" ${12:embed_index} += 1",
279283
"buttons = [emoji_firstpage,emoji_backpage,emoji_lock,emoji_nextpage,emoji_lastpage]",
280284
"curent = 0",
281-
"msg = await ctx.send(embed=${10:embeds}[curent])",
285+
"msg = await ctx.send(embed=${9:embeds}[curent])",
282286
"for bt in buttons:",
283287
" try:",
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:",
329-
" 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:",
291+
"while True:",
292+
" try:",
293+
" reaction, user = await ${1|bot,client,self.bot|}.wait_for('reaction_add', check=lambda r, u: ${16:u == ctx.author and r.message.channel.id == ctx.channel.id and r.emoji in buttons}, timeout=${17|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",
308+
" await msg.edit(embed=${9:embeds}[curent])",
309+
" elif reaction.emoji == buttons[1]:",
310+
" if curent > 0:",
311+
" curent -= 1",
333312
" try:",
334-
" await msg.clear_reaction(btns)",
313+
" await msg.remove_reaction(str(reaction.emoji), user)",
335314
" except:",
336315
" pass",
316+
" if curent != previous_page:",
317+
" await msg.edit(embed=${9:embeds}[curent])",
318+
" elif reaction.emoji == buttons[3]:",
319+
" if curent < num_of_${9: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=${9:embeds}[curent])",
327+
" elif reaction.emoji == buttons[4]:",
328+
" curent = num_of_${9:embeds} - 1",
329+
" try:",
330+
" await msg.remove_reaction(str(reaction.emoji), user)",
331+
" except:",
332+
" pass",
333+
" if curent != previous_page:",
334+
" await msg.edit(embed=${9: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)