async def top(message, params, **options): member_limit = int(params[0]) if params else 10 if member_limit > 20: member_limit = 20 member_profile_controller = ControllerPostgres(table="user_profile") top_members = member_profile_controller.load( order_by="messages", limit=str(member_limit), order_by_descending=True, ) embed_message = Embed(title=f"Top {len(top_members)} members:") for index, user_data in enumerate(top_members, 1): member = message.guild.get_member(int(user_data[1])) member_nick_tag = f"{member.name}#{member.discriminator}" member_messages_amount = user_data[4] embed_message.add_field( name=f"{index}. {member_nick_tag}", value=f"{member_messages_amount}", inline=False, ) return await message.channel.send(embed=embed_message)
async def leaderboard(ctx): emb = Embed( title='Leaderboard :first_place:', description=f'**Доска почёта**\nПоказываю доску почёта всех участников сервера' ) emb.add_field(name='Синтаксис', value='`-leaderboard`') await ctx.send(embed=emb)
async def auth(self, ctx): """ Returns a link to the AllianceAuth Install Used by many other Bots and is a common command that users will attempt to run. """ await ctx.trigger_typing() embed = Embed(title="AllianceAuth") embed.set_thumbnail( url= "https://assets.gitlab-static.net/uploads/-/system/project/avatar/6840712/Alliance_auth.png?width=128" ) embed.colour = Color.blue() embed.description = "All Authentication functions for this Discord server are handled through our Alliance Auth install" regex = r"^(.+)\/d.+" matches = re.finditer(regex, settings.DISCORD_CALLBACK_URL, re.MULTILINE) for m in matches: url = m.groups() embed.add_field(name="Auth Link", value="[{}]({})".format(url[0], url[0]), inline=False) return await ctx.send(embed=embed)
async def get_user_choice(cls, ctx: Context, search_query: str, entries: List[Tuple[str]]) -> int: em = Embed(colour=cls._embed_colour,) em.set_author(name=f'{cls._track_type} search results - {search_query} - Requested by {ctx.author}') for index, entry in enumerate(entries, 1): em.add_field( name=f'{index} - {entry[0]}', value=entry[1], inline=False) search_message = await ctx.send(embed=em) ensure_future(add_numeric_reactions(search_message, len(entries))) def check(react: Reaction, user: User): return any(( react.message.id == search_message.id, user == ctx.author, react.emoji in (numeric_emoji(n) for n in range(1, 1+len(entries))) )) try: reaction, _ = await ctx.bot.wait_for('reaction_add', check=check, timeout=60) except TimeoutError: raise BadArgument("You did not choose a search result in time.") await search_message.delete() return int(reaction.emoji[0]) - 1
async def dice(ctx): emb = Embed( title='Dice :game_die:', description='**Бросить кубик**\nКидаю кубик и говорю, что выпало. Можно настраивать количество граней' ) emb.add_field(name='Синтаксис', value='`-dice`\n`-dice <количество граней>`') await ctx.send(embed=emb)
async def catch(ctx): message = ctx.message pkmn = database.get_random_pokemon() pkmn_id = pkmn["national_id"] pkmn_name = pkmn["name"] pkmn_name_stripped = pkmn_name.lower().split("-")[0] color = _get_tier_color(pkmn_id) type_str = _get_types_string(pkmn["types"]) # random generator if shiny shiny_chance = randint(1,100) if shiny_chance < 2: shiny = True description = "**{}** You have caught :star2:**{}**".format(message.author, pkmn_name) else: shiny = False description = "**{}** You have caught **{}**".format(message.author, pkmn_name) embed = Embed(color=color, description=description) if shiny: embed.set_image(url="http://www.pkparaiso.com/imagenes/xy/sprites/animados-shiny/{}.gif".format(pkmn_name_stripped)) else: embed.set_image(url="http://www.pkparaiso.com/imagenes/xy/sprites/animados/{}.gif".format(pkmn_name_stripped)) embed.add_field(name='Name', value="{}[{}]".format(pkmn_name, pkmn_id)) embed.add_field(name="Types", value=type_str) embed.set_thumbnail(url="http://marktan.us/pokemon/img/icons/{}.png".format(pkmn_id)) # add the pokemon to the user db database.add_pokemon(message.author, pkmn, shiny=shiny) await ctx.send(embed=embed)
async def pokecenter(ctx, *args): """ Heals your whole party pokemon for ₱150 """ author = ctx.message.author database.add_pokedollars(author, -150) database.heal_party(author) embed = Embed( color=0xB80800, description="**{}** Welcome to the Pokemon Center!".format(author)) embed.set_author( name="Nurse Joy", icon_url= "https://i.pinimg.com/originals/ed/47/7c/ed477c99f4776886de48d5789f25776d.jpg" ) embed.add_field(name="Your Pokemon are healed!", value="Thanks for coming in. Please Come again ;)", inline=False) embed.set_footer( text= "Nurse Joy charged you ₱150 for her services. She ain't messin with no broke broke." ) embed.set_image( url= "https://cdn.bulbagarden.net/upload/thumb/9/9f/Nurse_Joy_anime_SM.png/250px-Nurse_Joy_anime_SM.png" ) return await pokemaster_bot.say(embed=embed)
async def kinsy(self, ctx): """ Returns the Kinsy Video """ await ctx.trigger_typing() embed = Embed(title="JUST JUMP IN!!") embed.set_thumbnail( url= "https://images.evetech.net/characters/1630472146/portrait?size=128" ) embed.colour = Color.blue() embed.description = "Just Jump In And WARP TO ME!!" url = get_site_url() embed.add_field( name="The Link", value= "https://cdn.discordapp.com/attachments/685827175626440735/949349523774398565/My_Movie.mp4" .format(url, url), inline=False) return await ctx.send(embed=embed)
async def stat(ctx): emb = Embed( title='Stat :bar_chart:', description=f'**Статистика пользователя**\nПоказываю ID, топ роль и дату подключения на сервер.\nМожно написать чей-нибудь ник, либо упомянуть кого-нибудь (например, меня), либо просто написать `-stat` и получить информацию о себе' ) emb.add_field(name='Синтаксис', value='`-stat <ник, либо упоминание>`\n`-stat`') await ctx.send(embed=emb)
async def embed(self, ctx, title=None, description=None, url=None, fields=None, color=None, thumbnail=None, image=None, footer=defaultFooter, showTimeStamp=True, send=True): if type(title) is dict: e = Embed.from_dict(title) if send: return await ctx.send(embed=e) return e if not color: color = colors[random.choice(list(colors.keys()))] e = Embed(title=title, description=description, url=url, color=color) if type(fields) is list: for field in fields: inline = True if "inline" in list(field.keys()): inline = field['inline'] del field['inline'] for name, value in field.items(): e.add_field(name=name, value=value, inline=inline) if showTimeStamp: e.timestamp = datetime.datetime.now() if thumbnail: e.set_thumbnail(url=thumbnail) else: e.set_thumbnail(url=self.bot.user.avatar_url) if image: e.set_image(url=image) if footer: icon = self.bot.user.avatar_url text = footer["text"].replace( "//author//", f"{ctx.author.name}#{ctx.author.discriminator}") if footer['icon']: if "//author.avatar//" in footer['icon']: if ctx.author.avatar_url: icon = ctx.author.avatar_url e.set_footer(text=text, icon_url=icon) if send: return await ctx.send(embed=e) return e
async def rule34(ctx): emb = Embed( title='Rule34 :yum:', description=f'**Правило интернета №34**\nДобро пожаловать в интернет. По понятным причинам можно использовать только в NSFW каналах' ) emb.add_field(name='Синтаксис', value='`-rule34`\n`-rule34 <список тегов через пробел>`') emb.add_field(name='Синонимы', value='`-r34`\n`-r`') await ctx.send(embed=emb)
async def anek(ctx): emb = Embed( title='Anek :zany_face:', description=f'**Рандомный анекдот**\nРасскажу тебе случайный анекдот из паблика **Анектоды категории Б+**' ) emb.add_field(name='Синтаксис', value='`-anek`') emb.add_field(name='Синонимы', value='`-anekdot`\n`-анек`\n`-прикол`\n`-смеяка`\n`-анекдот`\n`-ржака`') await ctx.send(embed=emb)
async def eightball(self, ctx, error, *, question): responses = ["Es seguro", "Es decididamente así", "Sin duda", "Puedes confiar en ello", "Tal como lo veo, si", "Lo mas probable", "Si", "Los signos apuntan al si", "Respuesta confusa, intentalo de nuevo", "Vuelve a preguntar mas tarde", "Mejor no te lo digo ahora", "No puedo predecirlo en este momento", "Concentrate y vuelve a preguntar", "Mi respuesta es un no", "Mis fuentes dicen que no", "No cuentes con ello", "Las perspectivas no son tan buenas", "Muy dudoso"] embed=Embed(title='**8Ball**', color=0xfff0ff) embed.add_field(name='***Tu pregunta***', value={question}, inline=True) embed.add_field(name='***Mi respuesta***', value={random.choice(responses)}, inline=True) embed.set_footer(text='Espero que esta respuesta alla sido de tu agrado 😀') await ctx.send(embed=embed)
async def _list(self, ctx: Context) -> None: if len(self._env_store.keys()): emb = Embed(title='Environment Store List', color=Colour.green()) for k, v in self._env_store.items(): emb.add_field(name=k, value=repr(v)) else: emb = Embed(title='Environment Store List', description='Environment Store is currently empty', color=Colour.green()) await ctx.send(embed=emb)
async def err(self, ctx: Context, lines: int = 5): """Get stdout logs""" err = self.get_tail("error", lines) em = Embed(title="Administration: Tail", color=0x00ff00) em.add_field(name="Error", value=f"```diff\n{err}\n```", inline=False) await ctx.send(embed=em)
def create_embed(self, msg: str, state: Aria) -> Embed: image = "neutral" if state.mood < 0: image = "strict" embed = Embed(title="ARIA", description=msg, color=discord.Color.from_rgb(255, 0, 0)) embed.add_field(name="Mistress Mood", value=str(state.mood)) embed.set_image(url=IMAGES[image]) return embed
async def ban(self, ctx, member: Member, *reason: str): await member.ban(reason=reason) emb = Embed(title=f'~~Cagatse~~', description=f'{member.mention} ha sido baneado por {ctx.author.mention}', color=0xFFC500) emb.set_thumbnail(url=member.avatar_url) emb.add_field(name='Motivo', value=reason) emb.add_field(name='Fecha de emision', value=ctx.message.created_at, inline=True) emb.set_footer(text=f'Flangsbot | Developed by Flangrys#7673') await ctx.send(embed=emb)
def buildListEmbed(title: str, sorteds: tuple[str, Any], valueFun: Callable[[Any], str], inline: bool=True): """ Builds an embed with a list of game objects. Used by the .list commands. """ embeds = [] for x in range(int(len(sorteds) / 25)+1): n = x * 25 embed = Embed(title=title, color=MISCORANGE) for name, obj in sorteds[n:n+25]: embed.add_field(name=name, value=valueFun(obj), inline=inline) embeds.append(embed) return embeds
async def ping(self, ctx): """ Tests Functionality """ VERSION = os.getenv('HEROKU_RELEASE_VERSION') e = Embed(title='Pong!', description=':ping_pong:!', color=discord.Color.green()) e.set_footer(text=f"Caseus Version {VERSION}") e.add_field( name="Latency:", value=f"Responded in {round(self.cas.latency, 2)} microseconds.") await ctx.send(embed=e)
async def listcommands(self, ctx: Context): """ Lists all commands. """ embed = Embed( title = "All commands:", color = MISCORANGE ) for command in ctx.bot.commands: embed.add_field(name=command.name, value=command.help, inline=False) await ctx.send(embed=embed)
async def test(self, context): video_url = 'https://video.twimg.com/ext_tw_video/886927908026974208/pu/vid/720x720/80aBs03U6PRl4XEW.mp4' video_url2 = 'https://moviestat.7gogo.jp/output/gN3r1SOGblf9GtN76wEuUm==/hq/EIOglrc4OQGAsjgE2zkduNq2.mp4' embed = Embed() embed._video = { "url": video_url, "height": 720, "width": 720 } embed.add_field(name="Test", value="test") await self.bot.say(embed=embed)
async def _remove(self, ctx: Context, name: str): if name: v = self._env_store.pop(name, None) else: v = None name = 'You must enter a name' if v: emb = Embed(title='Environment Item Removed', color=Colour.green()) emb.add_field(name=name, value=repr(v)) else: emb = Embed(title='Environment Item Not Found', description=name, color=Colour.red()) await ctx.send(embed=emb)
async def get_trainer_info(ctx, author): total_caught = database.get_total_caught(author) total_caught = "{}/718".format(total_caught) pokedollars = "₱{}".format(database.get_pokedollars(author)) embed = Embed(color=0xB80800) embed.set_author(name="{}'s Trainer Profile".format(author), icon_url="https://vignette3.wikia.nocookie.net/pkmnshuffle/images/b/b1/Pikachu_%28Winking%29.png/revision/latest?cb=20170410234514") embed.add_field(name='Pokedex Entries', value=total_caught) embed.add_field(name='Money', value=pokedollars) embed.set_thumbnail(url="http://rs1240.pbsrc.com/albums/gg495/iKyle10/Pokemon%20Trainer/avatar514181_1_zpsfxp46su9.gif~c200") embed.set_image(url="https://archives.bulbagarden.net/media/upload/a/a0/Spr_B2W2_Hilbert.png") return await ctx.send(embed=embed)
async def roles(self, ctx): embed = Embed( title= f'Currently available optional roles in {ctx.guild.name}: o.join <role name>' ) with open('cogs/utils/roles.txt', encoding='utf8') as rolef: rolesList = rolef.read().splitlines() for role in rolesList: embed.add_field(name=role, value=f'Grants {role} role', inline=False) return await ctx.send(embed=embed)
async def search(ctx: Context, query: str, page=1): em = Embed( title="Search", description=f"Searching for query `{query}`..... page ***{page}***") with sm as s: names = sort(s.get_names(), query)[(page - 1) * LINES_PER_PAGE:page * LINES_PER_PAGE] if len(names): for id_, name in names: em.add_field(name=name, value=id_) else: em.add_field(name="Not found", value="no such map was found") await ctx.send(embed=em)
def get_embeds(server_info, stats): embeds = [] embeds.append(get_header_embed(server_info)) stats_display = { "TOP_KILLERS": get_stat(stats, "kills"), "TOP_RATIO": get_stat(stats, "kill_death_ratio"), "TOP_PERFORMANCE": get_stat(stats, "kills_per_minute"), "TRY_HARDERS": get_stat(stats, "deaths_per_minute"), "TOP_STAMINA": get_stat(stats, "deaths"), "TOP_KILL_STREAK": get_stat(stats, "kills_streak"), "I_NEVER_GIVE_UP": get_stat(stats, "deaths_without_kill_streak"), "MOST_PATIENT": get_stat(stats, "deaths_by_tk"), "I_M_CLUMSY": get_stat(stats, "teamkills"), "I_NEED_GLASSES": get_stat(stats, "teamkills_streak"), "I_LOVE_VOTING": get_stat(stats, "nb_vote_started"), "WHAT_IS_A_BREAK": get_stat( stats, "time_seconds", post_process=lambda v: round(v / 60, 2) ), "SURVIVORS": get_stat( stats, "longest_life_secs", post_process=lambda v: round(v / 60, 2) ), "U_R_STILL_A_MAN": get_stat( stats, "shortest_life_secs", reverse=False, ), } stats_display = { CONFIG[k]: v for k, v in stats_display.items() if k in STATS_KEYS_TO_DISPLAY } current_embed = Embed( color=13734400, ) if not stats: current_embed.add_field(name=NO_STATS_AVAILABLE, value=f"{FIND_PAST_STATS}{PAST_GAMES_URL}") embeds.append(current_embed) else: for idx, (name, value) in enumerate(stats_display.items(), start=0): current_embed.add_field(name=name, value=value) if idx % 2: embeds.append(current_embed) current_embed = Embed( color=13734400, ) embeds[-1].add_field(name="\u200b", value=f"{ALL_STATS_TEXT}{SCOREBOARD_PUBLIC_URL}" , inline=False) embeds[-1].set_footer(icon_url=FOOTER_ICON_URL, text="Community RCon based stats by Dr.WeeD") print(embeds) return embeds
async def _build_setup_embed(self) -> Embed: guild = await self.services.guilds.to_dict() embed = Embed(title=f"SpellBot Setup for {guild['name']}") embed.set_thumbnail(url=self.settings.ICO_URL) description = ( "These are the current settings for SpellBot on this server." " Please use the buttons below, as well as the `/set` commands," " to setup SpellBot as you wish.\n\n" "You may also view Awards configuration using the `/awards` command" " and Channels configuration using the `/channels` command." ) embed.description = description[:EMBED_DESCRIPTION_SIZE_LIMIT] embed.add_field( name="MOTD", value=guild["motd"] or "None", inline=False, ) embed.add_field( name="Public Links", value=humanize_bool(guild["show_links"]), ) embed.add_field( name="Show Points on Games", value=humanize_bool(guild["show_points"]), ) embed.add_field( name="Create Voice Channels", value=humanize_bool(guild["voice_create"]), ) embed.color = discord.Color(self.settings.EMBED_COLOR) return embed
async def settings(self, ctx: Context): if ctx.invoked_subcommand: return lang = get_user_language(ctx.author.id) embed = Embed(color=Colors.default, timestamp=datetime.now()) embed.add_field(name="__" + lang.settings_private_settings + "__", value="** **", inline=False) embed.add_field(name=lang.settings_language_language, value=f"`{lang.name}`") if (log := await can_run_command( ctx, "settings log")) | (pref := await can_run_command( ctx, "settings prefix")):
async def page_embeds(self, embed: PagedEmbed, out=None): out = out or self fields = [ embed.fields[i:i + 25] for i in range(0, len(embed.fields), 25) ] for idx, field in zip(range(len(fields)), fields): page = Embed(title=embed.title, description=embed.desc, colour=embed.colour or self.me.colour) page.set_footer(text=f'page {idx+1} of {len(fields)}') for entry in field: page.add_field(name=entry[0], value=entry[1], inline=entry[2]) await out.send(embed=page)
def get_embed(self) -> Tuple[Embed, File]: embed = Embed(title=self.title if self.title else "", description=self.description if self.description else "", colour=self.color, timestamp=datetime.utcnow()) for field in self.fields: embed.add_field(name=field['name'], value=field['value']) if self.author: embed.set_author(name=self.author['name'], url=self.author.get('url', EmptyEmbed), icon_url=self.author.get('icon_url', EmptyEmbed)) if self.image_url: embed.set_image(url=self.image_url) return embed, self.file