async def me(self, ctx): d = dbu.DBUtils() dd = d.get_user_leveling(ctx.message.author) img = Image.open("image_tools/template.png") drow = ImageDraw.Draw(img) im2 = self.fetch_image_url( str(ctx.message.author.avatar_url_as(format='png')) + "?size=128x18") #await ctx.send(str(ctx.message.author.avatar_url_as(format='png')) + "?size=64x64") img.paste(im2, (53, 133)) font = ImageFont.truetype("image_tools/font.ttf", 25) desc_font = ImageFont.truetype("image_tools/desc_font.ttf", 20) user_desc = textwrap.fill(d.get_user_desc(ctx.message.author), width=17) drow.text((200, 245), ctx.message.author.name, font=font) drow.text((60, 300), 'level: ', font=font) drow.text((130, 300), str(dd['level']), font=font) drow.text((60, 350), 'xp: ', font=font) drow.text((100, 350), str(dd['xp']) + "/" + str(dd['level'] * 300), font=font) drow.text((60, 400), 'gold: ', font=font) drow.text((120, 400), str(dd['gold']), font=font) drow.text((280, 315), user_desc, font=desc_font) a = io.BytesIO() img.save(a, format='PNG') a.seek(0) f = discord.File(fp=a, filename="profile.png") await ctx.send(file=f)
async def profile_edit(self, ctx): func_list = ['description'] args = ctx.message.content.split(' ') if (len(args) == 1): await ctx.send( f':x: you need to provide functions! function list: `{" ".join(func_list)}`' ) return func = args[1] if (func not in func_list): await ctx.send( f':x: function {func} not found, function list: `{" ".join(func_list)}``' ) return elif func == 'description': if len(args) == 2: await ctx.send(':x: you must to provide desciprion') return db = dbu.DBUtils() c = ctx.message.content.split(' ') del c[0] del c[0] c = ' '.join(c) db.edit_desc(ctx.message.author, c) await ctx.send(f"i setted your profile description to `{c}`")
def __init__(self, tid): self.id = tid self.db = ub.DBUtils() db, cursor = self.db.connect() cursor.execute('SELECT * FROM `items` WHERE item_id = {}'.format( self.id)) self.dict = cursor.fetchall()[0] self.title = self.dict[1] self.cost = self.dict[2] self.power = self.dict[3]
async def top(self, ctx): db, cursor = dbu.DBUtils().connect() cursor.execute('SELECT * FROM user_leveling') db2 = cursor.fetchall() db3 = {} for i in db2: db3[i[0]] = i[3] raw = db3 board = sorted(raw.items(), key=lambda x: x[1], reverse=True)[:10] counter = 0 leaderboard = [] for x in board: user = self.bot.get_user(int(x[0])) if not user: continue coins = x[1] counter += 1 leveling = dbu.DBUtils().get_user_leveling(user) #Emojis Xp_bottle = discord.utils.get(self.bot.emojis, name='Xp_bottle') Xp = discord.utils.get(self.bot.emojis, name='Xp') gold = discord.utils.get(self.bot.emojis, name='Gold_Nugget') user_xp = f"{str(leveling['xp'])}/ {str(leveling['level'] * 300)}" user_lvl = str(leveling['level']) leaderboard.append( f'`{counter}` | **{user}** :: `{coins}` {str(gold)}, {str(Xp_bottle)} `{user_lvl}`, {str(Xp)} `{user_xp}`' ) e = discord.Embed() e.description = '\n'.join(leaderboard) e.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) e.set_footer(text=ctx.prefix + ctx.command.qualified_name, icon_url=ctx.guild.me.avatar_url) e.color = ctx.guild.me.color db.disconnect() await ctx.send(embed=e)
def __init__(self, ctx, atacker, defender, max_hp=100000): self.ctx = ctx self.bot = self.ctx.bot self.aid = atacker self.did = defender self.colors = [ discord.Colour.teal(), discord.Colour.blue(), discord.Colour.orange(), discord.Colour.green(), discord.Colour.red(), discord.Colour.magenta() ] self.db = database.DBUtils() self.hp = {}
def __init__(self, bot): self.bot = bot self.database = database.DBUtils()
def __init__(self, bot): self.bot = bot self.d = dbu.DBUtils()
async def shop(self, ctx): db = dbu.DBUtils() res = db.get_shop_list() embed = discord.Embed(title='shop', description='\n'.join(res)) embed.color = 0x1abcc4 await ctx.message.channel.send(embed=embed)
def __init__(self): self.db = dbu.DBUtils()
def setup(bot): bot.db = database.DBUtils() bot.add_cog(Admin(bot))
def __init__(self, bot): self.bot = bot self.db = ub.DBUtils() self.u = ii.util(self.bot) self.client = api.Client(None) self.utils = ii.util(self.bot)