mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-08 02:12:32 -05:00
[Docs] Mod Cog Guide (#4886)
* Initial commit * Add some args * bool prolog * index * Add more arguments * more arguments, style fixes * improve naming of arguments * Fix up backlog * Run black * extra corrections from backlog * Update tempban arg names * backlog * change prolog type * Change kick argument prolog to member instead of user * Update argument names * missed a colon * Update prolog to be friendly with non-positional args * Edit through the decorator instead * Add back docstring spacing * black * usage in decorator for name commands * Fix command signature * fixup docstring spacing * style fixes * Add spacing inside unban docstring * Rename args instead of using usage * black - simple * Add labeler glob * unify style * rename variables instead of usage * Update docstrings correspondingly * run black * update description in usage * ehh this isn't necessary... * fix up tags * fix grammar and accuracy issues * fix docstring too
This commit is contained in:
@@ -32,8 +32,8 @@ class ModInfo(MixinMeta):
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(manage_nicknames=True)
|
||||
@checks.admin_or_permissions(manage_nicknames=True)
|
||||
async def rename(self, ctx: commands.Context, user: discord.Member, *, nickname: str = ""):
|
||||
"""Change a user's nickname.
|
||||
async def rename(self, ctx: commands.Context, member: discord.Member, *, nickname: str = ""):
|
||||
"""Change a member's nickname.
|
||||
|
||||
Leaving the nickname empty will remove it.
|
||||
"""
|
||||
@@ -46,8 +46,8 @@ class ModInfo(MixinMeta):
|
||||
return
|
||||
if not (
|
||||
(me.guild_permissions.manage_nicknames or me.guild_permissions.administrator)
|
||||
and me.top_role > user.top_role
|
||||
and user != ctx.guild.owner
|
||||
and me.top_role > member.top_role
|
||||
and member != ctx.guild.owner
|
||||
):
|
||||
await ctx.send(
|
||||
_(
|
||||
@@ -57,7 +57,7 @@ class ModInfo(MixinMeta):
|
||||
)
|
||||
else:
|
||||
try:
|
||||
await user.edit(reason=get_audit_reason(ctx.author, None), nick=nickname)
|
||||
await member.edit(reason=get_audit_reason(ctx.author, None), nick=nickname)
|
||||
except discord.Forbidden:
|
||||
# Just in case we missed something in the permissions check above
|
||||
await ctx.send(_("I do not have permission to rename that member."))
|
||||
@@ -160,58 +160,60 @@ class ModInfo(MixinMeta):
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def userinfo(self, ctx, *, user: discord.Member = None):
|
||||
"""Show information about a user.
|
||||
async def userinfo(self, ctx, *, member: discord.Member = None):
|
||||
"""Show information about a member.
|
||||
|
||||
This includes fields for status, discord join date, server
|
||||
join date, voice state and previous names/nicknames.
|
||||
|
||||
If the user has no roles, previous names or previous nicknames,
|
||||
If the member has no roles, previous names or previous nicknames,
|
||||
these fields will be omitted.
|
||||
"""
|
||||
author = ctx.author
|
||||
guild = ctx.guild
|
||||
|
||||
if not user:
|
||||
user = author
|
||||
if not member:
|
||||
member = author
|
||||
|
||||
# A special case for a special someone :^)
|
||||
special_date = datetime(2016, 1, 10, 6, 8, 4, 443000)
|
||||
is_special = user.id == 96130341705637888 and guild.id == 133049272517001216
|
||||
is_special = member.id == 96130341705637888 and guild.id == 133049272517001216
|
||||
|
||||
roles = user.roles[-1:0:-1]
|
||||
names, nicks = await self.get_names_and_nicks(user)
|
||||
roles = member.roles[-1:0:-1]
|
||||
names, nicks = await self.get_names_and_nicks(member)
|
||||
|
||||
joined_at = user.joined_at if not is_special else special_date
|
||||
since_created = (ctx.message.created_at - user.created_at).days
|
||||
joined_at = member.joined_at if not is_special else special_date
|
||||
since_created = (ctx.message.created_at - member.created_at).days
|
||||
if joined_at is not None:
|
||||
since_joined = (ctx.message.created_at - joined_at).days
|
||||
user_joined = joined_at.strftime("%d %b %Y %H:%M")
|
||||
else:
|
||||
since_joined = "?"
|
||||
user_joined = _("Unknown")
|
||||
user_created = user.created_at.strftime("%d %b %Y %H:%M")
|
||||
voice_state = user.voice
|
||||
user_created = member.created_at.strftime("%d %b %Y %H:%M")
|
||||
voice_state = member.voice
|
||||
member_number = (
|
||||
sorted(guild.members, key=lambda m: m.joined_at or ctx.message.created_at).index(user)
|
||||
sorted(guild.members, key=lambda m: m.joined_at or ctx.message.created_at).index(
|
||||
member
|
||||
)
|
||||
+ 1
|
||||
)
|
||||
|
||||
created_on = _("{}\n({} days ago)").format(user_created, since_created)
|
||||
joined_on = _("{}\n({} days ago)").format(user_joined, since_joined)
|
||||
|
||||
if any(a.type is discord.ActivityType.streaming for a in user.activities):
|
||||
if any(a.type is discord.ActivityType.streaming for a in member.activities):
|
||||
statusemoji = "\N{LARGE PURPLE CIRCLE}"
|
||||
elif user.status.name == "online":
|
||||
elif member.status.name == "online":
|
||||
statusemoji = "\N{LARGE GREEN CIRCLE}"
|
||||
elif user.status.name == "offline":
|
||||
elif member.status.name == "offline":
|
||||
statusemoji = "\N{MEDIUM WHITE CIRCLE}\N{VARIATION SELECTOR-16}"
|
||||
elif user.status.name == "dnd":
|
||||
elif member.status.name == "dnd":
|
||||
statusemoji = "\N{LARGE RED CIRCLE}"
|
||||
elif user.status.name == "idle":
|
||||
elif member.status.name == "idle":
|
||||
statusemoji = "\N{LARGE ORANGE CIRCLE}"
|
||||
activity = _("Chilling in {} status").format(user.status)
|
||||
status_string = self.get_status_string(user)
|
||||
activity = _("Chilling in {} status").format(member.status)
|
||||
status_string = self.get_status_string(member)
|
||||
|
||||
if roles:
|
||||
|
||||
@@ -249,7 +251,7 @@ class ModInfo(MixinMeta):
|
||||
else:
|
||||
role_str = None
|
||||
|
||||
data = discord.Embed(description=status_string or activity, colour=user.colour)
|
||||
data = discord.Embed(description=status_string or activity, colour=member.colour)
|
||||
|
||||
data.add_field(name=_("Joined Discord on"), value=created_on)
|
||||
data.add_field(name=_("Joined this server on"), value=joined_on)
|
||||
@@ -279,22 +281,22 @@ class ModInfo(MixinMeta):
|
||||
value="{0.mention} ID: {0.id}".format(voice_state.channel),
|
||||
inline=False,
|
||||
)
|
||||
data.set_footer(text=_("Member #{} | User ID: {}").format(member_number, user.id))
|
||||
data.set_footer(text=_("Member #{} | User ID: {}").format(member_number, member.id))
|
||||
|
||||
name = str(user)
|
||||
name = " ~ ".join((name, user.nick)) if user.nick else name
|
||||
name = str(member)
|
||||
name = " ~ ".join((name, member.nick)) if member.nick else name
|
||||
name = filter_invites(name)
|
||||
|
||||
avatar = user.avatar_url_as(static_format="png")
|
||||
avatar = member.avatar_url_as(static_format="png")
|
||||
data.set_author(name=f"{statusemoji} {name}", url=avatar)
|
||||
data.set_thumbnail(url=avatar)
|
||||
|
||||
await ctx.send(embed=data)
|
||||
|
||||
@commands.command()
|
||||
async def names(self, ctx: commands.Context, *, user: discord.Member):
|
||||
"""Show previous names and nicknames of a user."""
|
||||
names, nicks = await self.get_names_and_nicks(user)
|
||||
async def names(self, ctx: commands.Context, *, member: discord.Member):
|
||||
"""Show previous names and nicknames of a member."""
|
||||
names, nicks = await self.get_names_and_nicks(member)
|
||||
msg = ""
|
||||
if names:
|
||||
msg += _("**Past 20 names**:")
|
||||
@@ -310,4 +312,4 @@ class ModInfo(MixinMeta):
|
||||
msg = filter_various_mentions(msg)
|
||||
await ctx.send(msg)
|
||||
else:
|
||||
await ctx.send(_("That user doesn't have any recorded name or nickname change."))
|
||||
await ctx.send(_("That member doesn't have any recorded name or nickname change."))
|
||||
|
||||
Reference in New Issue
Block a user