Advertisement
Tranquility3

Adminsell

Mar 23rd, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1.  
  2.  
  3.  
  4. import re
  5. from datetime import datetime
  6. from copy import deepcopy
  7. import emojis
  8. import asyncio
  9. import discord
  10. import math
  11. import random
  12. from discord.ext import commands, tasks
  13. from dateutil.relativedelta import relativedelta
  14. from utils.util import GetMessage
  15. from time import sleep
  16. import utils.mysql_help as conn
  17. import path
  18. import discord.utils
  19. from discord.utils import get
  20. from pygicord import Paginator
  21. from discord.ext import commands
  22.  
  23. @commands.command(
  24. name='adminsell',
  25. #aliases =['a'],
  26. description="Sell resources to the admin shop",
  27. #usage='<code> [value]',
  28. )
  29. @commands.has_role("Server Player")
  30. @commands.has_permissions(send_messages=True)
  31. async def adminSell(self, ctx):
  32.  
  33.  
  34. pages = []
  35. guild_id = ctx.guild.id
  36. user = ctx.author
  37. channel = await user.create_dm()
  38. shopName = 'the admin shop'
  39.  
  40. sql = "SELECT shop_name FROM shops WHERE shop_name_lower = '%s' AND guild_id = %s " % (shopName, guild_id)
  41. check = await conn.query(sql)
  42. shop_display_name = check[0][0]
  43.  
  44. sql = "SELECT * FROM shop_product WHERE shop_name_lower = '%s' AND guild_id = %s AND type = 'Sell' OR type = 'Sell and Buy'" % (shopName, guild_id)
  45. allProducts = await conn.query(sql)
  46.  
  47. j=0
  48. p=1
  49. list_length=len(allProducts)
  50. embed = discord.Embed(
  51. title=f"{shop_display_name}` will **Buy** the following products: (page {p} of {math.ceil(list_length/6)})",
  52. #description=f"{reason}",
  53. )
  54. for i in allProducts:
  55.  
  56. product = i
  57.  
  58. print(i)
  59.  
  60. product_id = product[0]
  61.  
  62. product_name = product[3]
  63. product_desc = product[4]
  64. product_price = product[6]
  65.  
  66. if j > 5:
  67. p+=1
  68.  
  69. j=0
  70. embed.set_thumbnail(url=ctx.guild.icon_url)
  71. pages.append(embed)
  72. #await channel.send(embed=embed)
  73. embed = discord.Embed(
  74. title=f"{shop_display_name}` will **Buy** the following products: (page {p} of {math.ceil(list_length/6)})",
  75. )
  76.  
  77.  
  78. embed.add_field(
  79. name=f"Product Id: **{product_id}**",
  80. value=f"**Product: *{product_name}***\nDescription: *{product_desc}*\nPrice: *{product_price}*\n --------------",
  81. inline=False
  82. )
  83.  
  84.  
  85. j+=1
  86.  
  87. embed.set_thumbnail(url=ctx.guild.icon_url)
  88. pages.append(embed)
  89. #await channel.send(embed=embed)
  90.  
  91. paginator = Paginator(pages=pages, has_input = False)
  92. await paginator.start(ctx)
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement