Skip to content

Commit ebc94ef

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

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

snippets/snippets.code-snippets

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
]
232232
},
233233
"discord.py guild_only template": {
234-
"prefix": "!guild_only",
234+
"prefix": "!guildonly",
235235
"body": [
236236
"@commands.guild_only()",
237237
]
@@ -263,49 +263,49 @@
263263
"body": [
264264
"# Variable per page can be taken from the parameter command that you created",
265265
"emoji_nextpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$2\")",
266-
"emoji_backpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$4\")",
267-
"emoji_firstpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$5\")",
268-
"emoji_lastpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$6\")",
269-
"emoji_lock = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$7\")",
270-
"${8:formart_lb} = []",
271-
"for x in data:",
272-
" ${8:formart_lb}.append(\"$9\")",
273-
"num_of_${10:embeds} = ceil((len(${8:formart_lb}) + 1) / ${15|perpage,1,2,3,4,5,6,7,8,9,10|})",
274-
"${10:embeds} = []",
275-
"page_format = '(Page {}/{})'",
276-
"for i in range(1, num_of_${10:embeds} + 1):",
277-
" ${10:embeds}.append(discord.Embed($10).set_footer(text=page_format.format(i, num_of_${10:embeds})))",
278-
"${11:embed_index} = 0",
279-
"for index, element in enumerate(${10:formart_lb}):",
280-
" ${10:embeds}[${11:embed_index}].add_field(name=f'**{index + 1}.**', value='{}'.format(element), inline=${12|True,False|})",
281-
" if (index + 1) % ${15|perpage,1,2,3,4,5,6,7,8,9,10|} == 0:",
282-
" ${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",
283283
"buttons = [emoji_firstpage,emoji_backpage,emoji_lock,emoji_nextpage,emoji_lastpage]",
284284
"curent = 0",
285-
"msg = await ctx.send(embed=${10:embeds}[curent])",
285+
"msg = await ctx.send(embed=${9:embeds}[curent])",
286286
"for bt in buttons:",
287287
" try:",
288288
" await msg.add_reaction(bt)",
289289
" except:",
290290
" pass",
291291
"while True:",
292292
" 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|})",
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|})",
294294
" except asyncio.TimeoutError:",
295295
" for btn in buttons:",
296296
" try:",
297297
" await msg.clear_reaction(btn)",
298298
" except:",
299299
" pass",
300-
" else:",
300+
" else:",
301301
" previous_page = curent",
302302
" if reaction.emoji == buttons[0]:",
303303
" curent = 0",
304304
" try:",
305305
" await msg.remove_reaction(str(reaction.emoji), user)",
306306
" except:",
307307
" pass",
308-
" await msg.edit(embed=${10:embeds}[curent])",
308+
" await msg.edit(embed=${9:embeds}[curent])",
309309
" elif reaction.emoji == buttons[1]:",
310310
" if curent > 0:",
311311
" curent -= 1",
@@ -314,24 +314,24 @@
314314
" except:",
315315
" pass",
316316
" if curent != previous_page:",
317-
" await msg.edit(embed=${10:embeds}[curent])",
317+
" await msg.edit(embed=${9:embeds}[curent])",
318318
" elif reaction.emoji == buttons[3]:",
319-
" if curent < num_of_${10:embeds} - 1:",
319+
" if curent < num_of_${9:embeds} - 1:",
320320
" curent += 1",
321321
" try:",
322322
" await msg.remove_reaction(str(reaction.emoji), user)",
323323
" except:",
324324
" pass",
325325
" if curent != previous_page:",
326-
" await msg.edit(embed=${10:embeds}[curent])",
326+
" await msg.edit(embed=${9:embeds}[curent])",
327327
" elif reaction.emoji == buttons[4]:",
328-
" curent = num_of_${10:embeds} - 1",
328+
" curent = num_of_${9:embeds} - 1",
329329
" try:",
330330
" await msg.remove_reaction(str(reaction.emoji), user)",
331331
" except:",
332332
" pass",
333333
" if curent != previous_page:",
334-
" await msg.edit(embed=${10:embeds}[curent])",
334+
" await msg.edit(embed=${9:embeds}[curent])",
335335
" elif reaction.emoji == buttons[2]:",
336336
" await msg.remove_reaction(buttons[2], ctx.author)",
337337
" for btns in buttons:",

0 commit comments

Comments
 (0)