|
230 | 230 | "@commands.has_permissions(${1:permission_name}=True)" |
231 | 231 | ] |
232 | 232 | }, |
| 233 | + "discord.py guild_only template": { |
| 234 | + "prefix": "!guildonly", |
| 235 | + "body": [ |
| 236 | + "@commands.guild_only()", |
| 237 | + ] |
| 238 | + }, |
233 | 239 | "discord.py wait_for template for on_reaction_add": { |
234 | 240 | "prefix": "!waitforreaction", |
235 | 241 | "body": [ |
|
241 | 247 | " $0" |
242 | 248 | ] |
243 | 249 | }, |
244 | | - |
245 | 250 | "discord.py wait_for template for on_message": { |
246 | 251 | "prefix": "!waitformessage", |
247 | 252 | "body": [ |
|
253 | 258 | " $0" |
254 | 259 | ] |
255 | 260 | }, |
256 | | - |
257 | 261 | "discord.py embed page reaction template": { |
258 | 262 | "prefix": "!embpagere", |
259 | 263 | "body": [ |
260 | 264 | "# Variable per page can be taken from the parameter command that you created", |
261 | 265 | "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", |
279 | 283 | "buttons = [emoji_firstpage,emoji_backpage,emoji_lock,emoji_nextpage,emoji_lastpage]", |
280 | 284 | "curent = 0", |
281 | | - "msg = await ctx.send(embed=${10:embeds}[curent])", |
| 285 | + "msg = await ctx.send(embed=${9:embeds}[curent])", |
282 | 286 | "for bt in buttons:", |
283 | 287 | " try:", |
284 | 288 | " await msg.add_reaction(bt)", |
285 | 289 | " except:", |
286 | 290 | " 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", |
333 | 312 | " try:", |
334 | | - " await msg.clear_reaction(btns)", |
| 313 | + " await msg.remove_reaction(str(reaction.emoji), user)", |
335 | 314 | " except:", |
336 | 315 | " 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", |
337 | 342 | ] |
338 | 343 | }, |
339 | | - |
340 | 344 | "discord.py Exception":{ |
341 | 345 | "prefix": "!except", |
342 | 346 | "body": [ |
|
347 | 351 | ], |
348 | 352 | "description": "Add a basic exception." |
349 | 353 | }, |
350 | | - |
351 | 354 | "discord.py UI Button":{ |
352 | 355 | "prefix": "!button", |
353 | 356 | "body": [ |
|
358 | 361 | ], |
359 | 362 | "description": "Add a basic button." |
360 | 363 | }, |
361 | | - |
362 | | - |
363 | 364 | "discord.py Custom UI Button":{ |
364 | 365 | "prefix": "!cbutton", |
365 | 366 | "body": [ |
|
378 | 379 | ], |
379 | 380 | "description": "Add a button with a custom constructor.." |
380 | 381 | }, |
381 | | - |
382 | 382 | "discord.py UI Select":{ |
383 | 383 | "prefix": "!select", |
384 | 384 | "body": [ |
|
0 commit comments