Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from datetime import datetime
- from copy import deepcopy
- import emojis
- import asyncio
- import discord
- import math
- import random
- from discord.ext import commands, tasks
- from dateutil.relativedelta import relativedelta
- from utils.util import GetMessage
- from time import sleep
- import utils.mysql_help as conn
- import path
- import discord.utils
- from discord.utils import get
- from pygicord import Paginator
- from discord.ext import commands
- @commands.command(
- name='adminsell',
- #aliases =['a'],
- description="Sell resources to the admin shop",
- #usage='<code> [value]',
- )
- @commands.has_role("Server Player")
- @commands.has_permissions(send_messages=True)
- async def adminSell(self, ctx):
- pages = []
- guild_id = ctx.guild.id
- user = ctx.author
- channel = await user.create_dm()
- shopName = 'the admin shop'
- sql = "SELECT shop_name FROM shops WHERE shop_name_lower = '%s' AND guild_id = %s " % (shopName, guild_id)
- check = await conn.query(sql)
- shop_display_name = check[0][0]
- 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)
- allProducts = await conn.query(sql)
- j=0
- p=1
- list_length=len(allProducts)
- embed = discord.Embed(
- title=f"{shop_display_name}` will **Buy** the following products: (page {p} of {math.ceil(list_length/6)})",
- #description=f"{reason}",
- )
- for i in allProducts:
- product = i
- print(i)
- product_id = product[0]
- product_name = product[3]
- product_desc = product[4]
- product_price = product[6]
- if j > 5:
- p+=1
- j=0
- embed.set_thumbnail(url=ctx.guild.icon_url)
- pages.append(embed)
- #await channel.send(embed=embed)
- embed = discord.Embed(
- title=f"{shop_display_name}` will **Buy** the following products: (page {p} of {math.ceil(list_length/6)})",
- )
- embed.add_field(
- name=f"Product Id: **{product_id}**",
- value=f"**Product: *{product_name}***\nDescription: *{product_desc}*\nPrice: *{product_price}*\n --------------",
- inline=False
- )
- j+=1
- embed.set_thumbnail(url=ctx.guild.icon_url)
- pages.append(embed)
- #await channel.send(embed=embed)
- paginator = Paginator(pages=pages, has_input = False)
- await paginator.start(ctx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement