async def send_profile_archivation( self, user_profile: localutils.UserProfile, target_user: discord.Member) -> typing.Optional[discord.Message]: """ Send a profile to the template's archive channel. This will also add the given role to the user. Yes, archivation is a word. Args: user_profile (localutils.UserProfile): The profile to be submitted target_user (discord.Member): The owner of the profile Returns: bool: Whether or not the archive send was successful """ # Grab the archive channel ID template: localutils.Template = user_profile.template archive_channel_id: typing.Optional[int] = template.get_archive_channel_id(target_user) # this may raise InvalidCommandText # Check if there's an archive channel set if archive_channel_id is None: return None # Get the channel try: channel: discord.TextChannel = self.bot.get_channel(archive_channel_id) or await self.bot.fetch_channel(archive_channel_id) except discord.HTTPException: raise localutils.errors.TemplateArchiveChannelError(f"I can't reach a channel with the ID `{archive_channel_id}`.") # Send the data embed: utils.Embed = user_profile.build_embed(self.bot, target_user) try: return await channel.send(None if target_user is None else target_user.mention, embed=embed) except discord.HTTPException: raise localutils.errors.TemplateArchiveChannelError(f"I can't send messages to {channel.mention}.")
async def send_profile_verification(self, user_profile:localutils.UserProfile, target_user:discord.Member) -> typing.Optional[discord.Message]: """ Sends a profile in to the template's verification channel. Args: user_profile (localutils.UserProfile): The profile to be submitted. target_user (discord.Member): The owner of the profile. Returns: typing.Optional[discord.Message]: The message that was sent into the verification channel by the bot. Raises: localutils.errors.TemplateVerificationChannelError: The bot encountered an error sending a message to the verification channel. """ # Grab the verification channel ID template: localutils.Template = user_profile.template verification_channel_id: typing.Optional[int] = template.get_verification_channel_id(target_user) # this may raise InvalidCommandText # Check if there's a verification channel if verification_channel_id is None: return None # Get the channel try: channel: discord.TextChannel = self.bot.get_channel(verification_channel_id) or await self.bot.fetch_channel(verification_channel_id) if channel is None: raise localutils.errors.TemplateVerificationChannelError(f"I can't reach a channel with the ID `{verification_channel_id}`.") except discord.HTTPException: raise localutils.errors.TemplateVerificationChannelError(f"I can't reach a channel with the ID `{verification_channel_id}`.") # Send the data embed: utils.Embed = user_profile.build_embed(self.bot, target_user) embed.set_footer(text=f'{template.name} // Verification Check') try: v = await channel.send(f"New **{template.name}** submission from <@{user_profile.user_id}>\n{user_profile.user_id}/{template.template_id}/{user_profile.name}", embed=embed) except discord.HTTPException: raise localutils.errors.TemplateVerificationChannelError(f"I can't send messages to {channel.mention}.") # Add reactions to message try: await v.add_reaction(self.TICK_EMOJI) await v.add_reaction(self.CROSS_EMOJI) except discord.HTTPException: try: await v.delete() except discord.HTTPException: pass raise localutils.errors.TemplateVerificationChannelError(f"I can't add reactions in {channel.mention}.") # Wew nice we're done return v
async def send_profile_verification( self, user_profile: localutils.UserProfile, target_user: discord.Member) -> typing.Optional[discord.Message]: """ Sends a profile in to the template's verification channel. Args: user_profile (localutils.UserProfile): The profile to be submitted. target_user (discord.Member): The owner of the profile. Returns: typing.Optional[discord.Message]: The message that was sent into the verification channel by the bot. Raises: localutils.errors.TemplateVerificationChannelError: The bot encountered an error sending a message to the verification channel. """ # Grab the verification channel ID template: localutils.Template = user_profile.template verification_channel_id: typing.Optional[int] = template.get_verification_channel_id(target_user) # this may raise InvalidCommandText # Check if there's a verification channel if verification_channel_id is None: return None # Get the channel try: channel: discord.TextChannel = self.bot.get_channel(verification_channel_id) or await self.bot.fetch_channel(verification_channel_id) if channel is None: raise localutils.errors.TemplateVerificationChannelError(f"I can't reach a channel with the ID `{verification_channel_id}`.") except discord.HTTPException: raise localutils.errors.TemplateVerificationChannelError(f"I can't reach a channel with the ID `{verification_channel_id}`.") # Send the data embed: utils.Embed = user_profile.build_embed(self.bot, target_user) embed.set_footer(text=f'{template.name} // Verification Check') try: components = utils.MessageComponents.add_buttons_with_rows( utils.Button("Approve", style=utils.ButtonStyle.SUCCESS, custom_id="VERIFY PROFILE YES"), utils.Button("Decline", style=utils.ButtonStyle.DANGER, custom_id="VERIFY PROFILE NO"), ) v = await channel.send( f"New **{template.name}** submission from <@{user_profile.user_id}>\n{user_profile.user_id}/" f"{template.template_id}/{user_profile.name}", embed=embed, components=components ) except discord.HTTPException: raise localutils.errors.TemplateVerificationChannelError(f"I can't send messages to {channel.mention}.") # Wew nice we're done return v