Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[(f'guilds.{message.guild.id}', pymongo.DESCENDING)]).limit(10).to_list(None)
user_list = []
list_headers = ['Username', currency]
for kud_item in kud_list:
usr = discord.utils.find(lambda x: x.id == kud_item['UserID'], cmd.bot.get_all_members())
if usr:
usr_name = usr.name
else:
usr_name = '{Unknown User}'
if len(usr_name) > 32:
usr_name = usr_name[:29] + '...'
if key_look:
user_list.append([usr_name, kud_item[key_look]])
else:
user_list.append([usr_name, kud_item['guilds'][str(message.guild.id)]])
lb_table = boop(user_list, list_headers)
strip_clr = await get_image_colors(message.guild.icon_url)
response = discord.Embed(color=strip_clr)
if not key_look:
response.set_author(name=message.guild.name, icon_url=message.guild.icon_url)
response.add_field(name='Kud Criteria', value=title, inline=False)
response.add_field(name='User List', value=f'```bat\n{lb_table}\n```', inline=False)
await message.channel.send(embed=response)
"""
response = discord.Embed(color=0x1ABC9C)
games, online, playing = make_games_dict(pld.msg.guild)
sorted_games = sorted(games.items(), key=operator.itemgetter(1), reverse=True)
page = pld.args[0] if pld.args else 1
game_list, page = PaginatorCore.paginate(sorted_games, page)
start_range = (page - 1) * 10
out_table_list = []
game_count = len(sorted_games)
index = start_range
for key, value in game_list:
index += 1
if len(key) > 32:
key = key[:32] + '...'
out_table_list.append([str(index), key, value, str(value / playing * 100).split('.')[0] + '%'])
output = boop(out_table_list)
general_stats_list = [['Online', online], ['In-Game', playing], ['Unique Games', game_count]]
out_block = f'```hs\n{boop(general_stats_list)}\n```'
response.add_field(name='👾 Current Gaming Statistics on ' + pld.msg.guild.name, value=out_block, inline=False)
response.add_field(name=f'🎮 By Game on Page {page}', value=f'```haskell\n{output}\n```', inline=False)
await pld.msg.channel.send(embed=response)
if not leader_docs or leader_timer + 180 < now:
coll = cmd.db[cmd.db.db_nam][f'{resource.title()}Resource']
search = {'$and': [{sort_key: {'$exists': True}}, {sort_key: {'$gt': 0}}]}
all_docs = await coll.find(search).sort(sort_key, -1).limit(100).to_list(None)
leader_docs = await get_leader_docs(cmd.db, all_docs, sort_key)
await cmd.db.cache.set_cache(f'{resource}_{sort_key}', leader_docs)
await cmd.db.cache.set_cache(f'{resource}_{sort_key}_stamp', now)
leader_timer = now
table_data = [
[
pos + 1 if not doc[0] == pld.msg.author.id else f'{pos + 1} <',
clean_name((await gu(doc[0])).name if await gu(doc[0]) else doc[0], 'Unknown')[:18],
str(doc[1])
] for pos, doc in enumerate(leader_docs)
]
table_body = boop(table_data, ['#', 'User Name', value_name])
curr_icon = '🍬'
response = f'{curr_icon} **{lb_category} {value_name} Leaderboard**'
response += f'\n```hs\n{table_body}\n```'
response += f'\nLeaderboard last updated **{arrow.get(leader_timer).humanize()}**.'
await pld.msg.channel.send(response)
if role_search:
members = []
for member in pld.msg.guild.members:
if role_search in member.roles:
if state:
if member.status.name == state:
members.append([member.name, member.top_role.name])
else:
members.append([member.name, member.top_role.name])
if members:
count = len(members)
members, page = PaginatorCore.paginate(sorted(members), page)
response = discord.Embed(color=role_search.color)
state = state if state else 'Any'
value = f'```py\nShowing 10 of {count} users. Status: {state}. Page {page}\n```'
members_table = boop(members, ['Name', 'Top Role'])
response.add_field(name='📄 Details', value=value, inline=False)
response.add_field(name='👥 Members', value=f'```hs\n{members_table}\n```', inline=False)
else:
response = not_found(f'No users have the {role_search.name} role.')
else:
response = not_found(f'{lookup} not found.')
else:
response = error('Nothing inputted.')
await pld.msg.channel.send(embed=response)
type_out = boop(type_list)
rare_keys = ['common', 'uncommon', 'rare', 'legendary', 'prime',
'spectral', 'ethereal', 'antimatter', 'omnipotent']
rare_list = []
for rare_key in rare_keys:
if rare_key in rarity_dict:
an = types['animal'].get(rare_key) or 0
fi = types['fish'].get(rare_key) or 0
pl = types['plant'].get(rare_key) or 0
to = rarity_dict[rare_key]
rare_row = [rare_key.upper(), an, fi, pl, to]
else:
rare_row = [rare_key.upper(), 0, 0, 0, 0]
rare_list.append(rare_row)
headers = ['Rarity', 'Animals', 'Fish', 'Plants', 'Total']
rare_out = boop(rare_list, headers)
currency = cmd.bot.cfg.pref.currency
response = discord.Embed(color=0xc16a4f)
response.add_field(name='Items by Type', value=f'```py\n{type_out}\n```', inline=False)
response.add_field(name='Items by Rarity', value=f'```py\n{rare_out}\n```', inline=False)
response.set_footer(text=f'Total Value: {total_value} {currency}')
else:
response = discord.Embed(color=0xc6e4b5, title='💸 Totally empty...')
response.set_author(name=f'{target.name}#{target.discriminator}', icon_url=user_avatar(target))
await pld.msg.channel.send(embed=response)
async def status(cmd, message, args):
cpu_stats = []
col_nam = []
n = 1
cpu_count = psutil.cpu_count()
while n < (cpu_count + 1):
col_nam.append('Core ' + str(n))
n += 1
for x in range(4):
cpu_stat = psutil.cpu_percent(1, True)
cpu_stats.append(cpu_stat)
cpu_stats_text = 'CPU Stats:\n```haskell\n' + boop(cpu_stats, col_nam) + '\n```'
await cmd.reply(cpu_stats_text)
)
cookie_count = await cookie_count.to_list(None)
cookie_count = cookie_count[0]['cookie_count']
cookie_list = []
for cookie_file in all_cookies:
user = discord.utils.find(lambda x: x.id == cookie_file['UserID'], cmd.bot.get_all_members())
if user:
unam = user.name
else:
unam = '{Unknown}'
if len(unam) > 13:
unam = f'{unam[0:13]}...'
cookie_list.append([unam, cookie_file['Cookies']])
cookie_table = boop(cookie_list, ['User', 'Cookies'])
top_text = f'A total of {cookie_count} cookies have been given.'
response = discord.Embed(color=0xd99e82)
response.add_field(name='Cookie Count', value=top_text, inline=False)
response.add_field(name='Cookie Leaderboard', value=f'```bat\n{cookie_table}\n```', inline=False)
await message.channel.send(embed=response)
:type pld: sigma.core.mechanics.payload.CommandPayload
"""
acolytes = await WorldState().acolytes
if acolytes:
data_list = []
headers = ['Name', 'Health', 'Location']
for acolyte in acolytes:
name = acolyte.get('name')
health = f"{round(acolyte.get('health') * 100, 2)}%"
if acolyte.get('discovered'):
location = acolyte.get('location')
else:
location = 'Unknown'
entry = [name, health, location]
data_list.append(entry)
data_table = format_pretty_table(data_list, headers)
response = discord.Embed(color=0xcc0000)
response.set_author(name='Warframe Acolytes Data', icon_url=stalker_icon)
response.description = f'```hs\n{data_table}\n```'
else:
response = error('No data on the Acolytes.')
await pld.msg.channel.send(embed=response)
async def servers(cmd, message, args):
if message.author.id in permitted_id:
serv_lst = []
column_lst = ['Server Name', 'Server ID', 'Members']
for server in cmd.bot.servers:
temp_lst = []
n = len(server.members)
temp_lst.append(str(server))
temp_lst.append(str(server.id))
temp_lst.append(str(n))
serv_lst.append(temp_lst)
server_list = format_pretty_table(serv_lst, column_lst)
out_text = 'List of servers:\n```'
out_text += server_list
if len(out_text) > 1950:
out_text = out_text[:1950]
out_text += '...'
out_text += '\n```'
await cmd.reply(out_text)
else:
error_msg = await cmd.reply('Insufficient permissions.')
await asyncio.sleep(5)
await cmd.bot.delete_message(error_msg)
await cmd.bot.delete_message(message)
headers = ['Name', 'Platinum']
if not no_discounts:
headers.append('Discount')
if sales_data:
total_plat = sum([x['premiumOverride'] for x in sales_data_all])
sales_data = sorted(sales_data, key=lambda x: x['item'])
stat_block = f'Showing items {start_range}-{end_range}. Page {page}'
stat_block += f'\nThere are {total_item} items valued at {total_plat} platinum.'
item_list = []
for sale_item in sales_data:
if no_discounts:
item_list.append([sale_item.get('item'), sale_item.get('premiumOverride')])
else:
item_list.append(
[sale_item.get('item'), sale_item.get('premiumOverride'), f"-{sale_item.get('discount')}%"])
item_table = boop(item_list, headers)
response = discord.Embed(color=0x336699)
response.set_author(name='Warframe Promotions', icon_url=warframe_icon)
response.add_field(name='Details', value=f'```py\n{stat_block}\n```', inline=False)
response.add_field(name=title, value=f'```hs\n{item_table}\n```', inline=False)
else:
response = discord.Embed(color=0x336699)
response.set_author(name='No items found, try adding the "all" argument.', icon_url=warframe_icon)
else:
response = error('Could not retrieve Sales data.')
await pld.msg.channel.send(embed=response)