def describe(thing: Any, *, mention=False, before='', created=False, joined=False, quote=False):
"""
Returns a string representing an project. Usually consists of the object in string form,
then the object's ID in parentheses after.
Parameters
----------
thing
The thing to describe. Usually a superclass of :class:`discord.Object`.
mention
Specifies whether to mention the thing instead of using its string representation.
before
Specifies text to insert after name and ID.
created
Specifies whether to append the ``created_at`` attribute, post-processed with :func:`ago`.
joined
Specifies whether to append the ``joined_at`` attribute, post-processed with :func:`ago`.
quote
Specifies whether to quote the name of the thing.
"""
# get name, might be mention
name = str(thing) if not mention else thing.mention
# handle emoji specially
if isinstance(thing, discord.Emoji):
name = f'`{":" + thing.name + ":" if thing.require_colons else thing.name}`'
if quote:
name = '"' + name + '"'
# name + id
message = f'{name} (`{thing.id}`)'
# objects have id only
if isinstance(thing, discord.Object):
message = f'`{thing.id}`'
if before:
message += ' ' + before
if created:
message += f', created {ago(thing.created_at)}'
if joined and isinstance(thing, discord.Member):
message += f', joined {ago(thing.joined_at)}'
return message
评论列表
文章目录