async def combinechains(cmd, message, args): if not await cmd.bot.cool_down.on_cooldown(cmd.name, message.author): if len(message.mentions) == 2: target_one = message.mentions[0] target_two = message.mentions[1] chain_one = await cmd.db[cmd.db.db_cfg.database ]['MarkovChains'].find_one( {'UserID': target_one.id}) chain_two = await cmd.db[cmd.db.db_cfg.database ]['MarkovChains'].find_one( {'UserID': target_two.id}) if chain_one and chain_two: await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, 20) init_embed = discord.Embed(color=0xbdddf4, title='💭 Hmm... Let me think...') init_message = await message.channel.send(embed=init_embed) string_one = ' '.join(chain_one.get('Chain')) string_two = ' '.join(chain_two.get('Chain')) with ThreadPoolExecutor() as threads: chain_task_one = functools.partial(markovify.Text, string_one) chain_task_two = functools.partial(markovify.Text, string_two) markov_one = await cmd.bot.loop.run_in_executor( threads, chain_task_one) markov_two = await cmd.bot.loop.run_in_executor( threads, chain_task_two) combine_task = functools.partial(markovify.combine, [markov_one, markov_two], [1, 1]) combination = await cmd.bot.loop.run_in_executor( threads, combine_task) sentence_function = functools.partial( combination.make_short_sentence, 500) sentence = await cmd.bot.loop.run_in_executor( threads, sentence_function) if not sentence: response = discord.Embed( color=0xBE1931, title='😖 I could not think of anything...') else: icon_choice = secrets.choice([target_one, target_two]) combined_name = combine_names(target_one, target_two) response = discord.Embed(color=0xbdddf4) response.set_author(name=combined_name, icon_url=user_avatar(icon_choice)) response.add_field(name='💭 Hmm... something like...', value=sentence) await init_message.edit(embed=response) else: no_chain = discord.Embed( color=0xBE1931, title='❗ One of the users does not have a chain.') await message.channel.send(embed=no_chain) else: no_target = discord.Embed(color=0xBE1931, title='❗ Invalid number of targets.') await message.channel.send(embed=no_target) else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, message.author) on_cooldown = discord.Embed( color=0xccffff, title=f'❄ On cooldown for another {timeout} seconds.') await message.channel.send(embed=on_cooldown)
async def fish(cmd, message, args): global item_core if not item_core: item_core = ItemCore(cmd.resource('data')) if not await cmd.bot.cool_down.on_cooldown(cmd.name, message.author): upgrade_file = await cmd.db[cmd.db.db_cfg.database].Upgrades.find_one( {'UserID': message.author.id}) if upgrade_file is None: await cmd.db[cmd.db.db_cfg.database ].Upgrades.insert_one({'UserID': message.author.id}) upgrade_file = {} inv = await cmd.db.get_inventory(message.author) if 'storage' in upgrade_file: storage = upgrade_file['storage'] else: storage = 0 inv_limit = 64 + (8 * storage) if len(inv) < inv_limit: base_cooldown = 60 if 'stamina' in upgrade_file: stamina = upgrade_file['stamina'] else: stamina = 0 cooldown = int(base_cooldown - ((base_cooldown / 100) * (stamina * 0.5))) await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, cooldown) rarity = await item_core.roll_rarity(cmd.db, message.author.id) if args: if message.author.id in cmd.bot.cfg.dsc.owners: try: rarity = int(args[0]) except TypeError: pass item = item_core.pick_item_in_rarity('fish', rarity) connector = 'a' if item.rarity_name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' if rarity == 0: if item.name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' response_title = f'{item.icon} You caught {connector} {item.name} and threw it away!' else: response_title = f'{item.icon} You caught {connector} {item.rarity_name} {item.name}!' data_for_inv = item.generate_inventory_item() await cmd.db.add_to_inventory(message.author, data_for_inv) response = discord.Embed(color=item.color, title=response_title) response.set_author(name=message.author.display_name, icon_url=user_avatar(message.author)) if item.rarity >= 5: if 'item_channel' in cmd.cfg: await item_core.notify_channel_of_special( message, cmd.bot.get_all_channels(), cmd.cfg['item_channel'], item) else: response = discord.Embed(color=0xBE1931, title=f'❗ Your inventory is full.') else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, message.author) response = discord.Embed( color=0x696969, title=f'🕙 Your new bait will be ready in {timeout} seconds.') await message.channel.send(embed=response)
async def inventory(cmd, message, args): global item_core if not item_core: item_core = ItemCore(cmd.resource('data')) if message.mentions: target = message.mentions[0] else: target = message.author upgrade_file = await cmd.db[cmd.db.db_cfg.database ].Upgrades.find_one({'UserID': target.id}) if upgrade_file is None: await cmd.db[cmd.db.db_cfg.database ].Upgrades.insert_one({'UserID': target.id}) upgrade_file = {} if 'storage' in upgrade_file: storage = upgrade_file['storage'] else: storage = 0 inv_limit = 64 + (8 * storage) page_number = 1 if args: try: page_number = abs(int(args[0])) if page_number == 0: page_number = 1 except TypeError: page_number = 1 except ValueError: page_number = 1 start_range = (page_number - 1) * 10 end_range = page_number * 10 inv = await cmd.db.get_inventory(target) total_inv = len(inv) item_o_list = [] for item in inv: item_o = item_core.get_item_by_file_id(item['item_file_id']) item_o_list.append(item_o) item_o_list = sorted(item_o_list, key=lambda x: x.rarity, reverse=True) inv = item_o_list[start_range:end_range] if inv: headers = ['Type', 'Item', 'Value', 'Rarity'] to_format = [] total_value = 0 for item_o_item in inv: to_format.append([ item_o_item.type, item_o_item.name, f'{item_o_item.value}', f'{item_o_item.rarity_name.title()}' ]) for item_o_item in item_o_list: total_value += item_o_item.value output = boop(to_format, column_names=headers) response = discord.Embed(color=0xc16a4f) response.set_author(name=f'{target.name}#{target.discriminator}', icon_url=user_avatar(target)) inv_text = f'Showing items {start_range}-{end_range}.' inv_text += f'\nYou have {total_inv}/{inv_limit} items in your inventory.' inv_text += f'\nTotal value of your inventory is {total_value} {cmd.bot.cfg.pref.currency}.' response.add_field(name='📦 Inventory Stats', value=f'```py\n{inv_text}\n```') response.add_field(name=f'📋 Items Currently On Page {page_number}', value=f'```hs\n{output}\n```', inline=False) else: response = discord.Embed(color=0xc6e4b5, title='💸 Totally empty...') await message.channel.send(embed=response)
async def combinechains(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ if len(pld.msg.mentions) >= 2: empty_chain = None chains = [] chain_dicts = [] with ThreadPoolExecutor() as threads: for target in pld.msg.mentions: target_chain = load(target.id) if os.path.exists( f'chains/{target.id}.json.gz') else None if not target_chain: empty_chain = target break chain_dicts.append(deserialize(target_chain)) failed = False for chain_dict in chain_dicts: try: chain_task = functools.partial(markovify.Text.from_dict, chain_dict) chain = await cmd.bot.loop.run_in_executor( threads, chain_task) chains.append(chain) except (ValueError, KeyError, AttributeError): failed = True break if not empty_chain: if not failed: await cmd.bot.cool_down.set_cooldown( cmd.name, pld.msg.author, 20) try: combine_task = functools.partial( markovify.combine, chains) combination = await cmd.bot.loop.run_in_executor( threads, combine_task) sentence_function = functools.partial( combination.make_short_sentence, 500) sentence = await cmd.bot.loop.run_in_executor( threads, sentence_function) except (ValueError, KeyError, AttributeError): sentence = None if not sentence: not_enough_data = '😖 I could not think of anything... I need more chain items!' response = discord.Embed(color=0xBE1931, title=not_enough_data) else: combined_name = combine_names(pld.msg.mentions) response = discord.Embed(color=0xbdddf4) response.set_author(name=combined_name, icon_url=user_avatar( secrets.choice( pld.msg.mentions))) response.add_field( name='💠Hmm... something like...', value=sentence) else: response = GenericResponse( 'Failed to combine the markov chains.').error() else: response = GenericResponse( f'{empty_chain.name} does not have a chain.').error() else: response = GenericResponse('Invalid number of targets.').error() await pld.msg.channel.send(embed=response)
async def inventorystats(cmd, message, args): global item_core if not item_core: item_core = ItemCore(cmd.resource('data')) if message.mentions: target = message.mentions[0] else: target = message.author inv = cmd.db.get_inventory(target) item_o_list = [] for item in inv: item_o = item_core.get_item_by_file_id(item['item_file_id']) item_o_list.append(item_o) item_o_list = sorted(item_o_list, key=lambda x: x.rarity, reverse=True) inv = item_o_list if inv: total_value = 0 rarity_dict = {} type_dict = {} for item_o_item in item_o_list: total_value += item_o_item.value if item_o_item.type.lower() in type_dict: type_count = type_dict[item_o_item.type.lower()] else: type_count = 0 type_count += 1 type_dict.update({item_o_item.type.lower(): type_count}) if item_o_item.rarity_name in rarity_dict: rare_count = rarity_dict[item_o_item.rarity_name] else: rare_count = 0 rare_count += 1 rarity_dict.update({item_o_item.rarity_name: rare_count}) type_keys = ['fish', 'plant', 'animal'] type_list = [] for type_key in type_keys: if type_key in type_dict: type_num = type_dict[type_key] else: type_num = 0 type_list.append([type_key.upper(), type_num]) 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: rare_num = rarity_dict[rare_key] else: rare_num = 0 rare_list.append([rare_key.upper(), rare_num]) rare_out = boop(rare_list) response = discord.Embed(color=0xc16a4f) response.set_author(name=f'{target.name}#{target.discriminator}', icon_url=user_avatar(target)) 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) else: response = discord.Embed(color=0xc6e4b5, title='💸 Totally empty...') await message.channel.send(embed=response)
async def ban(cmd: SigmaCommand, message: discord.Message, args: list): if message.author.permissions_in(message.channel).ban_members: if message.mentions: target = message.mentions[0] if len(args) >= 2: try: clean_days = int(args[-1]) except ValueError: clean_days = 0 else: clean_days = 0 clean_days = clean_days if clean_days in [0, 1, 7] else 0 if cmd.bot.user.id != target.id: if message.author.id != target.id: above_hier = hierarchy_permit(message.author, target) is_admin = message.author.permissions_in( message.channel).administrator if above_hier or is_admin: above_me = hierarchy_permit(message.guild.me, target) if above_me: if len(args) > 1: reason = ' '.join(args[1:]) else: reason = 'No reason stated.' response = discord.Embed( color=0x696969, title=f'🔨 The user has been banned.') response_title = f'{target.name}#{target.discriminator}' response.set_author(name=response_title, icon_url=user_avatar(target)) to_target = discord.Embed(color=0x696969) to_target.add_field(name='🔨 You have been banned.', value=f'Reason: {reason}') to_target.set_footer( text=f'From: {message.guild.name}.', icon_url=message.guild.icon_url) try: await target.send(embed=to_target) except discord.Forbidden: pass audit_reason = f'By {message.author.name}: {reason}' await target.ban(reason=audit_reason, delete_message_days=clean_days) log_embed = generate_log_embed( message, target, reason) await log_event(cmd.bot, message.guild, cmd.db, log_embed, 'LogBans') else: response = discord.Embed( title='⛔ Target is above my highest role.', color=0xBE1931) else: response = discord.Embed( title='⛔ Can\'t ban someone equal or above you.', color=0xBE1931) else: response = discord.Embed( color=0xBE1931, title='❗ You can\'t ban yourself.') else: response = discord.Embed(color=0xBE1931, title='❗ I can\'t ban myself.') else: response = discord.Embed(color=0xBE1931, title='❗ No user targeted.') else: response = discord.Embed( title='⛔ Access Denied. Ban permissions needed.', color=0xBE1931) await message.channel.send(embed=response)
async def hunt(cmd: SigmaCommand, message: discord.Message, args: list): global item_core if not item_core: item_core = ItemCore(cmd.resource('data')) if not await cmd.bot.cool_down.on_cooldown(cmd.name, message.author): upgrade_file = await cmd.db[cmd.db.db_cfg.database].Upgrades.find_one( {'UserID': message.author.id}) if upgrade_file is None: await cmd.db[cmd.db.db_cfg.database ].Upgrades.insert_one({'UserID': message.author.id}) upgrade_file = {} inv = await cmd.db.get_inventory(message.author) if 'storage' in upgrade_file: storage = upgrade_file['storage'] else: storage = 0 inv_limit = 64 + (8 * storage) if len(inv) < inv_limit: base_cooldown = 60 if 'stamina' in upgrade_file: stamina = upgrade_file['stamina'] else: stamina = 0 cooldown = int(base_cooldown - ((base_cooldown / 100) * ((stamina * 0.5) / (1.25 + (0.01 * stamina))))) if cooldown < 12: cooldown = 12 await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, cooldown) rarity = await item_core.roll_rarity(cmd.db, message.author.id) if args: if message.author.id in cmd.bot.cfg.dsc.owners: try: if int(args[0]) <= 9: rarity = int(args[0]) else: pass except TypeError: pass if rarity == 0: item = None item_color = 0x67757f response_title = f'🗑 You failed to catch anything.' else: item = item_core.pick_item_in_rarity('animal', rarity) await item_core.add_item_statistic(cmd.db, item, message.author) connector = 'a' if item.rarity_name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' item_color = item.color response_title = f'{item.icon} You caught {connector} {item.rarity_name} {item.name}!' data_for_inv = item.generate_inventory_item() await cmd.db.add_to_inventory(message.author, data_for_inv) response = discord.Embed(color=item_color, title=response_title) response.set_author(name=message.author.display_name, icon_url=user_avatar(message.author)) if rarity >= 5: if 'item_channel' in cmd.cfg: await item_core.notify_channel_of_special( message, cmd.bot.get_all_channels(), cmd.cfg['item_channel'], item) else: response = discord.Embed(color=0xBE1931, title=f'❗ Your inventory is full.') else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, message.author) response = discord.Embed( color=0x696969, title=f'🕙 You are resting for another {timeout} seconds.') await message.channel.send(embed=response)
async def softban(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ if pld.msg.author.permissions_in(pld.msg.channel).ban_members: target = get_broad_target(pld) if target: if cmd.bot.user.id != target.id: if pld.msg.author.id != target.id: above_hier = hierarchy_permit(pld.msg.author, target) is_admin = pld.msg.author.permissions_in( pld.msg.channel).administrator if above_hier or is_admin: above_me = hierarchy_permit(pld.msg.guild.me, target) if above_me: reason = ' '.join( pld.args[1:]) if pld.args[1:] else None response = discord.Embed( color=0x696969, title='🔩 The user has been soft-banned.') response_title = f'{target.name}#{target.discriminator}' response.set_author(name=response_title, icon_url=user_avatar(target)) guild_icon = str( pld.msg.guild.icon_url ) if pld.msg.guild.icon_url else discord.Embed.Empty to_target = discord.Embed(color=0x696969) to_target.add_field( name='🔩 You have been soft-banned.', value=f'Reason: {reason}') to_target.set_footer( text=f'From: {pld.msg.guild.name}.', icon_url=guild_icon) try: await target.send(embed=to_target) except (discord.Forbidden, discord.HTTPException): pass await target.ban( reason= f'By {pld.msg.author.name}: {reason} (Soft)') await target.unban() log_embed = generate_log_embed( pld.msg, target, reason) await log_event(cmd.bot, pld.settings, log_embed, 'log_bans') else: response = GenericResponse( 'Target is above my highest role.').denied() else: response = GenericResponse( 'Can\'t soft-ban someone equal or above you.' ).denied() else: response = GenericResponse( 'You can\'t soft-ban yourself.').error() else: response = GenericResponse('I can\'t soft-ban myself.').error() else: response = GenericResponse('No user targeted.').error() else: response = GenericResponse( 'Access Denied. Ban permissions needed.').denied() await pld.msg.channel.send(embed=response)
async def slots(cmd: SigmaCommand, message: discord.Message, args: list): currency_icon = cmd.bot.cfg.pref.currency_icon currency = cmd.bot.cfg.pref.currency current_kud = await cmd.db.get_currency(message.author, message.guild) current_kud = current_kud['current'] if args: try: bet = abs(int(args[0])) except ValueError: bet = 10 else: bet = 10 if current_kud >= bet: if not await cmd.bot.cool_down.on_cooldown(cmd.name, message.author): upgrade_file = await cmd.db[cmd.db.db_cfg.database ].Upgrades.find_one( {'UserID': message.author.id}) if upgrade_file is None: await cmd.db[cmd.db.db_cfg.database].Upgrades.insert_one( {'UserID': message.author.id}) upgrade_file = {} base_cooldown = 60 if 'casino' in upgrade_file: stamina = upgrade_file['casino'] else: stamina = 0 cooldown = int(base_cooldown - ((base_cooldown / 100) * ((stamina * 0.5) / (1.25 + (0.01 * stamina))))) if cooldown < 12: cooldown = 12 await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, cooldown) await cmd.db.rmv_currency(message.author, bet) out_list = [] for x in range(0, 3): temp_list = [] init_symb = [] for y in range(0, 3): if not init_symb: symbol_choice = secrets.choice(symbols) init_symb.append(symbol_choice) else: roll = secrets.randbelow(bet + (bet // 2) + 10) if roll == 0: symbol_choice = secrets.choice(symbols) else: temp_symb = [] for symbol_item in symbols: temp_symb.append(symbol_item) for init_symb_item in init_symb: temp_symb.remove(init_symb_item) symbol_choice = secrets.choice(temp_symb) init_symb.append(symbol_choice) temp_list.append(symbol_choice) out_list.append(temp_list) slot_lines = f'⏸{"".join(out_list[0])}⏸' slot_lines += f'\n▶{"".join(out_list[1])}◀' slot_lines += f'\n⏸{"".join(out_list[2])}⏸' combination = out_list[1] three_comb = bool( combination[0] == combination[1] == combination[2]) two_comb_one = bool(combination[0] == combination[1]) two_comb_two = bool(combination[0] == combination[2]) two_comb_three = bool(combination[1] == combination[2]) if three_comb: win = True winnings = int(bet * (rarity_rewards[combination[0]] * (bet // 2))) elif two_comb_one or two_comb_two or two_comb_three: if combination[0] == combination[1]: win_comb = combination[0] elif combination[0] == combination[2]: win_comb = combination[0] elif combination[1] == combination[2]: win_comb = combination[1] else: win_comb = None win = True winnings = int(bet * (rarity_rewards[win_comb] * (bet // 5))) else: win = False winnings = 0 if win: color = 0x5dadec title = '💎 Congrats, you won!' footer = f'{currency_icon} {winnings} {currency} has been awarded.' await cmd.db.add_currency(message.author, message.guild, winnings, additive=False) else: color = 0x232323 title = '💣 Oh my, you lost...' footer = f'{currency_icon} {bet} {currency} has been deducted.' response = discord.Embed(color=color) response.set_author(name=message.author.display_name, icon_url=user_avatar(message.author)) response.add_field(name=title, value=slot_lines) response.set_footer(text=footer) else: timeout = await cmd.bot.cool_down.get_cooldown( cmd.name, message.author) response = discord.Embed( color=0x696969, title=f'🕙 You can spin again in {timeout} seconds.') else: response = discord.Embed(color=0xa7d28b, title=f'💸 You don\'t have {bet} {currency}.') await message.channel.send(embed=response)
async def unqueue(cmd: SigmaCommand, message: discord.Message, args: list): if args: if message.author.voice: same_bound = True if message.guild.voice_client: if message.guild.voice_client.channel.id != message.author.voice.channel.id: same_bound = False if same_bound: if message.guild.voice_client: queue = cmd.bot.music.get_queue(message.guild.id) if not queue.empty(): try: order_num = int(args[0]) if order_num >= 1: order_num -= 1 queue_list = await cmd.bot.music.listify_queue( queue) queue_size = len(queue_list) if order_num <= queue_size - 1: item = queue_list[order_num] is_mod = message.author.guild_permissions.manage_guild is_req = item.requester.id == message.author.id if is_mod or is_req: queue_list.remove(item) new_queue = Queue() for list_item in queue_list: await new_queue.put(list_item) cmd.bot.music.queues.update( {message.guild.id: new_queue}) response = discord.Embed( color=0x66CC66, title=f'✅ Removed {item.title}.') requester = f'{message.author.name}#{message.author.discriminator}' response.set_author(name=requester, icon_url=user_avatar( message.author)) else: auth_deny_desc = f'Sorry, {message.author.name}. To remove a song you need to be' auth_deny_desc += ' the person who requested it, or have the Manage Server' auth_deny_desc += f' permission on {message.guild.name}.' response = discord.Embed(color=0xBE1931) response.add_field(name='⛔ Access Denied', value=auth_deny_desc) else: response = discord.Embed( color=0xBE1931, title='❗ Input out of range.') except ValueError: response = discord.Embed( color=0xBE1931, title='❗ Invalid input. Numbers only.') else: response = discord.Embed(color=0xBE1931, title='❗ The queue is empty.') else: response = discord.Embed( color=0xBE1931, title='❗ I am not connected to any channel.') else: response = discord.Embed( color=0xBE1931, title='❗ You are not in my voice channel.') else: response = discord.Embed(color=0xBE1931, title='❗ You are not in a voice channel.') else: response = discord.Embed(color=0xBE1931, title='❗ Nothing inputted.') await message.channel.send(embed=response)
async def cycler(ev): """ :param ev: The event object referenced in the event. :type ev: sigma.core.mechanics.event.SigmaEvent """ raffle_coll = ev.db[ev.db.db_nam].Raffles while True: if ev.bot.is_ready(): # noinspection PyBroadException try: now = arrow.utcnow().float_timestamp raffles = await raffle_coll.find({ 'end': { '$lt': now }, 'active': True }).to_list(None) if raffles: for raffle in raffles: cid = raffle.get('channel') aid = raffle.get('author') mid = raffle.get('message') icon = raffle.get('icon') title = raffle.get('title') color = raffle.get('color') channel = await ev.bot.get_channel(cid) if channel: await raffle_coll.update_one( raffle, {'$set': { 'active': False }}) message = await channel.fetch_message(mid) if message: custom_emote = icon.startswith( '<:') and icon.endswith('>') if custom_emote: emote = get_matching_emote( message.guild, icon) if emote: icon = emote.name contestants = [] reactions = message.reactions for reaction in reactions: rem_nam = str(reaction.emoji) custom_rem = rem_nam.startswith( '<:') and rem_nam.endswith('>') if custom_rem: rem_emote = get_matching_emote( message.guild, rem_nam) if rem_emote: rem = rem_emote.name else: rem = None else: rem = reaction.emoji if rem: if rem == icon: async for user in reaction.users(): if not user.bot: contestants.append(user) break if contestants: contestants = extra_shuffle(contestants) draw_count = min( len(contestants), raffle.get('draw_count', 1)) for _ in range(draw_count): winner = contestants.pop( secrets.randbelow( len(contestants))) amen = f'<@{aid}>' wmen = f'<@{winner.id}>' ender = '' if title[ -1] in string.punctuation else '!' win_text = f'{raffle.get("icon")} Hey {amen}, {wmen} won your raffle!' win_embed = discord.Embed(color=color) win_title = f'{winner.name} won {title.lower()}{ender}' win_embed.set_author( name=win_title, icon_url=user_avatar(winner)) await channel.send(win_text, embed=win_embed) ev.log.info( f'{winner} won {aid}\'s raffle {raffle.get("ID")} in {cid}.' ) except Exception as e: ev.log.error(e) pass await asyncio.sleep(1)
async def edit_invite_blocker(ev, pld): """ :param ev: The event object referenced in the event. :type ev: sigma.core.mechanics.event.SigmaEvent :param pld: The event payload data to process. :type pld: sigma.core.mechanics.payload.MessageEditPayload """ after = pld.after if after.guild: if isinstance(after.author, discord.Member): override = check_filter_perms(after, pld.settings, 'invites') is_owner = after.author.id in ev.bot.cfg.dsc.owners if not any([ after.author.guild_permissions.administrator, is_owner, override ]): active = pld.settings.get('block_invites') if active: arguments = after.content.split(' ') invite_found = None for arg in arguments: triggers = ['discord.gg', 'discordapp.com/invite'] for trigger in triggers: if trigger in arg: try: code = arg.split('/')[-1] invite_found = await ev.bot.fetch_invite( code) break except (discord.NotFound, IndexError): pass if invite_found: try: invite_warn = pld.settings.get('invite_auto_warn') if invite_warn: reason = f'Sent an invite to {invite_found.guild.name}.' warn_data = warning_data( after.guild.me, after.author, reason) await ev.db[ev.db.db_nam ].Warnings.insert_one(warn_data) await after.delete() title = f'⛓ Invite links are not allowed on {after.guild.name}.' response = discord.Embed(color=0xF9F9F9, title=title) try: await after.author.send(embed=response) except (discord.Forbidden, discord.HTTPException): pass log_embed = discord.Embed(color=0xF9F9F9) author = f'{after.author.name}#{after.author.discriminator}' log_embed.set_author( name=f'I removed {author}\'s invite link.', icon_url=user_avatar(after.author)) log_embed.set_footer( text= f'Posted In: #{after.channel.name} | Leads To: {invite_found.guild.name}' ) await log_event(ev.bot, pld.settings, log_embed, 'log_filters') except (discord.ClientException, discord.NotFound, discord.Forbidden): pass
async def hunt(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ ongoing = Ongoing.is_ongoing('profession', pld.msg.author.id) if not ongoing: Ongoing.set_ongoing('profession', pld.msg.author.id) item_core = await get_item_core(cmd.db) if not await cmd.bot.cool_down.on_cooldown('profession', pld.msg.author): upgrade_file = await cmd.bot.db.get_profile(pld.msg.author.id, 'upgrades') or {} inv = await cmd.db.get_inventory(pld.msg.author.id) storage = upgrade_file.get('storage', 0) inv_limit = 64 + (8 * storage) if len(inv) < inv_limit: base_cooldown = 20 stamina = upgrade_file.get('stamina', 0) cooldown = int(base_cooldown - ((base_cooldown / 100) * ((stamina * 0.5) / (1.25 + (0.01 * stamina))))) cooldown = 2 if cooldown < 2 else cooldown await cmd.bot.cool_down.set_cooldown('profession', pld.msg.author, cooldown) rarity = await item_core.roll_rarity(await cmd.bot.db.get_profile(pld.msg.author.id)) if pld.args: if pld.msg.author.id in cmd.bot.cfg.dsc.owners: try: if int(pld.args[0]) <= 9: rarity = int(pld.args[0]) except ValueError: pass if rarity == 0: response_title = '🗑 You hunted for a while but found nothing...' response = discord.Embed(color=0x67757f, title=response_title) else: item = item_core.pick_item_in_rarity('animal', rarity) connector = 'a' if item.rarity_name[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' dialogue = DialogueCore(cmd.bot, pld.msg, None) dresp = await dialogue.item_dialogue(item_icons.get(item.type.lower()), item) if dresp.ok: response_title = f'{item.icon} You caught {connector} {item.rarity_name} {item.name}!' data_for_inv = item.generate_inventory_item() await cmd.db.add_to_inventory(pld.msg.author.id, data_for_inv) await item_core.add_item_statistic(cmd.db, item, pld.msg.author) await cmd.db.add_resource(pld.msg.author.id, 'items', 1, cmd.name, pld.msg, True) await cmd.db.add_resource(pld.msg.author.id, 'animal', 1, cmd.name, pld.msg, True) response = discord.Embed(color=item.color, title=response_title) else: if dresp.timed_out: response_title = f'🕙 Oh no... The {item.rarity_name} {item.type.lower()} escaped...' response = discord.Embed(color=0x696969, title=response_title) elif dresp.cancelled: response_title = '❌ Oh no... The feisty little thing slipped out of your grasp...' response = discord.Embed(color=0xBE1931, title=response_title) else: response = dresp.generic('hunting') else: response = GenericResponse('Your inventory is full.').error() else: timeout = await cmd.bot.cool_down.get_cooldown('profession', pld.msg.author) response = discord.Embed(color=0x696969, title=f'🕙 You are resting for another {timeout} seconds.') Ongoing.del_ongoing('profession', pld.msg.author.id) else: response = GenericResponse("Can't do multiple professions at once.").warn() response.set_author(name=pld.msg.author.display_name, icon_url=user_avatar(pld.msg.author)) await pld.msg.channel.send(embed=response)
async def roulette(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ if not await cmd.bot.cool_down.on_cooldown(cmd.name, pld.msg.author): if pld.args: sel, val = get_selector_and_value(pld.args) sel = 'color' if sel == 'colour' else sel if sel is not None and val is not None: if sel in selector_ranges: if val in selector_ranges.get(sel): bet = get_bet(pld.args) currency_icon = cmd.bot.cfg.pref.currency_icon currency = cmd.bot.cfg.pref.currency author = pld.msg.author.id current_kud = await cmd.db.get_resource( author, 'currency') current_kud = current_kud.current if current_kud >= bet: await set_roul_cd(cmd, pld) await cmd.db.del_resource(pld.msg.author.id, 'currency', bet, cmd.name, pld.msg) spot = secrets.choice(spots) spot_sel_val = getattr(spot, sel, val) if spot_sel_val == val: winnings = bet + (bet * selector_mults.get(sel)) await cmd.db.add_resource( author, 'currency', winnings, cmd.name, pld.msg, False) footer = f'{currency_icon} You won {winnings - bet} {currency}' resp_color = 0x66cc66 else: resp_color = 0xBE1931 footer = f'You lost {bet} {currency}' footer += f' for betting on the {sel}.' response = discord.Embed(color=resp_color, title=spot.desc) response.set_author(name=pld.msg.author.name, icon_url=user_avatar( pld.msg.author)) response.set_footer(text=footer) else: response = discord.Embed( color=0xa7d28b, title=f'💸 You don\'t have {bet} {currency}.' ) else: ranges = selector_ranges.get(sel) valids = f'{ranges[0]} - {ranges[-1]}' response = error( f'Invalid value for {sel}. Accepted are {valids}') else: response = error( 'Invalid selector, check the command description.') else: response = error('Invalid selector and value syntax.') else: response = error('Missing selector.') else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, pld.msg.author) response = discord.Embed( color=0x696969, title=f'🕙 You can spin again in {timeout} seconds.') await pld.msg.channel.send(embed=response)
async def trivia(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ global streaks if await cmd.bot.cool_down.on_cooldown(cmd.name, pld.msg.author): timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, pld.msg.author) on_cooldown = discord.Embed( color=0xccffff, title=f'❄ On cooldown for another {timeout} seconds.') await pld.msg.channel.send(embed=on_cooldown) return try: if not is_ongoing(cmd.name, pld.msg.author.id): set_ongoing(cmd.name, pld.msg.author.id) allotted_time = 20 trivia_api_url = 'https://opentdb.com/api.php?amount=1' cat_chosen = False if pld.args: catlook = pld.args[-1].lower() for cat in categories: cat_alts = categories.get(cat) if catlook in cat_alts: trivia_api_url += f'&category={cat}' cat_chosen = True break diflook = pld.args[0].lower() if diflook in ['easy', 'medium', 'hard']: trivia_api_url += f'&difficulty={diflook}' cat_chosen = True async with aiohttp.ClientSession() as session: async with session.get(trivia_api_url) as number_get: number_response = await number_get.read() try: data = json.loads(number_response).get('results')[0] except json.JSONDecodeError: if is_ongoing(cmd.name, pld.msg.author.id): del_ongoing(cmd.name, pld.msg.author.id) decode_error = error('Could not retrieve a question.') await pld.msg.channel.send(embed=decode_error) return await cmd.bot.cool_down.set_cooldown(cmd.name, pld.msg.author, 30) question = data['question'] question = ftfy.fix_text(question) question = re.sub(r'([*_~`])', r'\\\1', question) # escape markdown formatting category = data['category'] correct_answer = data['correct_answer'] correct_answer = ftfy.fix_text(correct_answer) incorrect_answers = data['incorrect_answers'] difficulty = data['difficulty'] reward_mult = streaks.get( pld.msg.author.id) or 0 if not cat_chosen else 0 kud_reward = int( (awards.get(difficulty) or '10') * (1 + (reward_mult * 2.25) / (1.75 + (0.03 * reward_mult)))) choice_list = [correct_answer] + incorrect_answers choice_list = shuffle_questions(choice_list) choice_number = 0 choice_lines = [] for choice in choice_list: choice_number += 1 choice_line = f'[{choice_number}] {choice}' choice_lines.append(choice_line) choice_text = '\n'.join(choice_lines) choice_text = ftfy.fix_text(choice_text) if difficulty == 'easy': starter = 'An' else: starter = 'A' question_embed = discord.Embed(color=0xF9F9F9, title='❔ Here\'s a question!') question_embed.description = f'{starter} {difficulty} one from the {category} category.' question_embed.add_field(name='Question', value=question, inline=False) question_embed.add_field(name='Choices', value=f'```py\n{choice_text}\n```', inline=False) question_embed.set_footer( text='Input the number of your chosen answer.') question_embed.set_author(name=pld.msg.author.display_name, icon_url=user_avatar(pld.msg.author)) await pld.msg.channel.send(embed=question_embed) def check_answer(msg): """ :param msg: :type msg: :return: :rtype: """ if pld.msg.channel.id != msg.channel.id: return if pld.msg.author.id != msg.author.id: return if msg.content.isdigit(): if abs(int(msg.content)) <= len(choice_lines): return True else: return elif msg.content.title() in choice_list: return True try: answer_message = await cmd.bot.wait_for('message', check=check_answer, timeout=allotted_time) try: answer_index = int(answer_message.content) - 1 except ValueError: answer_index = None correct_index = get_correct_index(choice_list, correct_answer) if answer_index == correct_index or answer_message.content.lower( ) == correct_answer.lower(): if cat_chosen: streaks.update( {pld.msg.author.id: reward_mult + 0.005}) else: streaks.update({pld.msg.author.id: reward_mult + 1}) await cmd.db.add_resource(answer_message.author.id, 'currency', kud_reward, cmd.name, pld.msg) author = answer_message.author.display_name currency = cmd.bot.cfg.pref.currency win_title = f'🎉 Correct, {author}, it was {correct_answer}. You won {kud_reward} {currency}!' final_embed = discord.Embed(color=0x77B255, title=win_title) else: if pld.msg.author.id in streaks: streaks.pop(pld.msg.author.id) lose_title = f'💣 Ooh, sorry, it was {correct_answer}...' final_embed = discord.Embed(color=0x262626, title=lose_title) await pld.msg.channel.send(embed=final_embed) except asyncio.TimeoutError: if pld.msg.author.id in streaks: streaks.pop(pld.msg.author.id) timeout_title = f'🕙 Time\'s up! It was {correct_answer}...' timeout_embed = discord.Embed(color=0x696969, title=timeout_title) await pld.msg.channel.send(embed=timeout_embed) if is_ongoing(cmd.name, pld.msg.author.id): del_ongoing(cmd.name, pld.msg.author.id) else: ongoing_error = error('There is already one ongoing.') await pld.msg.channel.send(embed=ongoing_error) except Exception: if is_ongoing(cmd.name, pld.msg.author.id): del_ongoing(cmd.name, pld.msg.author.id) raise
async def inventorystats(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ item_core = await get_item_core(cmd.db) if pld.msg.mentions: target = pld.msg.mentions[0] else: target = pld.msg.author inv = await cmd.db.get_inventory(target.id) item_o_list = [] for item in inv: item_o = item_core.get_item_by_file_id(item['item_file_id']) item_o_list.append(item_o) item_o_list = sorted(item_o_list, key=lambda x: x.rarity, reverse=True) types = type_rarity_counter(item_o_list) inv = item_o_list if inv: total_value = 0 rarity_dict = {} type_dict = {} for item_o_item in item_o_list: total_value += item_o_item.value if item_o_item.type.lower() in type_dict: type_count = type_dict[item_o_item.type.lower()] else: type_count = 0 type_count += 1 type_dict.update({item_o_item.type.lower(): type_count}) if item_o_item.rarity_name in rarity_dict: rare_count = rarity_dict[item_o_item.rarity_name] else: rare_count = 0 rare_count += 1 rarity_dict.update({item_o_item.rarity_name: rare_count}) type_keys = ['fish', 'plant', 'animal', 'meal', 'dessert', 'drink'] type_list = [] for type_key in type_keys: if type_key in type_dict: type_num = type_dict[type_key] else: type_num = 0 type_list.append([type_key.upper(), type_num]) 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 ouserinformation(cmd: SigmaCommand, message: discord.Message, args: list): if args: lookup = ' '.join(args) if '#' in lookup: uname = lookup.split('#')[0] udisc = lookup.split('#')[1] target = discord.utils.find( lambda u: u.name.lower() == uname.lower() and u.discriminator == udisc, cmd.bot.get_all_members() ) else: try: target = discord.utils.find(lambda u: u.id == int(lookup), cmd.bot.get_all_members()) except ValueError: target = None if target: response = discord.Embed(color=target.color) response.set_author(name=f'{target.display_name}\'s Information', icon_url=user_avatar(target)) creation_time = arrow.get(target.created_at).format('DD. MMMM YYYY') user_text = f'Username: **{target.name}**#{target.discriminator}' user_text += f'\nID: **{target.id}**' user_text += f'\nStatus: **{str(target.status).replace("dnd", "busy").title()}**' user_text += f'\nBot User: **{target.bot}**' user_text += f'\nCreated: **{creation_time}**' presence = get_membership(cmd.bot.guilds, target) response.add_field(name='User Info', value=user_text, inline=True) member_join_time = arrow.get(target.joined_at).format('DD. MMMM YYYY') is_moderator = target.permissions_in(message.channel).manage_guild member_text = f'Name: **{target.display_name}**' member_text += f'\nColor: **{str(target.color).upper()}**' member_text += f'\nTop Role: **{target.top_role.name}**' member_text += f'\nModerator: **{is_moderator}**' member_text += f'\nJoined: **{member_join_time}**' response.add_field(name='Member Info', value=member_text, inline=True) response.set_footer(text=f'This user is in {len(presence)} guilds.') else: response = discord.Embed(color=0xBE1931, title='❗ User not found.') else: response = discord.Embed(color=0xBE1931, title='❗ Nothing inputted.') await message.channel.send(None, embed=response)
async def raffle(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ if len(pld.args) >= 2: time_input = pld.args[0] try: time_sec = convert_to_seconds(time_input) start_stamp = arrow.utcnow().float_timestamp end_stamp = start_stamp + time_sec end_dt = arrow.get(end_stamp).datetime if time_sec < 90: end_hum = f'in {time_sec} seconds' else: end_hum = arrow.get(end_stamp).humanize() rafid = secrets.token_hex(3) reaction_name = reaction_icon = pld.settings.get('raffle_icon') icon_color = None if reaction_icon: gld = pld.msg.guild guild_icon = str( gld.icon_url) if gld.icon_url else discord.Embed.Empty custom_emote = reaction_icon.startswith( '<:') and reaction_icon.endswith('>') if custom_emote: emote_name = reaction_icon.split(':')[1] matching_emote = None for emote in pld.msg.guild.emojis: if emote.name == emote_name: matching_emote = emote if not matching_emote: reaction_icon = None await cmd.db.set_guild_settings( pld.msg.guild.id, 'raffle_icon', None) else: reaction_icon = matching_emote icon_color = await get_image_colors(matching_emote.url) else: icon_color = await get_image_colors(guild_icon) if not reaction_icon: reaction_name = reaction_icon = secrets.choice(raffle_icons) icon_color = icon_colors.get(reaction_icon) resp_title = f'{pld.msg.author.display_name} started a raffle!' target_ch = pld.msg.channel_mentions[ 0] if pld.msg.channel_mentions else pld.msg.channel external = pld.msg.channel.id != target_ch.id draw_count = 1 args = [a.lower() for a in pld.args] for arg in args: if arg.startswith('winners:'): pld.args.pop(args.index(arg)) draw_num = arg.split(':')[-1] if draw_num.isdigit(): draw_count = int(draw_num) break if external: allowed = pld.msg.author.permissions_in( target_ch).send_messages if allowed: for ai, arg in enumerate(pld.args): if arg == target_ch.mention: pld.args.pop(ai) else: allowed = True if allowed: raffle_title = ' '.join(pld.args[1:]) starter = discord.Embed(color=icon_color, timestamp=end_dt) starter.set_author(name=resp_title, icon_url=user_avatar(pld.msg.author)) starter.description = f'Prize: **{raffle_title}**' starter.description += f'\nReact with a {reaction_icon} to enter the raffle.' starter.set_footer(text=f'[{rafid}] Raffle ends {end_hum}.') starter_message = await target_ch.send(embed=starter) await starter_message.add_reaction(reaction_icon) raffle_data = { 'author': pld.msg.author.id, 'channel': target_ch.id, 'title': raffle_title, 'start': start_stamp, 'end': end_stamp, 'icon': reaction_name, 'color': icon_color, 'draw_count': draw_count, 'message': starter_message.id, 'active': True, 'id': rafid } await cmd.db[cmd.db.db_nam].Raffles.insert_one(raffle_data) response = None else: response = denied( f'You can\'t send messages to #{target_ch.name}.') except (LookupError, ValueError): response = error('Please use the format HH:MM:SS.') else: response = error('Nothing inputted.') if response: await pld.msg.channel.send(embed=response)
async def sell(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ if is_ongoing(cmd.name, pld.msg.author.id): return set_ongoing(cmd.name, pld.msg.author.id) item_core = await get_item_core(cmd.db) currency = cmd.bot.cfg.pref.currency if pld.args: inv = await cmd.db.get_inventory(pld.msg.author.id) if inv: lookup = ' '.join(pld.args) if lookup.lower() == 'all': ender = 's' if len(inv) > 1 else '' worth = sum([ item_core.get_item_by_file_id(ient['item_file_id']).value for ient in inv ]) question = f'❔ Are you sure you want to sell {len(inv)} item{ender} worth {worth} {currency}?' quesbed = discord.Embed(color=0xF9F9F9, title=question) sell_confirm, timeout = await bool_dialogue( cmd.bot, pld.msg, quesbed, True) if sell_confirm: value = 0 count = 0 for invitem in inv.copy(): item_ob_id = item_core.get_item_by_file_id( invitem['item_file_id']) value += item_ob_id.value count += 1 await cmd.db.del_from_inventory( pld.msg.author.id, invitem['item_id']) await cmd.db.add_resource(pld.msg.author.id, 'currency', value, cmd.name, pld.msg) response = discord.Embed(color=0xc6e4b5) response.title = f'💶 You sold {count} item{ender} for {value} {currency}.' else: response = discord.Embed(color=0xBE1931, title='❌ Item sale canceled.') elif lookup.lower() == 'duplicates': value = 0 count = 0 existing_ids = [] for invitem in inv.copy(): file_id = invitem['item_file_id'] if file_id in existing_ids: item_ob_id = item_core.get_item_by_file_id(file_id) value += item_ob_id.value count += 1 await cmd.db.del_from_inventory( pld.msg.author.id, invitem['item_id']) else: existing_ids.append(file_id) await cmd.db.add_resource(pld.msg.author.id, 'currency', value, cmd.name, pld.msg) ender = 's' if count > 1 else '' response = discord.Embed(color=0xc6e4b5) response.title = f'💶 You sold {count} duplicate{ender} for {value} {currency}.' else: request_count = 1 if len(pld.args) > 1: if pld.args[0].isdigit(): request_count = int(pld.args[0]) lookup = ' '.join(pld.args[1:]) item_o = item_core.get_item_by_name(lookup) count = 0 value = 0 if item_o: for _ in range(request_count): item = await cmd.db.get_inventory_item( pld.msg.author.id, item_o.file_id) if item: value += item_o.value count += 1 await cmd.db.del_from_inventory( pld.msg.author.id, item['item_id']) else: break if count > 0: await cmd.db.add_resource(pld.msg.author.id, 'currency', value, cmd.name, pld.msg) ender = 's' if count > 1 else '' response = discord.Embed(color=0xc6e4b5) response.title = f'💶 You sold {count} {item_o.name}{ender} for {value} {currency}.' else: if not lookup.isdigit(): response = not_found( f'I didn\'t find any {lookup} in your inventory.') else: response = not_found(f'Sell {lookup} of what?') else: response = discord.Embed(color=0xc6e4b5, title='💸 Your inventory is empty...') else: response = error('Nothing inputted.') if is_ongoing(cmd.name, pld.msg.author.id): del_ongoing(cmd.name, pld.msg.author.id) response.set_author(name=pld.msg.author.display_name, icon_url=user_avatar(pld.msg.author)) await pld.msg.channel.send(embed=response)
async def inventory(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ item_core = await get_item_core(cmd.db) reci_core = await get_recipe_core(cmd.db) if pld.msg.mentions: target = pld.msg.mentions[0] else: target = pld.msg.author upgrade_file = await cmd.db.get_profile(target.id, 'upgrades') or {} storage = upgrade_file.get('storage', 0) inv_limit = 64 + (8 * storage) inv = await cmd.db.get_inventory(target.id) total_inv = len(inv) item_o_list = [] item_filter = get_filter(pld.args) for item in inv: item_o = item_core.get_item_by_file_id(item['item_file_id']) add = item_belongs(item_filter, item_o) if item_filter else True if add: item_o_list.append(item_o) item_o_list = sorted(item_o_list, key=attrgetter('value'), reverse=True) item_o_list = sorted(item_o_list, key=attrgetter('name'), reverse=False) item_o_list = sorted(item_o_list, key=attrgetter('rarity'), reverse=True) page = pld.args[0] if pld.args else 1 inv, page = PaginatorCore.paginate(item_o_list, page) start_range, end_range = (page - 1) * 10, page * 10 if inv: all_reci = reci_core.recipes headers = ['Type', 'Item', 'Value', 'Rarity'] to_format = [] total_value = 0 for item_o_item in inv: in_rec = '*' if is_ingredient(all_reci, item_o_item) else '' to_format.append([ item_o_item.type, f'{item_o_item.name}{in_rec}', f'{item_o_item.value}', f'{item_o_item.rarity_name.title()}' ]) for item_o_item in item_o_list: total_value += item_o_item.value output = boop(to_format, column_names=headers) response = discord.Embed(color=0xc16a4f) inv_text = f'Showing items {start_range}-{end_range}.' pronouns = ['You', 'your' ] if target.id == pld.msg.author.id else ['They', 'their'] inv_text += f'\n{pronouns[0]} have {total_inv}/{inv_limit} items in {pronouns[1]} inventory.' inv_text += f'\nTotal value of {pronouns[1]} inventory is {total_value} {cmd.bot.cfg.pref.currency}.' response.add_field(name='📦 Inventory Stats', value=f'```py\n{inv_text}\n```') response.add_field(name=f'📋 Items Currently On Page {page}', value=f'```hs\n{output}\n```', inline=False) 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 collectchain(cmd, message, args): global in_use global in_use_by if in_use: response = discord.Embed(color=0x696969, title='🛠Currently in use. Try Again Later.') response.set_author(name=f'{in_use_by.name}', icon_url=user_avatar(in_use_by)) await message.channel.send(None, embed=response) else: if message.mentions: target = message.mentions[0] else: if args: target = discord.utils.find(lambda x: x.name.lower() == ' '.join(args).lower(), message.guild.members) else: target = message.author if target: start_time = arrow.utcnow().timestamp if message.channel_mentions: target_chn = message.channel_mentions[0] else: target_chn = message.channel collected = 0 collection = cmd.db[cmd.db.db_cfg.database]['MarkovChains'].find_one({'UserID': target.id}) if collection: collection = collection['Chain'] else: collection = [] in_use = True in_use_by = message.author ch_response = discord.Embed(color=0x66CC66, title='📖 Collecting... You will be sent a DM when I\'m done.') await message.channel.send(None, embed=ch_response) async for log in target_chn.history(limit=100000): if log.author.id == target.id: if log.content: if log.content != '': if len(log.content) > 3: if not check_for_bot_prefixes(cmd.bot.get_prefix(message), log.content): if 'http' not in log.content and '```' not in log.content: if '"' not in log.content: content = log.content if log.mentions: for mention in log.mentions: content = content.replace(mention.mention, mention.name) if log.channel_mentions: for mention in log.channel_mentions: content = content.replace(mention.mention, mention.name) unallowed_chars = ['`', '\n', '\\', '\\n'] for char in unallowed_chars: content = content.replace(char, '') if len(content) > 12: if not content.endswith(('.' or '?' or '!')): content += '.' if content not in collection: collection.append(content) collected += 1 if collected >= 5000: break cmd.db[cmd.db.db_cfg.database]['MarkovChains'].delete_one({'UserID': target.id}) data = { 'UserID': target.id, 'Chain': collection } cmd.db[cmd.db.db_cfg.database]['MarkovChains'].insert_one(data) in_use = False in_use_by = None dm_response = discord.Embed(color=0x66CC66, title=f'📖 {target.name}\'s chain is done!') dm_response.add_field(name='Amount Collected', value=f'```\n{collected}\n```') dm_response.add_field(name='Total Amount', value=f'```\n{len(collection)}\n```') dm_response.add_field(name='Time Elapsed', value=f'```\n{arrow.utcnow().timestamp - start_time}s\n```') await message.author.send(None, embed=dm_response) await message.channel.send(None, embed=dm_response) if message.author.id != target.id: tgt_msg = discord.Embed(color=0x66CC66, title=f'📖 {message.author.name} has made a markov chain for you.') await target.send(None, embed=tgt_msg)
async def inspect(cmd: SigmaCommand, message: discord.Message, args: list): item_core = await get_item_core(cmd.db) if args: inv = await cmd.db.get_inventory(message.author) if inv: lookup = ' '.join(args) item_o = item_core.get_item_by_name(lookup) if item_o: item = await cmd.db.get_inventory_item(message.author, item_o.file_id) else: item = None if item: response = item_o.make_inspect_embed(cmd.bot.cfg.pref.currency) stat_coll = cmd.db[cmd.db.db_nam].ItemStatistics all_stats = await stat_coll.find_one( {'UserID': message.author.id}) or {} item_total = 0 all_stat_docs = await stat_coll.find({ item_o.file_id: { '$exists': True } }).to_list(None) for stat_doc in all_stat_docs: item_total += stat_doc.get(item_o.file_id) or 0 stat_count = all_stats.get(item_o.file_id) or 0 footer = f'You Found: {stat_count} | Total Found: {item_total} | ItemID: {item["item_id"]}' response.set_footer(text=footer) else: response = None else: response = None else: response = discord.Embed(color=0xBE1931, title='❗ Nothing inputted.') if not response: lookup = ' '.join(args) item = item_core.get_item_by_name(lookup) if item: if item.rarity != 0: stat_coll = cmd.db[cmd.db.db_nam].ItemStatistics all_stats = await stat_coll.find_one( {'UserID': message.author.id}) or {} item_total = 0 all_stat_docs = await stat_coll.find({ item.file_id: { '$exists': True } }).to_list(None) for stat_doc in all_stat_docs: item_total += stat_doc.get(item.file_id) or 0 stat_count = all_stats.get(item.file_id) or 0 response = item.make_inspect_embed(cmd.bot.cfg.pref.currency) response.set_footer( text=f'You Found: {stat_count} | Total Found: {item_total}' ) else: response = discord.Embed(color=0xBE1931, title='❗ Sorry but that\'s trash.') else: response = discord.Embed(color=0x696969, title=f'🔍 Item not found.') else: response.set_author(name=message.author.display_name, icon_url=user_avatar(message.author)) await message.channel.send(embed=response)
async def combinechains(cmd: SigmaCommand, message: discord.Message, args: list): if len(message.mentions) == 2: target_one = message.mentions[0] target_two = message.mentions[1] chain_one = await cmd.db[cmd.db.db_nam].MarkovChains.find_one( {'user_id': target_one.id}) chain_two = await cmd.db[cmd.db.db_nam].MarkovChains.find_one( {'user_id': target_two.id}) if chain_one and chain_two: await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, 20) string_one = ' '.join(chain_one.get('chain')) string_two = ' '.join(chain_two.get('chain')) with ThreadPoolExecutor() as threads: markov_one = chain_object_cache.get_cache(target_one.id) if not markov_one: chain_task_one = functools.partial(markovify.Text, string_one) markov_one = await cmd.bot.loop.run_in_executor( threads, chain_task_one) chain_object_cache.set_cache(target_one.id, markov_one) markov_two = chain_object_cache.get_cache(target_two.id) if not markov_two: chain_task_two = functools.partial(markovify.Text, string_two) markov_two = await cmd.bot.loop.run_in_executor( threads, chain_task_two) chain_object_cache.set_cache(target_two.id, markov_two) combination = combination_cache.get_cache( f'{target_one}_{target_two}') if not combination: combine_task = functools.partial(markovify.combine, [markov_one, markov_two], [1, 1]) combination = await cmd.bot.loop.run_in_executor( threads, combine_task) combination_cache.set_cache(f'{target_one}_{target_two}', combination) sentence_function = functools.partial( combination.make_short_sentence, 500) sentence = await cmd.bot.loop.run_in_executor( threads, sentence_function) if not sentence: not_enough_data = '😖 I could not think of anything... I need more chain items!' response = discord.Embed(color=0xBE1931, title=not_enough_data) else: icon_choice = secrets.choice([target_one, target_two]) combined_name = combine_names(target_one, target_two) response = discord.Embed(color=0xbdddf4) response.set_author(name=combined_name, icon_url=user_avatar(icon_choice)) response.add_field(name='💭 Hmm... something like...', value=sentence) else: response = discord.Embed( color=0xBE1931, title='❗ One of the users does not have a chain.') else: response = discord.Embed(color=0xBE1931, title='❗ Invalid number of targets.') await message.channel.send(embed=response)
async def send_word_blocker(ev: SigmaEvent, message: discord.Message): if message.guild: if isinstance(message.author, discord.Member): is_owner = message.author.id in ev.bot.cfg.dsc.owners if not message.author.permissions_in( message.channel).administrator or is_owner: prefix = await ev.db.get_prefix(message) if not message.content.startswith(prefix): text = clean_content(message.content.lower()) elements = text.split(' ') blocked_words = await ev.db.get_guild_settings( message.guild.id, 'blocked_words') or [] hard_blocked_words = await ev.db.get_guild_settings( message.guild.id, 'hardblocked_words') or [] remove = False reason = None for word in blocked_words: if word in elements: remove = True reason = word break for word in hard_blocked_words: if word in message.content: remove = True reason = word if remove: try: filter_warn = await ev.db.get_guild_settings( message.guild.id, 'filter_auto_warn') if filter_warn: warn_data = warning_data( message.guild.me, message.author, f'Said "{reason}".') await ev.db[ev.db.db_nam ].Warnings.insert_one(warn_data) await message.delete() title = f'🔥 Your message was deleted for containing "{reason}".' to_author = discord.Embed(color=0xFFCC4D, title=title) try: await message.author.send(embed=to_author) except discord.Forbidden: pass author = f'{message.author.name}#{message.author.discriminator}' title = f'I deleted {author}\'s message for containing "{reason}".' log_embed = discord.Embed( color=0xFFCC4D, timestamp=arrow.utcnow().datetime) log_embed.description = f'Content: {message.content}' log_embed.set_author(name=title, icon_url=user_avatar( message.author)) log_embed.set_footer( text= f'Channel: #{message.channel.name} [{message.channel.id}]' ) await log_event(ev.bot, message.guild, ev.db, log_embed, 'log_filters') except (discord.ClientException, discord.NotFound, discord.Forbidden): pass
async def trivia(cmd: SigmaCommand, message: discord.Message, args: list): global streaks global trivia_cache if not await cmd.bot.cool_down.on_cooldown(cmd.name, message.author): if message.author.id not in ongoing_list: ongoing_list.append(message.author.id) allotted_time = 20 if not trivia_cache: trivia_api_url = 'https://opentdb.com/api.php?amount=50' async with aiohttp.ClientSession() as session: async with session.get(trivia_api_url) as number_get: number_response = await number_get.read() try: data = json.loads(number_response) except json.JSONDecodeError: if message.author.id in ongoing_list: ongoing_list.remove(message.author.id) decode_error = discord.Embed( color=0xBE1931, title='❗ Couldn\'t retrieve a question.') await message.channel.send(embed=decode_error) return trivia_cache += data['results'] data = trivia_cache.pop(secrets.randbelow(len(trivia_cache))) await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, 30) question = data['question'] question = ftfy.fix_text(question) category = data['category'] correct_answer = data['correct_answer'] correct_answer = ftfy.fix_text(correct_answer) incorrect_answers = data['incorrect_answers'] difficulty = data['difficulty'] reward_mult = streaks.get(message.author.id) or 0 kud_reward = int( (awards.get(difficulty) or '10') * (1 + (reward_mult * 0.8))) choice_list = [correct_answer] + incorrect_answers choice_list = shuffle_questions(choice_list) choice_number = 0 choice_lines = [] for choice in choice_list: choice_number += 1 choice_line = f'[{choice_number}] {choice}' choice_lines.append(choice_line) choice_text = '\n'.join(choice_lines) choice_text = ftfy.fix_text(choice_text) if difficulty == 'easy': starter = 'An' else: starter = 'A' question_embed = discord.Embed(color=0xF9F9F9, title='❔ Here\'s a question!') question_embed.description = f'{starter} {difficulty} one from the {category} category.' question_embed.add_field(name='Question', value=question, inline=False) question_embed.add_field(name='Choices', value=f'```py\n{choice_text}\n```', inline=False) question_embed.set_footer( text='Input the number of your chosen answer.') question_embed.set_author(name=message.author.display_name, icon_url=user_avatar(message.author)) await message.channel.send(embed=question_embed) def check_answer(msg): if message.channel.id == msg.channel.id: if message.author.id == msg.author.id: try: int(msg.content) number = True except ValueError: number = False if number or (msg.content.title() in choice_list): correct = True else: correct = False else: correct = False else: correct = False return correct try: answer_message = await cmd.bot.wait_for('message', check=check_answer, timeout=allotted_time) try: answer_index = int(answer_message.content) - 1 except ValueError: answer_index = None correct_index = get_correct_index(choice_list, correct_answer) if answer_index == correct_index or answer_message.content.lower( ) == correct_answer.lower(): streaks.update({message.author.id: reward_mult + 1}) await cmd.db.add_currency(answer_message.author, message.guild, kud_reward) author = answer_message.author.display_name currency = cmd.bot.cfg.pref.currency win_title = f'🎉 Correct, {author}, it was {correct_answer}. You won {kud_reward} {currency}!' final_embed = discord.Embed(color=0x77B255, title=win_title) else: if message.author.id in streaks: streaks.pop(message.author.id) lose_title = f'💣 Ooh, sorry, it was {correct_answer}...' final_embed = discord.Embed(color=0x262626, title=lose_title) await message.channel.send(embed=final_embed) except asyncio.TimeoutError: if message.author.id in streaks: streaks.pop(message.author.id) timeout_title = f'🕙 Time\'s up! It was {correct_answer}...' timeout_embed = discord.Embed(color=0x696969, title=timeout_title) await message.channel.send(embed=timeout_embed) if message.author.id in ongoing_list: ongoing_list.remove(message.author.id) else: ongoing_error = discord.Embed( color=0xBE1931, title='❗ There is one already ongoing.') await message.channel.send(embed=ongoing_error) else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, message.author) on_cooldown = discord.Embed( color=0xccffff, title=f'❄ On cooldown for another {timeout} seconds.') await message.channel.send(embed=on_cooldown)
async def slots(cmd, message, args): currency_icon = cmd.bot.cfg.pref.currency_icon currency = cmd.bot.cfg.pref.currency current_kud = cmd.db.get_currency(message.author, message.guild)['current'] if current_kud >= 10: if not cmd.bot.cooldown.on_cooldown(cmd.name, message.author): cmd.bot.cooldown.set_cooldown(cmd.name, message.author, 60) cmd.db.rmv_currency(message.author, message.guild, 10) out_list = [] for x in range(0, 3): temp_list = [] for y in range(0, 3): symbol_choice = secrets.choice(symbols) temp_list.append(symbol_choice) out_list.append(temp_list) slot_lines = f'⏸{"".join(out_list[0])}⏸' slot_lines += f'\n▶{"".join(out_list[1])}◀' slot_lines += f'\n⏸{"".join(out_list[2])}⏸' combination = out_list[1] if combination[0] == combination[1] == combination[2]: win = True announce = True winnings = int(10 * (symbol_rewards[combination[0]] * 5)) elif combination[0] == combination[1] or combination[0] == combination[2] or combination[1] == combination[2]: if combination[0] == combination[1]: win_comb = combination[0] elif combination[0] == combination[2]: win_comb = combination[0] elif combination[1] == combination[2]: win_comb = combination[1] else: win_comb = None win = True announce = False winnings = int(10 * (symbol_rewards[win_comb] * 2)) else: win = False announce = False winnings = 0 if win: color = 0x5dadec title = '💎 Congrats, you won!' footer = f'{currency_icon} {winnings} {currency} has been awarded.' cmd.db.add_currency(message.author, message.guild, winnings) else: color = 0x232323 title = '💣 Oh my, you lost...' footer = f'{currency_icon} 10 {currency} has been deducted.' if announce: if 'win_channel' in cmd.cfg: target_channel = discord.utils.find(lambda c: c.id == cmd.cfg['win_channel'], cmd.bot.get_all_channels()) announce_embed = discord.Embed(color=0xf9f9f9, title=f'🎰 A user just got 3 {combination[0]}.') announce_embed.set_author(name=message.author.display_name, icon_url=user_avatar(message.author)) announce_embed.set_footer(text=f'On: {message.guild.name}.', icon_url=message.guild.icon_url) await target_channel.send(embed=announce_embed) response = discord.Embed(color=color) response.add_field(name=title, value=slot_lines) response.set_footer(text=footer) else: timeout = cmd.bot.cooldown.get_cooldown(cmd.name, message.author) response = discord.Embed(color=0x696969, title=f'🕙 You can spin again in {timeout} seconds.') else: response = discord.Embed(color=0xa7d28b, title=f'💸 You don\'t have enough {currency}.') await message.channel.send(embed=response)
async def impersonate_local(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ target, limit, beginning = parse_args(pld) if target: if os.path.exists(f'chains/{target.id}.json.gz'): chain_data = await cmd.bot.threader.execute(load, (target.id, )) if chain_data: chain_json = await cmd.bot.threader.execute( deserialize, (chain_data, )) chain = await cmd.bot.threader.execute( markovify.Text.from_dict, (chain_json, )) try: if beginning: sentence_func = chain.make_sentence_with_start sentence_args = ( beginning, False, ) else: sentence_func = chain.make_short_sentence sentence_args = (limit, ) sentence = await cmd.bot.threader.execute( sentence_func, sentence_args) except (KeyError, ValueError, AttributeError): sentence = None except markovify.text.ParamError: if not beginning: sentence = None else: ender = 'word' if len( beginning.split()) == 1 else 'phrase' error_title = f'😖 I could not think of anything with that {ender}.' response = discord.Embed(color=0xBE1931, title=error_title) await pld.msg.channel.send(embed=response) return if not sentence: not_enough_data = '😖 I could not think of anything... I need more chain items!' response = discord.Embed(color=0xBE1931, title=not_enough_data) else: response = discord.Embed(color=0xbdddf4) response.set_author(name=target.name, icon_url=user_avatar(target)) response.add_field(name='💭 Hmm... something like...', value=ensure_length(sentence)) else: response = GenericResponse( f'{target.name}\'s chain has no data.').error() else: response = discord.Embed(color=0x696969) prefix = cmd.db.get_prefix(pld.settings) title = f'🔍 Chain Data Not Found For {target.name}' value = f'You can make one with `{prefix}collectchain @{target.name} #channel`!' response.add_field(name=title, value=value) else: response = GenericResponse('No user targeted.').error() await pld.msg.channel.send(embed=response)
async def liststatuses(cmd: SigmaCommand, message: discord.Message, args: list): status_data = await cmd.db[cmd.db.db_nam].StatusFiles.find({}).to_list(None) if status_data: status_list = [[s['ID'], s['Text']] for s in status_data] status_list = sorted(status_list, key=lambda x: x[1]) total_status = len(status_list) page = args[0] if args else 1 status_list, page = paginate(status_list, page) status_block = boop(status_list, ['ID', 'Text']) response = discord.Embed(color=await get_image_colors(cmd.bot.user.avatar_url)) response.set_author(name=f'{cmd.bot.user.name}\'s Status Rotation Items', icon_url=user_avatar(cmd.bot.user)) response.add_field(name='Info', value=f'Showing {len(status_list)} items out of {total_status} on page {page}.') response.add_field(name="List", value=f'```\n{status_block}\n```', inline=False) else: response = discord.Embed(color=0x696969, title='🔍 No statuses found.') await message.channel.send(embed=response)
async def impersonate(cmd: SigmaCommand, message: discord.Message, args: list): success = False if not await cmd.bot.cool_down.on_cooldown(cmd.name, message.author): if args: if message.mentions: target = message.mentions[0] else: target = discord.utils.find( lambda x: x.name.lower() == ' '.join(args).lower(), message.guild.members) else: target = message.author if target: await cmd.bot.cool_down.set_cooldown(cmd.name, message.author, 20) init_embed = discord.Embed(color=0xbdddf4, title='💭 Hmm... Let me think...') init_message = await message.channel.send(embed=init_embed) chain_data = await cmd.db[cmd.db.db_cfg.database ]['MarkovChains'].find_one( {'UserID': target.id}) if chain_data: if chain_data['Chain']: total_string = ' '.join(chain_data['Chain']) chain_function = functools.partial(markovify.Text, total_string) with ThreadPoolExecutor() as threads: chain = await cmd.bot.loop.run_in_executor( threads, chain_function) sentence_function = functools.partial( chain.make_short_sentence, 500) sentence = await cmd.bot.loop.run_in_executor( threads, sentence_function) if not sentence: response = discord.Embed( color=0xBE1931, title='😖 I could not think of anything...') else: response = discord.Embed(color=0xbdddf4) response.set_author(name=target.name, icon_url=user_avatar(target)) response.add_field(name='💭 Hmm... something like...', value=sentence) success = True else: response = discord.Embed( color=0xBE1931, title=f'❗ {target.name}\'s chain has no data.') else: response = discord.Embed(color=0x696969) prefix = await cmd.db.get_prefix(message) title = f'🔍 Chain Data Not Found For {target.name}' value = f'You can make one with `{prefix}collectchain @{target.name} #channel`!' response.add_field(name=title, value=value) await init_message.edit(embed=response) if cmd.cfg.get('chain_channel') and success: chain_channel_id = cmd.cfg.get('chain_channel') chain_channel = discord.utils.find( lambda x: x.id == chain_channel_id, cmd.bot.get_all_channels()) if chain_channel: cmd.bot.loop.create_task( chain_channel.send(embed=response)) else: no_target = discord.Embed(color=0xBE1931, title='❗ No user targeted.') await message.channel.send(embed=no_target) else: timeout = await cmd.bot.cool_down.get_cooldown(cmd.name, message.author) on_cooldown = discord.Embed( color=0xccffff, title=f'❄ On cooldown for another {timeout} seconds.') await message.channel.send(embed=on_cooldown)
async def cook(cmd, pld): """ :param cmd: The command object referenced in the command. :type cmd: sigma.core.mechanics.command.SigmaCommand :param pld: The payload with execution data and details. :type pld: sigma.core.mechanics.payload.CommandPayload """ ongoing = Ongoing.is_ongoing('profession', pld.msg.author.id) if not ongoing: Ongoing.set_ongoing('profession', pld.msg.author.id) recipe_core = await get_recipe_core(cmd.db) item_core = await get_item_core(cmd.db) if pld.args: lookup = ' '.join(pld.args) recipe = recipe_core.find_recipe(lookup) used_items = [] if recipe: req_satisfied = True for ingredient in recipe.ingredients: user_inv = await cmd.db.get_inventory(pld.msg.author.id) in_inventory = False for item in user_inv: if item['item_file_id'] == ingredient.file_id: used_items.append(item) in_inventory = True break if not in_inventory: req_satisfied = False if req_satisfied: cooked_item_data = item_core.get_item_by_name( recipe.name).generate_inventory_item() await cmd.db.add_to_inventory(pld.msg.author.id, cooked_item_data) await item_core.add_item_statistic(cmd.db, recipe, pld.msg.author) for req_item in used_items: if req_item.get('transferred'): cooked_item_data.update({'transferred': True}) await cmd.db.del_from_inventory( pld.msg.author.id, req_item['item_id']) quality = cook_quality[cooked_item_data['quality']] connector = 'a' if quality[0].lower() in ['a', 'e', 'i', 'o', 'u']: connector = 'an' await cmd.db.add_resource(pld.msg.author.id, 'items', 1, cmd.name, pld.msg, True) head_title = f'{recipe.icon} You made {connector} {quality.lower()} {recipe.name}' response = discord.Embed(color=recipe.color, title=head_title) else: response = GenericResponse( 'You\'re missing ingredients.').error() else: response = GenericResponse('Recipe not found.').not_found() else: response = GenericResponse('Nothing inputted.').error() Ongoing.del_ongoing('profession', pld.msg.author.id) else: response = GenericResponse( "Please wait while your previous item is done being prepared." ).warn() response.set_author(name=pld.msg.author.display_name, icon_url=user_avatar(pld.msg.author)) await pld.msg.channel.send(embed=response)