URL fixes, catches for empty/non-existent data
This commit is contained in:
parent
f1f1936673
commit
9f65213ea6
1 changed files with 17 additions and 2 deletions
|
@ -13,7 +13,7 @@ from dis_snek.models.discord.embed import EmbedField
|
|||
from dis_snek.models.discord.file import File
|
||||
from dis_snek.models.discord.guild import Guild
|
||||
from dis_snek.models.discord.role import Role
|
||||
from dis_snek.models.discord.user import User
|
||||
from dis_snek.models.discord.user import Member, User
|
||||
from dis_snek.models.snek.application_commands import (
|
||||
OptionTypes,
|
||||
SlashCommandChoice,
|
||||
|
@ -54,6 +54,12 @@ class UtilCog(Scale):
|
|||
fields.append(EmbedField(name="dis-snek", value=const.__version__))
|
||||
fields.append(EmbedField(name="Version", value=jarvis.__version__, inline=False))
|
||||
fields.append(EmbedField(name="Git Hash", value=get_repo_hash()[:7], inline=False))
|
||||
num_domains = len(self.bot.phishing_domains)
|
||||
fields.append(
|
||||
EmbedField(
|
||||
name="Phishing Protection", value=f"Detecting {num_domains} phishing domains"
|
||||
)
|
||||
)
|
||||
embed = build_embed(title=title, description=desc, fields=fields, color=color)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
@ -96,6 +102,8 @@ class UtilCog(Scale):
|
|||
to_send += f":{names[id]}:"
|
||||
if len(to_send) > 2000:
|
||||
await ctx.send("Too long.", ephemeral=True)
|
||||
elif len(to_send) == 0:
|
||||
await ctx.send("No valid text found", ephemeral=True)
|
||||
else:
|
||||
await ctx.send(to_send)
|
||||
|
||||
|
@ -111,7 +119,10 @@ class UtilCog(Scale):
|
|||
if not user:
|
||||
user = ctx.author
|
||||
|
||||
avatar = user.display_avatar.url
|
||||
avatar = user.avatar.url
|
||||
if isinstance(user, Member):
|
||||
avatar = user.display_avatar.url
|
||||
|
||||
embed = build_embed(title="Avatar", description="", fields=[], color="#00FFEE")
|
||||
embed.set_image(url=avatar)
|
||||
embed.set_author(name=f"{user.username}#{user.discriminator}", icon_url=avatar)
|
||||
|
@ -175,8 +186,12 @@ class UtilCog(Scale):
|
|||
required=False,
|
||||
)
|
||||
async def _userinfo(self, ctx: InteractionContext, user: User = None) -> None:
|
||||
await ctx.defer()
|
||||
if not user:
|
||||
user = ctx.author
|
||||
if not await ctx.guild.fetch_member(user.id):
|
||||
await ctx.send("That user isn't in this guild.", ephemeral=True)
|
||||
return
|
||||
user_roles = user.roles
|
||||
if user_roles:
|
||||
user_roles = sorted(user.roles, key=lambda x: -x.position)
|
||||
|
|
Loading…
Add table
Reference in a new issue