async def server(self, ctx, *, param): param = int( param.replace('<', '').replace('@', '').replace('!', '').replace('>', '')) s = self.client.get_guild(param) if s == None: await utils.embed_send(ctx, constants.ERROR_SEARCH_FAIL) return title = 'Server: {}'.format(s.name) thumbnail = s.icon_url fields = [['Owner', '<@{}>'.format(s.owner_id), False], [ 'Created', s.created_at.strftime('%d.%m.%Y, (%H:%M)'), True ], ['Members', str(len(s.members)), True], ['Channels', str(len(s.channels)), True], ['Roles', str(len(s.roles)), True], ['Emojis', str(len(s.emojis)), True], [None, True], ['Top 5 | Rank', 'Please wait ...', True], ['Top 5 | XP', 'Please wait ...', True]] footer = {'text': 'ID: {}'.format(s.id)} message = await utils.embed_send( ctx, utils.embed_create(title=title, fields=fields, thumbnail=thumbnail, footer=footer)) leaderboard = self.leaderboard(s) fields[-2] = ['Top 5 | Rank', '\n'.join(leaderboard[0]), True] fields[-1] = ['Top 5 | XP', '\n'.join(leaderboard[1]), True] await message.edit(embed=utils.embed_create( title=title, fields=fields, thumbnail=thumbnail, footer=footer))
async def remove(self, ctx, *, param): param = param.lower().split(' ') if len(param) > 1 and param[0] in LISTS: if param[0] == 'gif' or param[0] == 'emote': constants.FIRE_CON.delete('{}/{}'.format(param[0], param[1])) else: id_ = int(param[1].replace('<', '').replace('@', '').replace( '!', '').replace('>', '')) user = constants.FIRE_CON.get('users/{}'.format(id_)) if user == None: await utils.embed_send( ctx, utils.embed_create( title='User not found.', description= 'Couldn\'t find user with id/mention: `{}`'.format( param[1]))) return caller = constants.FIRE_CON.get('users/{}'.format( ctx.message.author.id)) if caller['rank'] <= user['rank']: await utils.embed_send(ctx, constants.ERROR_PERMISSION_DENIED) return constants.FIRE_CON.update('users/{}'.format(id_), {'rank': 0}) await utils.embed_send( ctx, utils.embed_create(title='Removed: {} from {}'.format( param[1] if param[0] == 'gif' or param[0] == 'emote' else self.client.get_user(id_).display_name, param[0]))) return await utils.embed_send(ctx, constants.ERROR_MISSING_PARAM)
async def reload(self, ctx, *, param): param = param.lower().split(' ') if self.cmds == {}: self.cmds = utils.load_cmd_meta(self.client) if param[0].lower() == 'all': param = self.cmds.keys() success = [] failed = [] for p in param: if p in self.cmds.keys(): cog = 'Bot.Cogs.' + type(self.cmds[p]).__name__ try: self.client.reload_extension(cog) utils.log( '> [Reload] Reloaded extension with key \'{}\''.format( p)) success.append(p) except commands.ExtensionNotLoaded: try: self.client.load_extension(cog) utils.log( '> [Reload] Reloaded extension with key \'{}\''. format(p)) success.append(p) except Exception as ex: utils.warn( '> [Reload] Failed to reload extension with key {}\n{}' .format(p, type(ex).__name__)) failed.append(p) except Exception as ex2: utils.warn( '> [Reload] Failed to reload extension with key {}\n{}' .format(p, type(ex2).__name__)) failed.append(p) else: utils.warn( '> [Reload] Failed to reload extension with key {}\nNo such Extension.' .format(p)) failed.append(p) if len(failed) == 0: await utils.embed_send( ctx, utils.embed_create( title='Reload: Success', description= 'Successfully reloaded modules with following keys:\n{}'. format(', '.join(['`{}`'.format(x) for x in success])))) return else: await utils.embed_send( ctx, utils.embed_create( title='Reload: Failed', description= 'Failed to reload {} modules ({} succeeded) with following keys:\n{}' .format(len(failed), len(success), ', '.join(['`{}`'.format(x) for x in failed]))))
async def add(self, ctx, *, param): param = param.lower().split(' ') for (k, amount) in LISTS: if param[0] == k and len(param) < amount: await utils.embed_send(ctx, constants.ERROR_MISSING_PARAM) return elif param[0] == k: break if param[0] == 'gif' or param[0] == 'emote': key = param[1] constants.FIRE_CON.setValue('{}/{}'.format(param[0], key), param[2]) if param[0] == 'gif': constants.GIF_DATA[key] = param[2] await utils.embed_send(ctx, utils.embed_create(title='Added {}'.format(param[0]), description='{}, added a {} with the key `{}`.'.format(ctx.message.author.mention, param[0], param[1]))) return rank = None for (i, x) in constants.RANK_MAP.items(): if x.lower() == param[0]: rank = i param[0] = x break if rank == None: await utils.embed_send(ctx, utils.embed_create(title='Add : Failed', description='Couldn\'t find list. Please check your spelling or contact an admin!')) return caller_key = str(ctx.message.author.id) user_key = param[1].replace('<', '').replace('@', '').replace('!', '').replace('>', '') user = self.client.get_user(int(user_key)) if user_key in constants.USER_DATA.keys(): data = constants.USER_DATA[user_key] else: if user == None: await utils.embed_send(ctx, utils.embed_create(title='User not found.', description='Couldn\'t find user with id/mention: `{}`'.format(param[1]))) return data = deepcopy(constants.EMPTY_USER) constants.USER_DATA[user_key] = data if caller_key in constants.USER_DATA.keys(): caller = constants.USER_DATA[caller_key] print(caller) if caller['rank'] <= rank or caller['rank'] <= data['rank']: await utils.embed_send(ctx, constants.ERROR_PERMISSION_DENIED) return else: constants.USER_DATA[caller_key] = deepcopy(constants.EMPTY_USER) await utils.embed_send(ctx, constants.ERROR_PERMISSION_DENIED) return data['rank'] = rank constants.USER_DATA[user_key] = data await utils.embed_send(ctx, utils.embed_create(title='Added {} to role {}'.format(user.display_name, param[0]), description='{} gave {} the role `{}`.'.format(ctx.message.author.mention, user.mention, param[0]),))
async def status(self, ctx, *, param): param = param.split(' ') for i in range(0, len(param)): param[i] = param[i].replace('<', '').replace('@', '').replace( '!', '').replace('>', '') for p in param: try: id_ = int(p) except: id_ = -1 user = self.client.get_user(id_) if user == None: await utils.embed_send( ctx, utils.embed_create( title='Profile not found.', description='Couldn\'t find user with id/mention: `{}`' .format(p))) elif not user.bot: key = str(id_) if key in constants.USER_DATA.keys(): data = deepcopy(constants.USER_DATA[key]) else: data = constants.EMPTY_USER constants.USER_DATA[key] = data mem = ctx.message.guild.get_member(id_) title = 'Profile: {}'.format(user.display_name if mem == None else mem.display_name) thumbnail = user.avatar_url lvl = utils.level(data['xp']) description = '**Level: ** {} ({}%)'.format( lvl, floor((data['xp'] - utils.total_exp(lvl)) / utils.total_exp(lvl + 1) * 100)) if data['prestige'] > 0: description += ' | **Prestige: ** {}'.format( data['prestige']) description += '\n**Rank: ** {}\n**Created Account: ** {}'.format( constants.RANK_MAP[data['rank']], user.created_at.strftime('%d.%m.%Y, (%H:%M)')) fields = [] if data['description'] != '-': fields.append(['Description', data['description'], False]) await utils.embed_send( ctx, utils.embed_create(title=title, description=description, fields=fields, thumbnail=thumbnail))
def help(self, footer): title = 'Kohaku' description = 'Wasshoi~!\n Type `{}help <command>` to see more details about a particular command.'.format( constants.INVOKE) fields = [ [None, False], [ ':clipboard: General', '`help`,`status`, `server`, `ping`, `gif`, `edit`', False ], [':scroll: Game Information', '`animalcrossing`', True], [ ':game_die: Games', '`magic8ball`, `neverhaveiever`, `wouldyourather`, `rockpaperscissors`, `love`, `roll`', True ], [None, False], [ ':gear: Source', '[Spaghetti code]({}), [Upcoming Features]({})'.format( constants.GITHUB_URL_CODE, constants.GITHUB_URL_BOARD), False ] ] return utils.embed_create(title=title, description=description, fields=fields, footer=footer)
def help(self, footer): title = 'Help Info: {}timeout'.format(constants.INVOKE) description = 'Timeouts a user from using commands\nCan only be used by moderators or higher!\n\n**Usage: ** `{}timeout` `<mention/id>` `<seconds>`'.format( constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
async def search_song(self, ctx, param): songs = self.resource['songs'] data = await self.search_by_exact_name_en_n_de(songs, param) if data == {'en': None, 'de': None}: data = await self.search_by_part_name_en_n_de(songs, param) if data == {'en': None, 'de': None}: return False if data['de'] != None: data = utils.json_load_url(data['de']['url']) else: data = utils.json_load_url(data['en']['url']) if data == None: await utils.embed_send(ctx, constants.ERROR_WHOOPS) return True t = ':flag_us: {}'.format(data['name']['en']) d = ':flag_de: _{}_\n[MP3]({})'.format(data['name']['de'], data['music']) await utils.embed_send( ctx, utils.embed_create(title=t, description=d, image=data['image'])) return True
def help(self, footer): title = 'Help Info: {}animalcrossing'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' possibilities = [ 'art - Shows a list of all artworks', 'fossil - Shows a list of all fossil', 'song - Shows a list of all songs', '<fish>/<bug>/<sea creature> - Looks up a specific critter', '<month> - Shows all critter for the month', '<song> - Looks up a specific song', '<fossil> - Looks up a specific fossil', '<villager> - Looks up a specific villager.' ] description = 'This command is connected to the game \'Animal Crossing : New Horizons\' and can show information regarding this game.\n\n{}**Usage: ** \n{}'.format( alias, '\n'.join([ '`{}animalcrossing` {}'.format(constants.INVOKE, x) for x in possibilities ])) return utils.embed_create(title=title, description=description, footer=footer)
async def search_fossil(self, ctx, param): fossils = self.resource['fossils'] data = await self.search_by_exact_name_en_n_de(fossils, param) if data == {'en': None, 'de': None}: data = await self.search_by_part_name_en_n_de(fossils, param) if data == {'en': None, 'de': None}: return False if data['de'] != None: data = utils.json_load_url(data['de']['url']) else: data = utils.json_load_url(data['en']['url']) if data == None: await utils.embed_send(ctx, constants.ERROR_WHOOPS) return True t = ':flag_us: {}'.format(data['name']['en']) d = ':flag_de: _{}_\n{} {}'.format(data['name']['de'], data['price'], self.sternis) fields = [ ['Set', data['group'].capitalize(), False], ['Blathers\' phrase', data['museums-phrase'], False], ] await utils.embed_send( ctx, utils.embed_create(title=t, description=d, fields=fields, thumbnail=data['image'])) return True
async def love(self, ctx, *, param): param = param.replace('<', '').replace('@', '').replace('!', '').replace('>', '') if param != 'everyone': try: user = self.client.get_user( int( param.replace('<', '').replace('@', '').replace( '!', '').replace('>', ''))) except: user = None if user == None: await utils.embed_send(ctx, constants.ERROR_SEARCH_FAIL) return perc = randint(0, 101) if perc == 101: description = ':heart: • The love between {} and {} is very strong! Their love is infinite!'.format( ctx.message.author.mention, user.mention) else: description = ':heart: • There is a {}% chance of love between {} and {}'.format( perc, ctx.message.author.mention, user.mention) else: description = ':heart: • {} loves everybody equally for at least {}%'.format( ctx.message.author.mention, randint(0, 100)) await utils.embed_send(ctx, utils.embed_create(description=description))
def help_default(self): return [ utils.embed_create( title='**Under Construction**', description= 'Either Nia forgot this embed, this embed is still under construction or something went terribly wrong ewe.' ), None ]
def help(self, footer): title = 'Help Info: {}neverhaveiever'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join(['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Selects a specific scenario.\n If you never did that, you pass ❌. But if you did do it at some point in your life: Drink! 🍹\n\n{}**Usage: ** `{}neverhaveiever`'.format(alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}add'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join(['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Adds someone / something to a list.\nCan only be used by admins or higher!\nLists are: gif, emote and the specific ranks. Gif and emote require a additional key.\n\n{}**Usage: ** `{}add` `<list>` `(<key>)` `<gif-url/emote/person>`'.format(alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
async def update(self, ctx, *, param): param = param.lower().split(' ') if self.cmds == {}: self.cmds = utils.load_cmd_meta(self.client) if param[0] == 'all': param = list( filter( lambda x: type(self.cmds[x]) in self.types, utils.load_cmd_meta(self.client, with_aliases=False).keys()) ) # Please don't update one resource more then one time, thanks <3 success = [] failed = [] message = await utils.embed_send( ctx, utils.embed_create(title='Updating...', description='Updating {} modules.'.format( len(param)))) start = time.time() for arg in param: if arg in self.cmds.keys() and type(self.cmds[arg]) in self.types: try: await self.cmds[arg].update() success.append(arg) except: failed.append(arg) else: failed.append(arg) footer = {'text': 'Time: {}s'.format(round(time.time() - start, 2))} if len(failed) == 0: await message.edit(embed=utils.embed_create( title='Update : Success', description='Updated successfully {} modules.'.format( len(success)), footer=footer)) else: await message.edit(embed=utils.embed_create( title='Update : Failed', description= 'Couldn\'t update {} modules ({} successfull).\nFailed modules were with the following keys:\n{}' .format(len(failed), len(success), ', '.join( ['`{}`'.format(x) for x in failed])), footer=footer))
async def search_fish(self, ctx, param): fishes = self.resource['fishes'] data = await self.search_by_exact_name_en_n_de(fishes, param) if data == {'en': None, 'de': None}: data = await self.search_by_part_name_en_n_de(fishes, param) if data == {'en': None, 'de': None}: return False if data['de'] != None: data = utils.json_load_url(data['de']['url']) else: data = utils.json_load_url(data['en']['url']) if data == None: await utils.embed_send(ctx, constants.ERROR_WHOOPS) return True t = ':flag_us: {}'.format(data['name']['en']) d = ':flag_de: _{}_\n{} {}'.format(data['name']['de'], data['price'], self.sternis) north = 'ALL YEAR' if data['availability']['months-northern'] == [ x for x in range(1, 13) ] else ' '.join([ calendar.month_abbr[x].upper() for x in data['availability']['months-northern'] ]) south = 'ALL YEAR' if data['availability']['months-southern'] == [ x for x in range(1, 13) ] else ' '.join([ calendar.month_abbr[x].upper() for x in data['availability']['months-southern'] ]) fields = [ [ 'Location', '**Place:** {}\n**Times:** {}\n **Shadow:** {}\n**Rarity:** {}' .format(data['availability']['location'], data['availability']['time'], data['shadow'], data['availability']['rarity']), False ], [ 'Months', ':snowflake: :high_brightness: {}'.format(north) if north == south else ':snowflake: {}\n:high_brightness: {}'.format( north, south), False ], ['Catchphrase', data['catch-phrase'], False], ['Blathers\' phrase', data['museums-phrase'], False] ] await utils.embed_send( ctx, utils.embed_create(title=t, description=d, fields=fields, footer=self.critter_month_footer, thumbnail=data['icon'])) return True
async def gif(self, ctx, *, param): gifs = utils.json_load_url(constants.GIF_URL.format(param)) if gifs == None: await utils.embed_send(ctx, constants.ERROR_WHOOPS) return if len(gifs['results']) == 0: await utils.embed_send(ctx, constants.ERROR_SEARCH_FAIL) return i = random.randint(0, len(gifs['results']) - 1) gif = gifs['results'][i]['media'][0]['gif'] await utils.embed_send(ctx, utils.embed_create(image=gif['url']))
def help(self, footer): title = 'Help Info: {}rockpaperscissors'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Let\'s you play \'rock-paper-scissors\' with Kohaku.\n\n{}**Usage: ** `{}rockpaperscissors`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}remove'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Remove someone / something of a list.\nCan only be used by admins or higher!\nLists are: gif, emote and the specific ranks.\n\n{}**Usage: ** `{}remove` `<list>` `<key/person>`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}wouldyourather'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Asks you a specific \'A/B\'-question.\n\n{}**Usage: ** `{}wouldyourather`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}magic8ball'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Answers your \'yes/no\'-questions.\n\n{}**Usage: ** `{}magic8ball`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}server-list'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = '**Admin only: ** Shows a list of servers which have access to Kohaku.\n\n{}**Usage: ** `{}server-list`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}server'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Shows a quick information sheet about the server.\nNot available in DMs!\n\n{}\n**Usage: ** `{}server (<id>)`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}reload'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Reloads a command / module\nSending with the keyword `all` will reload all commands / modules.\n Can only be used by admins or higher!\n\n{}**Usage: ** `{}reload` `[<cmd/module>]`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}status'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Shows the profile(s) of named user(s).\nSending without parameters will show the profile of the author.\n{}\n**Usage: ** `{}status` `([<mention>/<id>])`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}ping'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Pings Kohaku and returns the ping in ms.\n\n{}**Usage: ** `{}ping`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}leave'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = '**Owner only:** Leaves specific Server.\n\n{}**Usage: ** `{}leave (<id>)`\n**Warning: ** No id results in leaving the server which the message origin from.'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}love'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Shows how much love is currently possible between you and a mentioned user.\n\n{}**Usage: ** `{}love` `<id/mention>`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}update'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Update resources for a module.\nSending the key `all` will update all resources.\nCan only be used by moderators or higher!\n\n{}**Usage: ** `{}update` `<alias/name>`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)
def help(self, footer): title = 'Help Info: {}gif'.format(constants.INVOKE) if ALIASES != None and ALIASES != []: alias = '**Aliases: ** {}\n'.format(' '.join( ['`{}`'.format(x) for x in ALIASES])) else: alias = '' description = 'Search gifs (on tenor) with the given parameter and returns a random gif from this list.\n\n{}**Usage: ** `{}gif <parameter>`'.format( alias, constants.INVOKE) return utils.embed_create(title=title, description=description, footer=footer)