async def description(client, message): prefix = client.command_processer.get_prefix_for(message) return Embed('ping', ('Ping - Pong?\n' f'Usage: `{prefix}ping`'), color=FLAN_HELP_COLOR)
async def description(self, message): return Embed( title='tag-all', color=colourfunc(message=message), description="Do `m!tag <name>` to list all tag", )
async def description(self, message): return Embed( title='tag-info', color=colourfunc(message=message), description="Do `m!tag-info <name>`", )
async def docs(): """Sends a link to hata's documentation.""" return Embed(description=f'[hata docs]({LINK__HATA_DOCS})', color=COLOR__KOISHI_HELP)
async def paste(): """A link to our paste service.""" return Embed(description=f'[Paste link]({LINK__PASTE})', color=COLOR__KOISHI_HELP)
async def command_error_handler(ctx, exception): if ctx.guild is not GUILD__NEKO_DUNGEON: return False with StringIO() as buffer: await KOKORO.render_exc_async(exception,[ ctx.client.full_name, ' ignores an occurred exception at command ', repr(ctx.command), '\n\nMessage details:\nGuild: ', repr(ctx.guild), '\nChannel: ', repr(ctx.channel), '\nAuthor: ', ctx.author.full_name, ' (', repr(ctx.author.id), ')\nContent: ', repr(ctx.content), '\n```py\n'], '```', file=buffer) buffer.seek(0) lines = buffer.readlines() pages = [] page_length = 0 page_contents = [] index = 0 limit = len(lines) while True: if index == limit: embed = Embed(description=''.join(page_contents)) pages.append(embed) page_contents = None break line = lines[index] index = index+1 line_length = len(line) # long line check, should not happen if line_length > 500: line = line[:500]+'...\n' line_length = 504 if page_length+line_length > 1997: if index == limit: # If we are at the last element, we don\'t need to shard up, # because the last element is always '```' page_contents.append(line) embed = Embed(description=''.join(page_contents)) pages.append(embed) page_contents = None break page_contents.append('```') embed = Embed(description=''.join(page_contents)) pages.append(embed) page_contents.clear() page_contents.append('```py\n') page_contents.append(line) page_length = 6+line_length continue page_contents.append(line) page_length += line_length continue limit = len(pages) index = 0 while index < limit: embed = pages[index] index += 1 embed.add_footer(f'page {index}/{limit}') await Pagination(ctx.client, ctx.channel, pages) return True
async def hata(): """Link to my wrapper's git repository.""" return Embed(description=f'[hata repository]({LINK__HATA_GIT})', color=COLOR__KOISHI_HELP)
def build_sticker_embed(sticker): sticker_url = sticker.url_as(size=4096) description_parts = [] sticker_description = sticker.description if (sticker_description is not None): description_parts.append(sticker_description) description_parts.append('\n\n') tags = sticker.tags if (tags is not None): description_parts.append('**Tags:**: ') description_parts.append(', '.join(sorted(tags))) description_parts.append('\n') description_parts.append('**Id**: ') description_parts.append(str(sticker.id)) description_parts.append('\n') created_at = sticker.created_at description_parts.append('**Created at:** ') description_parts.append(created_at.__format__(DATETIME_FORMAT_CODE)) description_parts.append(' *[') description_parts.append(elapsed_time(created_at)) description_parts.append(']*\n') sticker_type = sticker.type description_parts.append('**Type:** ') description_parts.append(sticker_type.name) description_parts.append(' (') description_parts.append(str(sticker_type.value)) description_parts.append(')\n') sticker_format = sticker.format description_parts.append('**Format:** ') description_parts.append(sticker_format.name) description_parts.append(' (') description_parts.append(str(sticker_format.value)) description_parts.append(')') sort_value = sticker.sort_value if sort_value: description_parts.append('\n**Sort value:** ') description_parts.append(str(sort_value)) user = sticker.user if (user is not ZEROUSER): description_parts.append('\n**Creator:** ') description_parts.append(user.full_name) description_parts.append(' (') description_parts.append(str(user.id)) description_parts.append(')') guild_id = sticker.guild_id if guild_id: description_parts.append('\n**Guild id:** ') description_parts.append(str(guild_id)) pack_id = sticker.pack_id if pack_id: description_parts.append('\n**pack id:** ') description_parts.append(str(pack_id)) description = ''.join(description_parts) embed = Embed(sticker.name, description, url=sticker_url) if (sticker_format is StickerFormat.png) or (sticker_format is StickerFormat.apng): embed.add_image(sticker_url) return embed
async def message_( client, event, message: ('str', 'Link to the message'), raw: ('bool', 'Should display json?') = True, ): """Shows up the message's payload.""" if not event.user.has_role(ROLE__NEKO_DUNGEON__TESTER): abort( f'You must have {ROLE__NEKO_DUNGEON__TESTER.mention} to invoke this command.' ) if not event.channel.cached_permissions_for(client).can_send_messages: abort('I need `send messages` permission to execute this command.') message_reference = parse_message_reference(message) if message_reference is None: abort('Could not identify the message.') guild_id, channel_id, message_id = message_reference try: message = MESSAGES[message_id] except KeyError: if channel_id: try: channel = CHANNELS[channel_id] except KeyError: abort('I have no access to the channel.') return else: channel = event.channel if not channel.cached_permissions_for(client).can_read_message_history: abort('I have no permission to get that message.') # We only really need `channel_id` and `guild_id`, so we can ignore `guild_id`. if raw: getter_coroutine = client.http.message_get(channel.id, message_id) else: getter_coroutine = client.message_get(channel, message_id) else: if raw: getter_coroutine = client.http.message_get(message.channel.id, message_id) else: getter_coroutine = None if (getter_coroutine is not None): try: response = await getter_coroutine if raw: data = response else: message = response except ConnectionError: # No internet return except DiscordException as err: if err.code in ( ERROR_CODES.unknown_channel, # message deleted ERROR_CODES.unknown_message, # channel deleted ): # The message is already deleted. abort('The referenced message is already yeeted.') if err.code == ERROR_CODES.missing_access: # client removed abort('The client is not in the guild / channel') if err.code == ERROR_CODES.missing_permissions: # permissions changed meanwhile abort('I have no permission to get that message.') raise if raw: chunks = cchunkify( json.dumps(data, indent=4, sort_keys=True).splitlines()) else: chunks = pchunkify(message) pages = [Embed(description=chunk) for chunk in chunks] await Pagination(client, event, pages)
async def command(client, message, cards_name): while True: attachments = message.attachments if attachments is None: content = 'The message has no attachment provided.' break if len(attachments) > 1: content = 'The message has more attachmemnts.' attachment = attachments[0] name = attachment.name extension = os.path.splitext(name)[1].lower() if extension not in ('.png', '.jpg', '.jpeg', '.bmp', '.mp4', '.gif'): # are there more? content = 'You sure the message format is an image format?\n If you are please request adding it.' break if name in PROTECTED_FILE_NAMES: content = 'The file\'s name is same as a protected file\'s name.' break card = CARDS_BY_NAME.get(cards_name.lower()) if card is None: content = 'Could not find a card with that name.' break actual_image_name = card.image_name file_path = os.path.join(CHESUTO_FOLDER, name) exists = os.path.exists(file_path) should_dump = True if actual_image_name is None: if exists: content = 'A file already exists with that name, if you overwrite it, more cards will have the same ' \ 'image.\nAre you sure?' else: content = None else: if exists: if actual_image_name == name: content = 'Are you sure at overwriting the card\'s image?' should_dump = False else: content = 'A file with that name already exists.\nIf you overwrite this card\'s image like that, ' \ 'you will endup with more cards with the same image. Are you sure?' else: content = 'The card has an image named differently. Are you sure like this?' if (content is not None): message = await client.message_create(message.channel, embed=Embed( description=content, color=CHESUTO_COLOR)) for emoji in ADD_IMAGE_EMOJIS: await client.reaction_add(message, emoji) try: event = await wait_for_reaction(client, message, ADD_IMAGE_CHECKER, 40.) except TimeoutError: emoji = ADD_IMAGE_CANCEL else: emoji = event.emoji await client.message_delete(message) if emoji is ADD_IMAGE_CANCEL: content = 'Cancelled.' break image_data = await client.download_attachment(attachment) with (await AsyncIO(file_path, 'wb')) as file: await file.write(image_data) if should_dump: card.image_name = name await Card.dump_cards(KOKORO) content = f'Image successfully added for {card.name}.' break message = await client.message_create(message.channel, embed=Embed(description=content, color=CHESUTO_COLOR)) await sleep(30.) await client.message_delete(message) return
async def command(client, message, content): result = [] if content: rarity = Rarity.BY_NAME.get(content.lower()) if rarity is None: if len(content) > 50: content = content[:50] + '...' result.append( Embed(f'{content!r} is not a rarity', color=CHESUTO_COLOR)) else: filtered = [] for card in CARDS_BY_NAME.values(): if card.rarity is rarity: if card.image_name is None: continue filtered.append(card) continue title = f'Checklist for {rarity.name}' limit = len(filtered) if limit: parts = [] index = 1 card = filtered[0] name = card.name length = len(name) if length > EMBED_NAME_LENGTH: name = name[:EMBED_NAME_LENGTH] + '...' length = 203 parts.append(name) while True: if index == limit: break card = filtered[index] index = index + 1 name = card.name name_ln = len(name) if name_ln > EMBED_NAME_LENGTH: name = name[:EMBED_NAME_LENGTH] + '...' name_ln = 203 length = length + name_ln + 1 if length > 2000: result.append( Embed(title, ''.join(parts), color=CHESUTO_COLOR)) length = name_ln parts.clear() parts.append(name) continue parts.append('\n') parts.append(name) continue if parts: result.append( Embed(title, ''.join(parts), color=CHESUTO_COLOR)) parts = None else: result.append(Embed(title, color=CHESUTO_COLOR)) else: filtered = tuple([] for x in range(len(Rarity.INSTANCES))) for card in CARDS_BY_NAME.values(): if card.image_name is None: continue filtered[card.rarity.index].append(card) continue title = 'Checklist' parts = [] length = 0 for rarity_index in range(len(filtered)): container = filtered[rarity_index] limit = len(container) if limit == 0: continue if length > 1500: result.append( Embed(title, ''.join(parts), color=CHESUTO_COLOR)) length = 0 parts.clear() else: parts.append('\n\n') length = length + 2 rarity_name = f'**{Rarity.INSTANCES[rarity_index].name}**\n\n' length = length + len(rarity_name) parts.append(rarity_name) card = container[0] name = card.name name_ln = len(name) if name_ln > EMBED_NAME_LENGTH: name = name[:EMBED_NAME_LENGTH] + '...' name_ln = 203 length = length + name_ln parts.append(name) index = 1 while True: if index == limit: break card = container[index] index = index + 1 name = card.name name_ln = len(name) if name_ln > EMBED_NAME_LENGTH: name = name[:EMBED_NAME_LENGTH] + '...' name_ln = 203 length = length + 1 + name_ln if length > 2000: result.append( Embed(title, ''.join(parts), color=CHESUTO_COLOR)) length = len(rarity_name) + name_ln parts.clear() parts.append(rarity_name) parts.append(name) continue parts.append('\n') parts.append(name) continue if parts: result.append(Embed(title, ''.join(parts), color=CHESUTO_COLOR)) parts = None index = 0 limit = len(result) while True: if index == limit: break embed = result[index] index = index + 1 embed.add_footer(f'Page: {index}/{limit}') await Pagination(client, message.channel, result) return
async def description(client, message): return Embed('showcard', ('Shows the specified card by it\'s name.\n' f'Usage: `{FLAN_PREFIX}showcard *name*`'), color=FLAN_HELP_COLOR)
async def command(client, message): try: await client.message_at_index(message.channel, 1000) except IndexError: pass await client.message_delete(message) messages = [] for message_ in message.channel.messages: try: profile = message_.author.guild_profiles[CARDS_ROLE.guild] except KeyError: continue profile_roles = profile.roles if (profile_roles is None) or (CARDS_ROLE not in profile_roles): continue messages.append(message_) new_ = 0 modified_ = 0 description_parts = [] for message_ in messages: lines = message_.content.split('\n') next_id = message_.id state = 0 #parse header description_parts.clear() for line in lines: if line == '<:nothing:562509134654865418>': line = '' if not line and description_parts: description = '\n'.join(description_parts) description_parts.clear() if Card.update(description, next_id, name, rarity): new_ += 1 next_id += 1 else: modified_ += 1 state = 0 continue if state == 0: parsed = CARD_HDR_RP.fullmatch(line) if parsed is None: continue name, special_rarity, rarity = parsed.groups() if special_rarity is None: special_rarity = -1 else: special_rarity = special_rarity.lower() if special_rarity == 'token': special_rarity = 0 elif special_rarity == 'passive': special_rarity = 1 else: special_rarity = -1 if special_rarity == -1: if rarity is None: special_rarity = 0 else: rarity = rarity.lower() if special_rarity != -1: try: rarity = Rarity.INSTANCES[special_rarity] except IndexError: continue else: try: rarity = Rarity.BY_NAME[rarity] except KeyError: continue state = 1 #parse description continue if state == 1: description_parts.append(line) continue if description_parts: description = '\n'.join(description_parts) description_parts.clear() if Card.update(description, next_id, name, rarity): new_ += 1 else: modified_ += 1 del description_parts if new_ or modified_: await Card.dump_cards(KOKORO) message = await client.message_create( message.channel, embed=Embed(None, f'modified: {modified_}\nnew: {new_}', color=CHESUTO_COLOR)) await sleep(30., KOKORO) await client.message_delete(message) return
async def description(client, message): prefix = client.command_processer.get_prefix_for(message) return Embed('bgms', ('Lists the chesuto bgms.\n' f'Usage: `{prefix}bgms`'), color=FLAN_HELP_COLOR)
async def description(client, message): prefix = client.command_processer.get_prefix_for(message) return Embed('love', ('How much you two fit together?\n' f'Usage: `{prefix}user *user*`\n'), color=GAMES_COLOR)
async def user_( client, event, user: ('user', '*spy?*') = None, ): """Shows some information about your or about the selected user.""" if user is None: user = event.user guild = event.guild embed = Embed(user.full_name) created_at = user.created_at embed.add_field( 'User Information', f'Created: {created_at:{DATETIME_FORMAT_CODE}} [*{elapsed_time(created_at)} ago*]\n' f'Profile: {user:m}\n' f'ID: {user.id}') if guild is None: profile = None else: profile = user.guild_profiles.get(guild, None) if profile is None: if user.avatar_type is ICON_TYPE_NONE: color = user.default_avatar.color else: color = user.avatar_hash & 0xFFFFFF embed.color = color else: embed.color = user.color_at(guild) roles = profile.roles if roles is None: roles = '*none*' else: roles.sort() roles = ', '.join(role.mention for role in reversed(roles)) text = [] if profile.nick is not None: text.append(f'Nick: {profile.nick}') if profile.joined_at is None: await client.guild_user_get(user.id) # Joined at can be `None` if the user is in lurking mode. joined_at = profile.joined_at if joined_at is not None: text.append( f'Joined: {joined_at:{DATETIME_FORMAT_CODE}} [*{elapsed_time(joined_at)} ago*]' ) boosts_since = profile.boosts_since if (boosts_since is not None): text.append( f'Booster since: {boosts_since:{DATETIME_FORMAT_CODE}} [*{elapsed_time(boosts_since)}*]' ) text.append(f'Roles: {roles}') embed.add_field('In guild profile', '\n'.join(text)) embed.add_thumbnail(user.avatar_url_as(size=128)) return embed
async def pat(self, message, content): await self.message_create( message.channel, embed=Embed(description=f"{self:m} pats {message.author:m}"))
async def add_bot_channel_name(client, message, weight: int, name): """ Adds the given channel name to the bot channel names. When adding a command please also define weight and not only name as: `weight | name` """ if EDIT_LOCK.locked(): await Closer( client, message.channel, Embed('Ohoho', 'A bot channel editing is already taking place.')) return async with EDIT_LOCK: name = escape_name(name) if not 2 <= len(name) <= 100: await Closer(client, message.channell, Embed(f'Too long or short name', name)) return names = await read_channels() close_matches = get_close_matches( name, [describer.name for describer in names], n=1, cutoff=0.8) if not close_matches: overwrite = False embed = Embed( 'Add bot channel name', f'Would you like to add a channel name:\n{name}\nWith weight of {weight}.' ) elif close_matches[0] == name: overwrite = True embed = Embed( 'Add bot channel name', f'Would you like to overwrite the following bot channel name:\n' f'{name}\n' f'To weight of {weight}.') else: overwrite = False embed = Embed( 'Add bot channel name', f'There is a familiar channel name already added: {close_matches[0]}\n' f'Would you like to overwrite the following bot channel name:\n' f'{name}\n' f'To weight of {weight}.') message = await client.message_create(message.channel, embed=embed, components=ADD_COMPONENTS) try: event = await wait_for_component_interaction( message, timeout=300., check=check_staff_role) except TimeoutError: event = None cancelled = False else: cancelled = (event.interaction == ADD_BUTTON_CANCEL) if cancelled: footer = 'Name adding cancelled.' else: if overwrite: for describer in names: if describer.name == describer: describer.weight = weight footer = 'Name overwritten successfully.' else: describer = ChannelNameDescriber.from_name_and_weight( name, weight) names.append(describer) footer = 'Name added successfully.' await write_channels(names) embed.add_footer(footer) if event is None: await client.message_edit(message, embed=embed, components=None) else: await client.interaction_component_message_edit(event, embed=embed, components=None)
async def embed_abort(client, event): """embed abortion.""" abort(embed=Embed('cake'))
async def command(client, message): await client.typing(message.channel) process_cpu_usage = await CpuUsage() description = [] description.append('**System info**:\n' \ 'Platform: ') description.append(sys.platform) description.append('\n' \ 'Cores: ') description.append(repr(psutil.cpu_count(logical=False))) description.append('\n' \ 'Threads: ') description.append(repr(psutil.cpu_count(logical=True))) description.append('\n' \ 'Max CPU frequence: ') description.append(CPU_MAX_FREQUENCE.__format__('.2f')) description.append('MHz\n\n' \ '**Memory and swap**:\n' \ 'Memory total: ') memory = psutil.virtual_memory() description.append((memory.total / (1 << 20)).__format__('.2f')) description.append('MB\n' \ 'Memory used: ') description.append((memory.used / (1 << 20)).__format__('.2f')) description.append('MB\n' \ 'Memory percent: ') description.append(memory.percent.__format__('.2f')) description.append('%\n' \ 'Swap total: ') swap = psutil.swap_memory() description.append((swap.total / (1 << 20)).__format__('.2f')) description.append('MB\n' \ 'Swap used: ') description.append((swap.used / (1 << 20)).__format__('.2f')) description.append('MB\n' \ 'Swap percent: ') description.append(swap.percent.__format__('.2f')) description.append('%\n' \ '\n' \ '**Process info**:\n' \ 'Name: ') description.append(PROCESS.name()) description.append('\n' \ 'PID: ') description.append(repr(PROCESS_PID)) description.append('\n' \ 'File descriptor count: ') description.append(repr(PROCESS.num_fds())) description.append('\n' \ 'Thread count: ') description.append(repr(PROCESS.num_threads())) description.append('\n' \ 'Created: ') description.append(elapsed_time(datetime.fromtimestamp(PROCESS.create_time()))) description.append(' ago\n' \ '\n' \ '**CPU times:**\n' \ 'User: '******'.2f')) cpu_time_system = cpu_times.system cpu_time_total +=cpu_time_system description.append('\n' \ 'System: ') description.append(cpu_time_system.__format__('.2f')) description.append('\n' \ 'Children User: '******'.2f')) description.append('\n' \ 'Children system: ') cpu_time_children_system = cpu_times.children_system cpu_time_total +=cpu_time_children_system description.append(cpu_time_children_system.__format__('.2f')) description.append('\n' \ 'IO wait: ') cputime_io_wait = cpu_times.iowait cpu_time_total +=cputime_io_wait description.append(cputime_io_wait.__format__('.2f')) description.append('\n' \ '--------------------\n' \ 'Total: ') description.append(cpu_time_total.__format__('.2f')) description.append('\n' \ '\n' \ '**CPU usage:**\n' \ 'CPU usage percent: ') description.append(process_cpu_usage.cpu_percent.__format__('.2f')) description.append('%\n' \ 'CPU usage with max frequence: ') description.append(process_cpu_usage.cpu_percent_with_max_frequence.__format__('.2f')) description.append('%\n' \ 'CPU usage over all cores: ') description.append(process_cpu_usage.cpu_percent_total.__format__('.2f')) description.append('%\n' \ '\n' \ '**RAM usage**:\n' \ 'Total: ') description.append((PROCESS.memory_info().rss / (1 << 20)).__format__('.2f')) description.append('MB\n' \ 'Percent: ') description.append(PROCESS.memory_percent().__format__('.2f')) description.append('%') embed = Embed('System and Process stats:', ''.join(description), color=STAT_COLOR) await client.message_create(message.channel, embed=embed)
async def slash(): """Link to my wrapper's git repository.""" return Embed(description=f'[slash]({LINK__HATA_SLASH})', color=COLOR__KOISHI_HELP)
async def command(client, message): thread_count_by_type = {} thread_count = 0 for thread in list_threads(): thread_count +=1 thread_type = thread.__class__ thread_count_by_type[thread_type] = thread_count_by_type.get(thread_type,0)+1 description = [] main_thread_count = thread_count_by_type.pop(MainThreadType, 0) event_thread_count = thread_count_by_type.pop(EventThread, 0) event_loop_executor_count = 0 add_space = False if main_thread_count or event_thread_count: add_space = True description.append('**Main threads**:\n') if main_thread_count: description.append('Main threads: ') description.append(repr(main_thread_count)) description.append('\n') if event_thread_count: description.append('Event threads: ') description.append(repr(event_thread_count)) description.append('\n') for thread in list_threads(): if type(thread) is EventThread: event_loop_executor_count += thread.used_executor_count + thread.free_executor_count description.append( f'--------------------\n' f'Total: {main_thread_count+event_thread_count}' ) executor_thread_count = thread_count_by_type.pop(ExecutorThread, 0) if executor_thread_count: if add_space: description.append('\n\n') else: add_space = True other_executors = executor_thread_count description.append('**Executors:**\n') if event_loop_executor_count: other_executors -=event_loop_executor_count description.append('Event thread executors: ') description.append(repr(event_loop_executor_count)) description.append('\n') if DB_ENGINE.uses_single_worker: other_executors -=1 description.append('Database engine worker: 1\n') if other_executors>0: description.append('Other executors: ') description.append(repr(other_executors)) description.append('\n') description.append( f'--------------------\n' f'Total: {executor_thread_count}' ) if thread_count_by_type: if add_space: description.append('\n\n') else: add_space = True description.append('**Other thread types**:\n') thread_count_by_type = sorted(thread_count_by_type.items(), key=lambda item:item[1]) total_leftover = 0 for item in thread_count_by_type: total_leftover +=item[1] displayed_thread_types_count = 0 non_displayed_thread_count = total_leftover while True: if non_displayed_thread_count == 0: break if displayed_thread_types_count == 10: description.append('Other: ') description.append(repr(non_displayed_thread_count)) description.append('\n') break type_, count = thread_count_by_type.pop() non_displayed_thread_count-=count thread_type_name = type_.__name__ if len(thread_type_name) > 32: thread_type_name = thread_type_name[:32]+'...' description.append(thread_type_name) description.append(': ') description.append(repr(count)) description.append('\n') description.append('--------------------\nTotal: ') description.append(repr(total_leftover)) if add_space: description.append('\n\n**--------------------**\n') description.append('**Total**: ') description.append(repr(thread_count)) embed = Embed('Threads', ''.join(description), color=STAT_COLOR) await client.message_create(message.channel, embed=embed)
async def docs_search(client, event, search_for: ('str', 'Search term'), ): """Searchers the given query from hata docs.""" guild = event.guild if guild is None: yield Embed('Error', 'Guild only command', color=COLOR__KOISHI_HELP) return if guild not in client.guild_profiles: yield Embed('Error', 'I must be in the guild to execute this command.', color=COLOR__KOISHI_HELP) return permissions = event.channel.cached_permissions_for(client) if (not permissions.can_send_messages) or (not permissions.can_add_reactions): yield Embed('Permission denied', 'I need `send messages` and `add reactions` permission to execute this command.', color=COLOR__KOISHI_HELP) return if len(search_for) < 4: yield Embed('Ohoho', 'Please give a longer query', color=COLOR__KOISHI_HELP) return yield async with client.http.get(HATA_DOCS_SEARCH_API, params={'search_for': search_for}) as response: datas = await response.json() if not datas: embed = Embed(f'No search result for: `{search_for}`', color=COLOR__KOISHI_HELP) await Closer(client, event, embed) return sections = [] section_parts = [] for data in datas: section_parts.append('[**') name = data['name'] name = name.replace('_', '\_') section_parts.append(name) section_parts.append('**](') section_parts.append(HATA_DOCS_BASE_URL) url = data['url'] section_parts.append(url) section_parts.append(') *') type_ = data['type'] section_parts.append(type_) section_parts.append('*') preview = data.get('preview', None) if (preview is not None): preview = preview.replace('_', '\_') section_parts.append('\n') section_parts.append(preview) section = ''.join(section_parts) sections.append(section) section_parts.clear() descriptions = [] description_parts = [] description_length = 0 for section in sections: section_length = len(section) description_length += section_length if description_length > 2000: description = ''.join(description_parts) descriptions.append(description) description_parts.clear() description_parts.append(section) description_length = section_length continue if description_parts: description_parts.append('\n\n') description_length += 2 description_parts.append(section) continue if description_parts: description = ''.join(description_parts) descriptions.append(description) title = f'Search results for `{search_for}`' embeds = [] for index, description in enumerate(descriptions, 1): embed = Embed(title, description, color=COLOR__KOISHI_HELP).add_footer(f'Page {index}/{len(descriptions)}') embeds.append(embed) await Pagination(client, event, embeds, check=partial_func(docs_search_pagination_check, event.user))
async def description(client, message): prefix = client.command_processer.get_prefix_for(message) return Embed('rate', ('Do you want me, to rate someone?\n' f'Usage: `{prefix}rate <user>`\n' 'If no user is passed, I will rate you :3'), color=GAMES_COLOR)
async def git(): """Link to my git repository.""" return Embed(description=f'[Koishi repository]({LINK__KOISHI_GIT})', color=COLOR__KOISHI_HELP)
async def description(client, message): return Embed('yuno', ('Your personal yandere.\n' 'Good luck, I better leave now!'), color=GAMES_COLOR)
async def description(self, message): return Embed( title='tag-del', color=colourfunc(message=message), description="Do `m!tag-del <name>` to remove the given tag", )
async def description(client, message): return Embed('paranoia', ('Pa-Pa-Pa-Pa-Paranoia!!\n'), color=GAMES_COLOR)
async def store_guild_data(client, guild): """ This function stores the guild data first it stores the prefixes if they do not exist second they stores the member data if the data does not exist """ DATABASE = My_Database.DATABASE embed = Embed(title = "Database Status", description = 'Storing Every Data') message = await client.message_create(BOT_LOGS, embed) #For the prefix with client.keep_typing(BOT_LOGS): has_bot_data = bool(await executor(client, DATABASE.child('MelonMintBots').get().val)) if has_bot_data is None: bot_data = { config.MINT_ID:{'prefix':config.MINT_PREFIX}, config.MELON_ID:{'prefix':config.MELON_PREFIX}, config.MELON_MINT_ID:{'prefix':config.MELON_MINT_PREFIX} } await executor(client, DATABASE.child('MelonMintBots').set(bot_data).update) value_msg = f"Set to {f'<@{id}> is set to {prefix}' for id, prefix in bot_data.items()}" else: value_msg = "Prefix Unchanged" await client.message_edit(message, embed.add_field(name = "Prefix Status", value = value_msg)) #For Users with client.keep_typing(BOT_LOGS): new_count = 0 update_count = 0 guild_users = message.guild.users.copy().values() member_list = await executor(client, DATABASE.child('members').shallow(). get().val) for user in guild_users: if user.is_bot: continue user_data = user.guild_profiles.get(guild) if member_list is None or str(user.id) not in member_list: #just do it new_data = { 'joined_at':[str(user_data.joined_at)], 'left_at': [], 'name':[user.name], 'level':0, 'reputation':0, 'todo':[], 'roles': [x.id for x in user_data.roles] if user_data.roles else [] } new_count += 1 else: #update stuff new_data = await executor(client, DATABASE.child('members').child(str(user.id)).get().val) new_data['joined_at'].append(str(user_data.joined_at)) new_data['name'].append(user.name) if new_data.get('roles'): new_data['roles'].extend([x.id for x in user_data.roles] if user_data.roles else []) else: new_data['roles'] = [x.id for x in user_data.roles] if user_data.roles else [] for value in ['joined_at','name','roles']: list(set(new_data[value])) update_count += 1 print(f'Added {new_count}/{len(guild.users)}\nUpdated {update_count}/{len(guild.users)}') await executor(client, DATABASE.child('members').child(str(user.id)).set(new_data).update) embed = embed.add_field(name = "Member Status", value = f'Added {new_count}/{len(guild.users)}\nUpdated {update_count}/{len(guild.users)}') await client.message_edit(message, embed) await client.message_create(message.channel, 'done')
async def command(self, message): await self.message_create( message.channel, Embed(title='This channel contains everything you need to know')) await self.message_create(message.channel, Embed(title='RULES')) await self.message_create( message.channel, Embed( title='Rules', color=BLUE, description= ('\n'. join( (f'**Rule {x}**\n{y}\n' for x, y in SERVER_RULES.items())) + '\nIf anyone is bothering you or you would like to report something please send a direct to our mods' '\nIf our mods are the one bothering please direct message <@683006961788387368>' ))) await sleep(1.69) await self.message_create(message.channel, Embed(title='NAVIGATION')) await self.message_create( message.channel, Embed( title='Navigation', color=BLUE, description= ('<#716722197481390130>: Category where server related information are posted.\n' '<#717200392840282154>: Category where Nihongo Quest Game related information are posted.\n' '<#809346661343035442>: Category where we just chill out and talk over something fun!\n' '<#717211219034898463>: Category where all the fun is!\n' '<#717309484795428894>: Category where we study 日本語 and posts some of our good resources to others\n' '<#717668394396286998>: Place to chill out and listen to music or even talk to other members!\n' ))) await sleep(1.69) await self.message_create(message.channel, Embed(title='BOTS')) await self.message_create( message.channel, Embed( title='Bots', color=BLUE, description= ('<@811236307211649064> bot is mostly for helping people in our server giving FAQs and welcoming people.\n' '<@811242799877718026> bot is for moderating the server bonking bad users and managing server.\n' '<@809281851650474005> bot is <@762335112368750602>\'s pet he works for him and does the testing.\n' 'The source code is private for some reasons but if you want to contribute please dm <@762335112368750602> !' ))) await sleep(1.69) await self.message_create(message.channel, Embed(title='WHAT TO DO IF')) await self.message_create( message.channel, Embed( title='What to do if...', color=BLUE, description= ('**If I found a bug:** You can post it at <#747323336836644865> and call out an active mod.\n' '**If I have questions:** You can ask them at <#717222563259875370> and we will help if we can.\n' '**If I have a suggestion:** You can post your suggestion at <#809262950971473930> and react' 'thumbs up and down.Then you can wait for results. \n' '**If someone is inappropriate:** You can report then to our active mods but please send proof' ))) await sleep(1.69) await self.message_create(message.channel, Embed(title='WHAT IS NEXT OWO')) await self.message_create( message.channel, Embed( title='What\'s Next', color=BLUE, description= ('Why not introduce yourself in <#717214286988050443>!\n' 'Start a conversation in <#717211320881250336> or <#809349050091569152>\n' 'Visit <#717200392840282154> to know more about the game and how to download it!' ))) await self.message_delete(message)