Skip to content

Commit 2da2a25

Browse files
authored
Version/1.3.0 (#20)
* refrag * refrag * updated dice rolls * refrag * added user infos
1 parent cfee08d commit 2da2a25

File tree

13 files changed

+152
-21
lines changed

13 files changed

+152
-21
lines changed

β€Žbot.pyβ€Ž

Lines changed: 152 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def _dict_factory(cursor, row):
115115
);
116116
''')
117117

118-
119118
cur.execute('''
120119
CREATE TABLE IF NOT EXISTS reactions (
121120
gid INTEGER NOT NULL,
@@ -285,6 +284,104 @@ async def xp_multiplier_adds(self, member_id, guild_id):
285284

286285
return xp_adds
287286

287+
async def info_get_embed(self, member):
288+
await self.check_member(member)
289+
embed = discord.Embed(title=member.display_name,
290+
description='',
291+
color=discord.Color.green())
292+
embed.set_thumbnail(url=member.avatar_url)
293+
data = await self.get_user(member)
294+
295+
embed.add_field(name='ID', value='{}'.format(data['uid']), inline=False)
296+
embed.add_field(name='Level', value='{:.2f}'.format(data['lvl']), inline=False)
297+
embed.add_field(name='XP Multiplier', value='{:.2f}'.format(data['xp_multiplier']), inline=False)
298+
299+
if data['joined'] < 0:
300+
embed.add_field(name='Last XP Update',
301+
value='None',
302+
inline=False)
303+
else:
304+
embed.add_field(name='Last XP Update',
305+
value='{}s ago'.format(int(time.time() - data['joined'])),
306+
inline=False)
307+
308+
embed.add_field(name='Blacklisted', value='{}'.format(bool(data['blacklist'])), inline=False)
309+
310+
boost_data = await self.boost_get_infos(member)
311+
312+
if boost_data['boosting'] is None:
313+
embed.add_field(name='Boosting',
314+
value='None',
315+
inline=False)
316+
else:
317+
embed.add_field(name='Boosting',
318+
value='*{}*, expires in **{}** days **{}** hours'
319+
.format(boost_data['boosting_name'],
320+
boost_data['boosting_remaining_days'],
321+
boost_data['boosting_remaining_hours']),
322+
inline=False)
323+
324+
def _get_value(arr):
325+
if len(arr) > 0:
326+
return '\n'.join(arr)
327+
return 'Empty'
328+
329+
embed.add_field(name='Boosts',
330+
value=_get_value(boost_data['boosts']),
331+
inline=False)
332+
333+
cur = self.db_conn.cursor()
334+
cur.execute('SELECT * FROM promo_boosts WHERE gid=? AND uid=?',
335+
(member.guild.id,
336+
member.id
337+
))
338+
promo = cur.fetchone()
339+
340+
if promo is None:
341+
embed.add_field(name='Promoted By',
342+
value='None',
343+
inline=False)
344+
else:
345+
promoted_by_name = 'A USER WHO LEFT'
346+
promoted_by_user = get(member.guild.members, id=promo['pid'])
347+
if promoted_by_user is not None:
348+
promoted_by_name = promoted_by_user.display_name
349+
embed.add_field(name='Promoted By',
350+
value='*{}*'.format(promoted_by_name),
351+
inline=False)
352+
353+
embed.add_field(name='Promo Boosts',
354+
value=_get_value(boost_data['promo_boosts']),
355+
inline=False)
356+
357+
def _format_date(date):
358+
if date is None:
359+
return 'None'
360+
return date.strftime("%d.%m.%Y %H:%M")
361+
362+
embed.add_field(name='Joined At',
363+
value='{}'.format(_format_date(member.joined_at)),
364+
inline=False)
365+
366+
embed.add_field(name='Boosting Server since',
367+
value='{}'.format(_format_date(member.premium_since)),
368+
inline=False)
369+
370+
hype_squad = None
371+
if member.public_flags.hypesquad_bravery:
372+
hype_squad = 'Brave'
373+
elif member.public_flags.hypesquad_brilliance:
374+
hype_squad = 'Brilliant'
375+
elif member.public_flags.hypesquad_balance:
376+
hype_squad = 'Balanced'
377+
378+
if hype_squad is not None:
379+
embed.add_field(name='Hype',
380+
value=hype_squad,
381+
inline=False)
382+
383+
return embed
384+
288385
async def add_msg_reaction(self, guild_id, msg_id, reaction, action_type, action):
289386
cur = self.db_conn.cursor()
290387
cur.execute('INSERT INTO msgreactions(gid, msgid, reaction, actiontype, action)'
@@ -437,7 +534,6 @@ async def use_promo_code(self, member, promo):
437534
if bool(data['blacklist']) is True:
438535
return False
439536

440-
441537
promo_lvl = await self.get_setting(member.guild.id, 'PROMO_USER_SET_LEVEL')
442538
if promo_lvl > data['lvl']:
443539
await self.member_set_lvl(member, promo_lvl, old_level=data['lvl'])
@@ -449,15 +545,12 @@ async def use_promo_code(self, member, promo):
449545

450546
return False
451547

452-
async def boost_get_embed(self, member):
548+
async def boost_get_infos(self, member):
453549
current_time = time.time()
454550

455551
boosting = await self.get_boost_user(member, current_time)
456552

457-
embed = discord.Embed(title='Boosts',
458-
description='You are currently boosting no one!\n'
459-
'Use **"boost {member}"** to start boosting!',
460-
color=discord.Color.gold())
553+
data = {'boosting': boosting}
461554

462555
id_names = {}
463556

@@ -481,33 +574,56 @@ def _get_days_hours(expires):
481574
if boosting is not None:
482575
member_name = _get_name(boosting['boostedid'])
483576

577+
data['boosting_name'] = member_name
578+
484579
boost_remaining_days, boost_remaining_hours = _get_days_hours(boosting['expires'])
485-
embed = discord.Embed(title='Boosts',
486-
description='You are boosting **{}**!\n'
487-
'Boost expires in **{}** days **{}** hours!'
488-
.format(member_name,
489-
boost_remaining_days,
490-
boost_remaining_hours),
491-
color=discord.Color.gold())
580+
581+
data['boosting_remaining_days'] = boost_remaining_days
582+
data['boosting_remaining_hours'] = boost_remaining_hours
492583

493584
def _boost_to_str(boost):
494585
brd, brh = _get_days_hours(boost['expires'])
495586
return 'By *{}* expires in **{}** days **{}** hours'.format(_get_name(boost['uid']), brd, brh)
496587

497588
boosted_by = await self.get_boosted_by(member, current_time)
498-
if len(boosted_by) > 0:
589+
590+
data['boosts'] = list(map(_boost_to_str, boosted_by))
591+
592+
promo_boosted_by = await self.get_promo_boosted_by(member, current_time)
593+
594+
data['promo_boosts'] = list(map(_boost_to_str, promo_boosted_by))
595+
596+
return data
597+
598+
async def boost_get_embed(self, member):
599+
data = await self.boost_get_infos(member)
600+
601+
embed = discord.Embed(title='Boosts',
602+
description='You are currently boosting no one!\n'
603+
'Use **"boost {member}"** to start boosting!',
604+
color=discord.Color.gold())
605+
606+
if data['boosting'] is not None:
607+
embed = discord.Embed(title='Boosts',
608+
description='You are boosting **{}**!\n'
609+
'Boost expires in **{}** days **{}** hours!'
610+
.format(data['boosting_name'],
611+
data['boosting_remaining_days'],
612+
data['boosting_remaining_hours']),
613+
color=discord.Color.gold())
614+
615+
if len(data['boosts']) > 0:
499616
embed.add_field(name='Your Boosts (x{})'
500617
.format(await self.get_setting(member.guild.id,
501618
'BOOST_ADD_XP_MULTIPLIER')),
502-
value='\n'.join(map(_boost_to_str, boosted_by)),
619+
value='\n'.join(data['boosts']),
503620
inline=False)
504621

505-
promo_boosted_by = await self.get_promo_boosted_by(member, current_time)
506-
if len(promo_boosted_by) > 0:
622+
if len(data['promo_boosts']) > 0:
507623
embed.add_field(name='Your Promo Boosts (x{})'
508624
.format(await self.get_setting(member.guild.id,
509625
'PROMO_BOOST_ADD_XP_MULTIPLIER')),
510-
value='\n'.join(map(_boost_to_str, promo_boosted_by)),
626+
value='\n'.join(data['promo_boosts']),
511627
inline=False)
512628
return embed
513629

@@ -1164,6 +1280,22 @@ async def _settings(self, ctx, *args):
11641280
'"settings set {key} {value}" to set a setting\n',
11651281
color=discord.Color.gold()))
11661282

1283+
@commands.command(name='info',
1284+
aliases=[],
1285+
description='user infos',
1286+
help=' - Lass dir Infos zu einem Benuter anzeigen')
1287+
async def _info(self, ctx, *args):
1288+
if len(args) == 0:
1289+
return await ctx.send(embed=await self.parent.info_get_embed(ctx.message.author))
1290+
search = ' '.join(args)
1291+
member = await self.parent.search_member(ctx, search)
1292+
if member is not None:
1293+
return await ctx.send(embed=await self.parent.info_get_embed(member))
1294+
return await ctx.send(embed=discord.Embed(title='',
1295+
description='User {} was not found!'
1296+
.format(search),
1297+
color=discord.Color.red()))
1298+
11671299
@commands.command(name='mreact',
11681300
aliases=[],
11691301
description='message reaction commands',
@@ -1514,7 +1646,7 @@ async def _coinflip(self, ctx, *args):
15141646
description='Roll a dice to your Witcher!',
15151647
help=' - WΓΌrfelt eine Zahl zwischen 1-6')
15161648
async def _dice(self, ctx, *args):
1517-
await ctx.send(file=discord.File(os.path.join('images', '{}.png'.format(random.randint(1, 6)))))
1649+
await ctx.send(file=discord.File(os.path.join('images', '{}.gif'.format(random.randint(1, 6)))))
15181650

15191651
@commands.command(name='random',
15201652
aliases=[],
@@ -1635,7 +1767,6 @@ async def on_raw_reaction_add(self, payload):
16351767
if payload.guild_id is not None and payload.member is not None and payload.member.bot is False:
16361768
await self.parent.msg_reaction_event(payload.member, payload.message_id, payload.emoji)
16371769

1638-
16391770
@commands.Cog.listener()
16401771
async def on_voice_state_update(self, member, before, after):
16411772
if member.bot:

β€Žimages/1.gifβ€Ž

116 KB
Loading

β€Žimages/1.pngβ€Ž

-6.73 KB
Binary file not shown.

β€Žimages/2.gifβ€Ž

140 KB
Loading

β€Žimages/2.pngβ€Ž

-6.63 KB
Binary file not shown.

β€Žimages/3.gifβ€Ž

155 KB
Loading

β€Žimages/3.pngβ€Ž

-8.33 KB
Binary file not shown.

β€Žimages/4.gifβ€Ž

169 KB
Loading

β€Žimages/4.pngβ€Ž

-9.57 KB
Binary file not shown.

β€Žimages/5.gifβ€Ž

199 KB
Loading

0 commit comments

Comments
Β (0)