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 _handle_watched_players(self, player_xids: list[int]): """Notify moderators about watched players.""" assert self.interaction.guild mod_role: Optional[discord.Role] = None for role in self.interaction.guild.roles: if role.name.startswith(self.settings.MOD_PREFIX): mod_role = role break if not mod_role: return watch_notes = await self.services.games.watch_notes(player_xids) if not watch_notes: return data = await self.services.games.to_dict() embed = Embed() embed.set_thumbnail(url=self.settings.ICO_URL) embed.set_author(name="Watched user(s) joined a game") embed.color = self.settings.EMBED_COLOR description = ( f"[⇤ Jump to the game post]({data['jump_link']})\n" f"[➤ Spectate the game on SpellTable]({data['spectate_link']})\n\n" f"**Users:**") for user_xid, note in watch_notes.items(): description += f"\n• <@{user_xid}>: {note}" embed.description = description for member in mod_role.members: await safe_send_user(member, embed=embed)
async def award_delete(self, guild_award_id: int) -> None: await self.services.guilds.award_delete(guild_award_id) embed = Embed() embed.set_thumbnail(url=self.settings.ICO_URL) embed.set_author(name="Award deleted!") description = "You can view all awards with the `/set awards` command." embed.description = description embed.color = self.settings.EMBED_COLOR await safe_send_channel(self.interaction, embed=embed, ephemeral=True)
async def _reply_found_embed(self): embed = Embed() embed.set_thumbnail(url=self.settings.ICO_URL) embed.set_author(name="I found a game for you!") game_data = await self.services.games.to_dict() link = game_data["jump_link"] embed.description = f"You can [jump to the game post]({link}) to see it!" embed.color = self.settings.EMBED_COLOR await safe_followup_channel(self.interaction, embed=embed)
async def award_add( self, count: int, role: str, message: str, **options: Optional[bool], ) -> None: repeating = bool(options.get("repeating", False)) remove = bool(options.get("remove", False)) max_message_len = GuildAward.message.property.columns[0].type.length # type: ignore if len(message) > max_message_len: await safe_send_channel( self.interaction, f"Your message can't be longer than {max_message_len} characters.", ephemeral=True, ) return if count < 1: await safe_send_channel( self.interaction, "You can't create an award for zero games played.", ephemeral=True, ) return if await self.services.guilds.has_award_with_count(count): await safe_send_channel( self.interaction, "There's already an award for players who reach that many games.", ephemeral=True, ) return await self.services.guilds.award_add( count, role, message, repeating=repeating, remove=remove, ) embed = Embed() embed.set_thumbnail(url=self.settings.ICO_URL) embed.set_author(name="Award added!") every_or_after = "every" if repeating else "after" give_or_take = "take" if remove else "give" description = ( f"• _{every_or_after} {count} games_ — {give_or_take} `@{role}`" f" — {message}\n\nYou can view all awards with the `/set awards` command." ) embed.description = description embed.color = self.settings.EMBED_COLOR await safe_send_channel(self.interaction, embed=embed, ephemeral=True)
async def ord(ctx, *, query: str = ''): response = get_ord_post(query).json()['response'] if len(response['items']) == 0: await ctx.send(':dizzy_face: Не могу найти такой пост') return content = response['items'][0]['text'] emb = Embed(title=f'**"{content}"**') if len(content) < 256 else Embed(description=f'**"{content}"**') footer = '© ' + response['groups'][0]['name'] + ', ' + datetime.utcfromtimestamp(response['items'][0]['date']).strftime('%Y') emb.set_footer(text=footer) try: if response['items'][0]['attachments'][0]['type'] == 'photo': image = response['items'][0]['attachments'][0]['photo']['sizes'][-1]['url'] emb.set_image(url=image) except: pass thumbnail = response['groups'][0]['photo_200'] emb.set_thumbnail(url=thumbnail) emb.color = discord.Color.from_rgb(255, 100, 100) await ctx.send(embed=emb)
async def anek(ctx): response = requests.get( 'https://api.vk.com/method/wall.get', params = { 'owner_id': environ.get('ANEK_ID'), 'count': 1, 'offset': 0, 'access_token': environ.get('VK_TOKEN'), 'v': '5.130' } ) error = response.json().get('error') if error: print(f'VK API error (code = {error["error_code"]}): {error["error_msg"]}') post_count = response.json()['response']['count'] response = requests.get( 'https://api.vk.com/method/wall.get', params = { 'owner_id': environ.get('ANEK_ID'), 'count': 1, 'offset': random.randint(0, post_count - 1), 'access_token': environ.get('VK_TOKEN'), 'v': '5.130', 'extended': '1' } ) error = response.json().get('error') if error: print(f'VK API error (code = {error["error_code"]}): {error["error_msg"]}') content = response.json()['response']['items'][0]['text'] emb = Embed(title=content) if len(content) < 256 else Embed(description=content) footer = '© ' + response.json()['response']['groups'][0]['name'] emb.set_footer(text=footer) attachments = response.json()['response']['items'][0] try: if attachments['attachments'][0]['type'] == 'photo': image = attachments['attachments'][0]['photo']['sizes'][-1]['url'] emb.set_image(url=image) except: pass thumbnail = response.json()['response']['groups'][0]['photo_200'] emb.set_thumbnail(url=thumbnail) emb.color = discord.Color.from_rgb(22, 185, 247) await ctx.send(embed=emb)
async def jf(self, ctx, dest, volume): """ Calculates the cost by m3 for GreenSwarm Express contracts. Valid destinations at this point are: d-o, do, home, d-ojez, and jita """ priceIn = 800 priceOut = 500 minimumValue = 5000000 allowedIn = ['d-o', 'home', 'do', 'd-ojez'] allowedOut = ['jita'] if dest in allowedIn: costs = int(priceIn) * int(volume) elif dest in allowedOut: costs = int(priceOut) * int(volume) else: return await ctx.send('Please select a valid destination. For now, the only valid destnations are \'d-o\', \'home\', \'do\', \'d-ojez\', \'jita\'') if int(costs) < int(minimumValue): costs = 5000000 embed = Embed(title='Cost to transport {} m3 to {}: {:,} isk'.format(volume, dest, costs)) embed.color = Color.green() return await ctx.send(embed=embed)
def new_embed() -> Embed: embed = Embed(title=f"SpellBot Player Awards for {guild['name']}") embed.set_thumbnail(url=self.settings.ICO_URL) embed.color = discord.Color(self.settings.EMBED_COLOR) return embed
def new_embed() -> Embed: embed = Embed(title=f"Configuration for channels in {guild['name']}") embed.set_thumbnail(url=self.settings.ICO_URL) embed.color = discord.Color(self.settings.EMBED_COLOR) return embed
async def jump(self, ctx, origin, dest, ship): if not origin: raise commands.BadArgument( 'Missing required argument: \'origin\'.') if not dest: raise commands.BadArgument( 'Missing required argument: \'destination\'.') if not ship: raise commands.BadArgument('Missing required argument: \'ship\'') origin = origin.capitalize() dest = dest.capitalize() ship = ship.capitalize() await ctx.trigger_typing() try: try: origin_lookup = self.bot.esi.search('solar_system', origin) origin_id = origin_lookup['solar_system'][0] except KeyError: embed = Embed(title='Origin not found') embed.color = Color.red() return await ctx.send(embed=embed) try: dest_lookup = self.bot.esi.search('solar_system', dest) dest_id = dest_lookup['solar_system'][0] dest_sheet_operation = self.bot.esi.esi.get_operation( 'get_universe_systems_system_id') dest_sheet = dest_sheet_operation.json(system_id=dest_id) dest_sec = round(float(dest_sheet['security_status']), 2) if dest_sec >= .50: raise commands.BadArgument( 'You cannot jump to a high security system.') except KeyError: embed = Embed(title='Destination not found') embed.color = Color.red() return await ctx.send(embed=embed) try: ship_lookup = self.bot.esi.search('inventory_type', ship) ship_id = ship_lookup['inventory_type'][0] ship_sheet_operation = self.bot.esi.esi.get_operation( 'get_universe_types_type_id') ship_sheet = ship_sheet_operation.json(type_id=ship_id) dogma_attr = ship_sheet['dogma_attributes'] if len( list( filter(lambda x: x['attribute_id'] == 861, dogma_attr))) == 1: pass else: embed = Embed( title=f'The **{ship}** is not a jump capable ship.') embed.color = Color.red() embed.set_thumbnail( url=f'https://image.eveonline.com/Type/{ship_id}_64.png' ) return await ctx.send(embed=embed) except KeyError: embed = Embed(title='Ship not found') embed.color = Color.red() return await ctx.send(embed=embed) route = origin + ':' + dest skills = 555 url = f'https://evemaps.dotlan.net/jump/{ship},{skills}/{route}' embed = Embed(title=f'Jump Route for {ship}', url=url) embed.set_thumbnail( url=f'https://image.eveonline.com/Type/{ship_id}_64.png') embed.add_field(name='Origin System', value=f'{origin}', inline=False) embed.add_field(name='Destination System', value=f'{dest}', inline=False) embed.set_footer( text= 'Skills used: Jump Drive Callibration = 5, Jump Fuel Conservation = 5, Jump Freighter = 5' ) embed.color = Color.green() except Exception as err: return await ctx.send(f'```py\n{traceback.format_exc()}\n```') return await ctx.send(embed=embed)
def new_embed() -> Embed: assert self.interaction.guild embed = Embed(title="List of watched players on this server") embed.set_thumbnail(url=settings.ICO_URL) embed.color = discord.Color(settings.EMBED_COLOR) return embed