def build_mod_action_embed( self, ctx, user: Member, reason: str, title: str ) -> Embed: embed = Embed(description=reason, color=0xCC2222) embed.set_author(name=title, icon_url=self.server.icon.url) embed.set_footer(text=ctx.author.display_name, icon_url=ctx.author.avatar.url) return embed
async def getproducts(self, ctx): dbresponse = getproducts() embed = Embed( title="Products", description=f"Here is all the products I was able to get for this server!", colour=ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) fields = [] for product in dbresponse: fields.append( ( product["name"], "Product Description: " + str(product["description"]) + "\nProduct Price: " + str(product["price"]), False, ) ) for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_footer(text="Redon Tech RPH • By: parker02311") await ctx.send(embed=embed, reference=ctx.message)
async def sources(intr: Interaction): """List all the sources supported""" if not await assert_check(intr, is_direct_only): return await intr.response.defer() embed = Embed( title="Supported sources", description= "This embed shows the list of all the sources currently supported", url= "https://novelsave-sources.readthedocs.io/en/latest/content/support.html#supported-novel-sources", ) for gateway in sorted(source_service.get_novel_sources(), key=lambda g: g.base_url): value = f"search: {'✅' if gateway.is_search_capable else '❌'}" embed.add_field(name=f"<{gateway.base_url}>", value=value) embed.set_footer(text=f"Version {source_service.current_version}") request_embed = Embed( title="Looking for something else?", description= "You can request a new source by creating an issue at github", url="https://github.com/mensch272/novelsave/issues/new/choose", ) await intr.send(embeds=[embed, request_embed])
async def get_message(self): messages = await self.channel.history(limit=1, oldest_first=True).flatten() message = None # Load the message from the channel, creating if necessary if not messages: message_content = ( f"**Select your coding skill level by reacting to this message**\n\n" f"Use {self.get_emoji('beginner')} if you're a beginner\n" f"Use {self.get_emoji('intermediate')} if you're at an intermediate skill level\n" f"Use {self.get_emoji('expert')} if you're an expert (e.g. production work experience)\n" ) embed = Embed(description=message_content, color=0x306998).set_author( name=f"Skill Level Assignment", icon_url=self.server.icon.url) embed.set_footer( text= "We reserve the right to adjust your skill level manually if " "we don't feel you've been honest about it.") message = await self.channel.send(embed=embed) await self.add_reactions() else: message = messages[0] return message
async def cmd_help(self, ctx, command): embed = Embed( title=f"Help with `{command}`", description=syntax(command), colour=ctx.author.colour, ) embed.add_field(name="Command Description", value=command.brief) embed.set_footer(text="Pembroke Bot • By: parker02311") await ctx.send(embed=embed, reference=ctx.message)
def buildembed(json_object, ableto, type): embed = Embed(title='<:sipsScared:819393684549533716> Name: ' + str(json_object['name']), color=0x228B22) embed.add_field(name='Health', value=str(json_object['currenthealth']) + '/' + str(json_object['maxhealth']), inline=True) embed.add_field(name='Food', value=str(json_object['food']) + '/100', inline=True) embed.add_field(name='Water', value=str(json_object['water']) + '/100', inline=True) embed.add_field(name='Cleanliness', value=str(json_object['cleanliness']) + '/100', inline=True) embed.add_field(name='Happiness', value=str(json_object['happiness']) + '/100', inline=True) if not ableto: embed.set_footer(text='Unable to ' + type + ' right now.') return embed
async def update_select(self, _, interaction: Interaction): product = str(interaction.data["values"])[2:-2] embed = Embed( title=f"Update {product}", description=f"What would you like to change?", colour=Colour.blue(), timestamp=nextcord.utils.utcnow(), ) embed.set_footer(text="Redon Tech RPH • By: parker02311") await interaction.message.edit( "", embed=embed, view=WhatUpdateView(self.context, product, self.bot) )
def build_rule_message_embed(self, title: str, message: str) -> nextcord.Embed: admin: nextcord.Member = self.server.get_member(266432511897370625) embed = Embed( title=title, description=message, timestamp=datetime.now().astimezone(pytz.timezone("US/Eastern")), color=BLUE, ) embed.set_footer(text=admin.name, icon_url=admin.avatar.url) for field_title, field_content in self.message_fields.items(): embed.add_field(name=field_title, value=field_content["description"], inline=False) return embed
async def write_page(self, menu, fields=[]): offset = (menu.current_page * self.per_page) + 1 len_data = len(self.entries) embed = Embed( title="Help", description="Get help on all commands!", colour=self.ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text= f"Redon Tech RPH • {offset:,} - {min(len_data, offset+self.per_page-1):,} of {len_data:,} commands • By: parker02311" ) for name, value in fields: embed.add_field(name=name, value=value, inline=False) return embed
async def _embed_substatus(self, ctx, title='Batsu Games', status_report=None, link=None): if status_report is None: status_report = [] embed = Embed(title=title, color=0xFF0000, url='' if link is None else link) embed.set_footer(text=self._STATUS_LEGEND) height = math.ceil( len(status_report) / float(Limits.EMBED_INLINE_FIELD_LIMIT)) for _ in range(height * Limits.EMBED_INLINE_FIELD_LIMIT): embed.add_field(name=embedutils.BLANK_DATA, value=embedutils.BLANK_DATA) r = 0 c = 0 for i in range(len(status_report)): if len(status_report[i + 1][0]) == 1: status_display = 'Complete!' else: status_display = '' for time, status in status_report[i + 1]: status_display += f'{time} | {status}\n' if len(status_display) == 0: status_display = embedutils.BLANK_DATA embed.set_field_at(r * Limits.EMBED_INLINE_FIELD_LIMIT + c, name=f'Part {i + 1}', value=status_display) r = (r + 1) % height if r == 0: c += 1 await ctx.send(embed=embed)
async def attachment_filter(self, message): """When a message is sent by normal users ensure it doesn't have any non-image attachments. Delete it and send a mod message if it does.""" if message.author.bot: return if not message.attachments: return if os.environ.get("PRODUCTION_BOT", False): if message.channel.name.lower() in self.admin_channels: return if message.channel.permissions_for(message.author).manage_messages: return allowed, disallowed = self.categorize_attachments(message) if not allowed and not disallowed: return user_message = ("\n".join(f"> {section}" for section in message.content.split("\n")) if message.content.strip() else "") embed = Embed( title="File Attachments Not Allowed", description= f"For safety reasons we do not allow file and video attachments.", color=YELLOW, ) if allowed: embed.title = f"{message.author.display_name} Uploaded Some Code" embed.description = user_message files = {} name = None for attachment in allowed: content = (await attachment.read()).decode() if len(content) < 1000: file_type = os.path.splitext( attachment.filename)[1].casefold() embed.add_field( name=f"Attachment: {attachment.filename}", value= f"```{self.file_types.get(file_type, '')}\n{content}\n```", ) else: if not name: name = attachment.filename files[attachment.filename] = content if files: gist = self.upload_files(files) embed.add_field( name="Uploaded the file to a Gist", value=f"[{name}]({gist})", ) embed.set_thumbnail( url= "https://cdn.discordapp.com/emojis/711749954837807135.png?v=1") embed.set_footer( text="For safety reasons we do not allow file attachments.") else: embed.set_thumbnail( url= "https://cdn.discordapp.com/emojis/651959497698574338.png?v=1") if user_message: embed.add_field(name=f"{message.author.display_name} Said", value=user_message) embed.add_field( name="Code Formatting", value= f"You can share your code using triple backticks like this:\n\\```\nYOUR CODE\n\\```", inline=False, ) embed.add_field( name="Large Portions of Code", value= f"For longer scripts use [Hastebin](https://hastebin.com/) or " f"[GitHub Gists](https://gist.github.com/) and share the link here", inline=False, ) if disallowed: embed.add_field( name="Ignored these files", value="\n".join(f"- {attachment.filename}" for attachment in disallowed) or "*NO FILES*", ) try: await message.delete() except nextcord.errors.NotFound: pass await message.channel.send(message.author.mention, embed=embed)
async def update_name(self, _, interaction: Interaction): embed = Embed( title=f"Update {self.product['name']}", description=f"What would you like to change the name to?", colour=Colour.blue(), timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311' ) view = CancelView(self.context) await interaction.message.edit("", embed=embed, view=None) def check(m): return m.content and m.author == self.context.author try: message = await self.bot.wait_for("message", timeout=600.0, check=check) except TimeoutError: await interaction.message.delete() await interaction.response.send_message("Timed Out", ephemeral=True) self.stop() if not message is None and view.canceled is False: if message.content.lower() == "cancel": await interaction.message.delete() await interaction.response.send_message("Canceled", ephemeral=True) self.stop() else: await interaction.message.delete() view = AreYouSureView(self.context) message = await self.context.send( f"Are you sure you would like to change {self.product['name']} to {message.content}?", view=view, reference=self.context.message, ) await view.wait() if view.Return == None: await message.delete() await interaction.response.send_message("Timed out", ephemeral=True) elif view.Return == False: await message.delete() await interaction.response.send_message("Canceled update", ephemeral=True) elif view.Return == True: try: updateproduct( self.product["name"], message.content, self.product["description"], self.product["price"], self.product["attachments"] ) await interaction.message.delete() name = self.product["name"] await interaction.response.send_message( f"Updated {name}.", ephemeral=True, ) except: await interaction.message.delete() await interaction.response.send_message( f"Failed to update {self.args[0]}.", ephemeral=True, )
async def createproduct(self, ctx): questions = [ "What do you want to call this product?", "What do you want the description of the product to be?", "What do you want the product price to be?", "attachments", ] embedmessages = [] usermessages = [] awnsers = [] attachments = [] def check(m): return m.content and m.author == ctx.author def emojicheck(self, user): return user == ctx.author def attachmentcheck(m): return m.author == ctx.author for i, question in enumerate(questions): if question == "attachments": embed = Embed( title=f"Create Product (Question {i+1})", description='Please post any attachments\nSay "Done" when complete', colour=ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311' ) fields = [ ( "Attachments", "None", False, ) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embedmessage = await ctx.send(embed=embed) embedmessages.append(embedmessage) while True: try: message = await self.bot.wait_for( "message", timeout=200.0, check=attachmentcheck ) except TimeoutError: await ctx.send("You didn't answer the questions in Time") return if message.content.lower() == "cancel": usermessages.append(message) for message in embedmessages: await message.delete() for message in usermessages: await message.delete() await ctx.message.delete() await ctx.send("Canceled", delete_after=5.0) break if message.content.lower() == "done": usermessages.append(message) break elif not message.attachments == [] and message.attachments: for attachment in message.attachments: attachments.append(attachment.url) embed = Embed( title=f"Create Product (Question {i+1})", description='Please post any attachments\nSay "Done" when complete', colour=ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311' ) fields = [ ( "Attachments", "\n".join( [attachment for attachment in attachments] ), False, ) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_footer(text="Pembroke Bot • By: parker02311") await embedmessage.edit(embed=embed) await ctx.send( "It is recommended to not delete this message unless needed.", reference=message, ) else: embed = Embed( title=f"Create Product (Question {i+1})", description=question, colour=ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311' ) embedmessage = await ctx.send(embed=embed) embedmessages.append(embedmessage) try: message = await self.bot.wait_for( "message", timeout=200.0, check=check ) except TimeoutError: await ctx.send("You didn't answer the questions in Time") return if message.content.lower() == "cancel": usermessages.append(message) for message in embedmessages: await message.delete() for message in usermessages: await message.delete() await ctx.message.delete() await ctx.send("Canceled", delete_after=5.0) break else: usermessages.append(message) awnsers.append(message.content) lastbeforefinal = await ctx.send( "Creating final message this may take a moment." ) for message in embedmessages: await message.delete() for message in usermessages: await message.delete() embed = Embed( title="Confirm Product Creation", description="✅ to confirm\n❌ to cancel", colour=ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) fields = [ ("Name", awnsers[0], False), ("Description", awnsers[1], False), ("Price", awnsers[2], False), ( "Attachments", "\n".join([attachment for attachment in attachments]), False, ), ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_footer(text="Redon Tech RPH • By: parker02311") finalmessage = await ctx.send(embed=embed) await finalmessage.add_reaction("✅") await finalmessage.add_reaction("❌") await lastbeforefinal.delete() try: reaction, user = await self.bot.wait_for( "reaction_add", timeout=200.0, check=emojicheck ) except TimeoutError: await ctx.author.send("You didn't respond in time.") return if str(reaction.emoji) == "✅": try: createproduct(awnsers[0], awnsers[1], awnsers[2], attachments) except: await ctx.send( "I was unable to create the product...", delete_after=5.0 ) raise embed = Embed( title="Product Created", description="The product was successfully created.", colour=ctx.author.colour, timestamp=nextcord.utils.utcnow(), ) fields = [ ("Name", awnsers[0], False), ("Description", awnsers[1], False), ("Price", awnsers[2], False), ( "Attachments", "\n".join([attachment for attachment in attachments]), False, ), ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_footer(text="Redon Tech RPH • By: parker02311") await ctx.send(embed=embed) await finalmessage.delete() await ctx.message.delete()
async def update_attachments(self, _, interaction: Interaction): embed = Embed( title=f"Update {self.product['name']}", description=f'Please post the attachments now. Say "Done" when you are done.', colour=Colour.blue(), timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311' ) fields = [ ( "Attachments", "None", False, ) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) view = CancelView(self.context) await interaction.message.edit("", embed=embed, view=None) def check(m): return m.author == self.context.author attachments = [] while True: try: message = await self.bot.wait_for("message", timeout=600.0, check=check) except TimeoutError: await interaction.message.delete() await interaction.response.send_message("Timed Out", ephemeral=True) self.stop() if message.content.lower() == "cancel": await interaction.message.delete() await self.context.send( "Canceled", reference=self.context.message, delete_after=5.0 ) break if message.content.lower() == "done": break elif not message.attachments == [] and message.attachments: for attachment in message.attachments: attachments.append(attachment.url) embed = Embed( title=f"Update {self.product['name']}", description=f'Please post the attachments now. Say "Done" when you are done.', colour=Colour.blue(), timestamp=nextcord.utils.utcnow(), ) embed.set_footer( text='Redon Tech RPH • Say "Cancel" to cancel. • By: parker02311' ) fields = [ ( "Attachments", "\n".join([attachment for attachment in attachments]), False, ) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_footer(text="Pembroke Bot • By: parker02311") await interaction.message.edit("", embed=embed, view=None) await self.context.send( "It is recommended to not delete this message unless needed.", reference=message, ) if attachments: await interaction.message.delete() view = AreYouSureView(self.context) await self.context.send( f"Are you sure you would like to change {self.product['attachments']} to {attachments}?", view=view, reference=self.context.message, ) await view.wait() if view.Return == None: await message.delete() await interaction.response.send_message("Timed out", ephemeral=True) elif view.Return == False: await message.delete() await interaction.response.send_message("Canceled update", ephemeral=True) elif view.Return == True: try: updateproduct( self.product["name"], self.product["name"], self.product["description"], self.product["price"], attachments ) await interaction.message.delete() name = self.product["name"] await interaction.response.send_message( f"Updated {name}.", ephemeral=True, ) except: await interaction.message.delete() await interaction.response.send_message( f"Failed to update {self.args[0]}.", ephemeral=True, )
async def _lookup( self, ctx: Interaction, profile: str = SlashOption( name="profile", description= "The osu! profile you are looking up. This can be their username or ID.", required=False, default=None), mode: str = SlashOption( name="mode", description= "The osu! gamemode you want to look up. This can be osu!, osu!taiko, osu!catch, or osu!mania.", required=False, default=None)): # defer await ctx.response.defer(ephemeral=False) # user has linked account if not profile: # check if member has an osu! profile linked member = await self.bot.db.fetch( "SELECT * FROM osulink WHERE discordid = %s", ctx.user.id) if not member: return await ctx.send( "You don't have a osu! profile linked!\nLink one with **/osu link** or specifiy a username when using **/osu lookup**!", ephemeral=True) # specified mode; get data if mode: if mode not in self.VALID_MODES: return await ctx.send( "Invalid mode selection!\nValid modes are: **osu!**, **osu!taiko**, **osu!catch**, **osu!mania**.", ephemeral=True) # TODO: handle this better try: user = self.bot.osu.user(member.get("osuid"), self.TO_API_CONV.get(mode)) except: return await ctx.send( "Failed to contact the osu!api. Please try again.", ephemeral=True) # unspecified mode; use favoritemode else: # TODO: handle this better try: user = self.bot.osu.user(member.get("osuid"), member.get("favoritemode")) except: return await ctx.send( "Failed to contact the osu!api. Please try again.", ephemeral=True) mode = self.FROM_API_CONV.get(member.get("favoritemode")) # profile used; no mode elif profile and not mode: # fetch user try: favoritemode = self.bot.osu.user(profile).playmode user = self.bot.osu.user(profile, favoritemode) except ValueError: return await ctx.send( "I couldn't find that osu! profile!\nMake sure you spelled their **username** or entered their **ID** correctly!", ephemeral=True) except: return await ctx.send( "An unknown error occured! Please report it to the developer!", ephemeral=True) # convert osu!api mode to fancy mode mode = self.FROM_API_CONV.get(favoritemode) # profile and mode used else: # check for user error if mode not in self.VALID_MODES: return await ctx.send( "Invalid mode selection!\nValid modes are: **osu!**, **osu!taiko**, **osu!catch**, **osu!mania**.", ephemeral=True) # fetch user try: user = self.bot.osu.user(profile, self.TO_API_CONV.get(mode)) except ValueError: return await ctx.send( "I couldn't find that osu! profile!\nMake sure you spelled their **username** or entered their **ID** correctly!", ephemeral=True) except: return await ctx.send( "An unknown error occured! Please report it to the developer!", ephemeral=True) # embed embed = Embed( title= f":flag_{user.country_code.lower()}: {':heartpulse:' if user.is_supporter else ''}{':wrench:' if user.is_bot else ''} {user.username} | {mode}", color=int(hex(int(user.profile_colour.strip("#"), 16)), 0) if user.profile_colour else 0xff94ed) embed.set_thumbnail(url=f"https://a.ppy.sh/{user.id}") # user doesn't have statistics for requested gamemode if not user.statistics.global_rank: embed.add_field( name=f"No {mode} stats are available for {user.username}.", value="** **", inline=True) # user has statistics for requested gamemode else: embed.add_field(name="Global Rank", value=f"{user.statistics.global_rank:,}", inline=True) embed.add_field(name="Country Rank", value=f"{user.statistics.country_rank:,}", inline=True) embed.add_field(name="PP", value=f"{user.statistics.pp:,.2f}", inline=True) embed.add_field(name="Ranked Score", value=f"{user.statistics.ranked_score:,}", inline=True) embed.add_field(name="Total Score", value=f"{user.statistics.total_score:,}", inline=True) embed.add_field(name="Accuracy", value=f"{user.statistics.hit_accuracy:.2f}%", inline=True) embed.add_field(name="Play Count", value=f"{user.statistics.play_count:,}", inline=True) embed.set_footer( text=f"running Moé v{self.bot.version}", icon_url="https://bot.its.moe/assets/favicon/favicon-16x16.png") if config.debug: log(f"Osu: Got api data: {user.username} ({user.id})", Ansi.LGREEN) return await ctx.send(embed=embed)
def _testing_embed(): embed = Embed(title="Title", url="https://cog-creators.github.io/discord-embed-sandbox/", description="Description", color=0xff0000) embed.set_author(name="Author name") embed.add_field(name="Field Name", value="Field Value", inline=False) embed.set_footer(text="Footer") return embed