(lion): Add more properties, and default tags.
Added `Lion.guild`. Added `Lion.ctx`. Added `Lion.profile_tags`, with defaults.
This commit is contained in:
@@ -7,6 +7,8 @@ from meta import client
|
||||
from data import tables as tb
|
||||
from settings import UserSettings, GuildSettings
|
||||
|
||||
from LionContext import LionContext
|
||||
|
||||
|
||||
class Lion:
|
||||
"""
|
||||
@@ -63,7 +65,11 @@ class Lion:
|
||||
return (self.guildid, self.userid)
|
||||
|
||||
@property
|
||||
def member(self):
|
||||
def guild(self) -> discord.Guild:
|
||||
return client.get_guild(self.guildid)
|
||||
|
||||
@property
|
||||
def member(self) -> discord.Member:
|
||||
"""
|
||||
The discord `Member` corresponding to this user.
|
||||
May be `None` if the member is no longer in the guild or the caches aren't populated.
|
||||
@@ -110,6 +116,15 @@ class Lion:
|
||||
"""
|
||||
return GuildSettings(self.guildid)
|
||||
|
||||
@property
|
||||
def ctx(self) -> LionContext:
|
||||
"""
|
||||
Manufacture a `LionContext` with the lion member as an author.
|
||||
Useful for accessing member context utilities.
|
||||
Be aware that `author` may be `None` if the member was not cached.
|
||||
"""
|
||||
return LionContext(client, guild=self.guild, author=self.member)
|
||||
|
||||
@property
|
||||
def time(self):
|
||||
"""
|
||||
@@ -246,6 +261,20 @@ class Lion:
|
||||
|
||||
return remaining
|
||||
|
||||
@property
|
||||
def profile_tags(self):
|
||||
"""
|
||||
Returns a list of profile tags, or the default tags.
|
||||
"""
|
||||
tags = tb.profile_tags.queries.get_tags_for(self.guildid, self.userid)
|
||||
prefix = self.ctx.best_prefix
|
||||
return tags or [
|
||||
f"Use {prefix}setprofile",
|
||||
"and add your tags",
|
||||
"to this section",
|
||||
f"See {prefix}help setprofile for more"
|
||||
]
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
@@ -260,7 +289,6 @@ class Lion:
|
||||
|
||||
return name
|
||||
|
||||
|
||||
def update_saved_data(self, member: discord.Member):
|
||||
"""
|
||||
Update the stored discord data from the givem member.
|
||||
|
||||
Reference in New Issue
Block a user