def banned_word_embed(guild, word): message = f'Your message was deleted in {guild.name} because it contained the banned word {word}.' embed = Embed(title='Message Deleted!', description=message, color=Color.orange()) embed.set_thumbnail(url=guild.icon_url) return embed
def restricted_embed(guild): message = f"""You are currently restricted from using commands in {guild.name}!\n You can continue to use Joy's functions in other servers or in DMs! Speak with a moderator of {guild.name} to get more information!""" embed = Embed(title='Restricted User Warning!', description=message, color=Color.orange()) embed.set_thumbnail(url=guild.icon_url) return embed
async def on_message_delete(self, message: Message) -> None: logging_channel = message.guild.get_channel(int(os.environ["LOGGING_CHANNEL"])) embed = Embed( title="Message Deleted", description=f"{message.author.mention}'s message in {message.channel.mention} was deleted", color=Color.red(), ) embed.add_field(name="Message", value=message.content) embed.set_thumbnail(url=message.author.avatar.url) embed.timestamp = datetime.now() await logging_channel.send(embed=embed)
async def on_message_edit(self, before: Message, after: Message) -> None: logging_channel = before.guild.get_channel(int(os.environ["LOGGING_CHANNEL"])) embed = Embed( title="Message Edited", description=f"{before.author.mention}'s message in {before.channel.mention} was edited", color=Color.red(), ) embed.add_field(name="Before", value=before.content, inline=False) embed.add_field(name="After", value=after.content, inline=False) embed.set_thumbnail(url=before.author.avatar.url) embed.timestamp = datetime.now() await logging_channel.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 _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)