mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
Accept mentions in [p]cleanup user (#5169)
* Accept mentions in `[p]cleanup user` * Updated spacing & formatting on info logging * Whoops... Co-authored-by: Kowlin <boxedpp@gmail.com>
This commit is contained in:
parent
b0f93a3ce1
commit
88abe469b6
@ -4,6 +4,7 @@ from typing import Callable, List, Optional, Set, Union
|
|||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
|
from redbot.cogs.mod.converters import RawUserIds
|
||||||
from redbot.core import checks, commands
|
from redbot.core import checks, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.i18n import Translator, cog_i18n
|
from redbot.core.i18n import Translator, cog_i18n
|
||||||
@ -188,7 +189,7 @@ class Cleanup(commands.Cog):
|
|||||||
)
|
)
|
||||||
to_delete.append(ctx.message)
|
to_delete.append(ctx.message)
|
||||||
|
|
||||||
reason = "{}({}) deleted {} messages containing '{}' in channel {}.".format(
|
reason = "{}({}) deleted {} messages containing '{}' in channel #{}.".format(
|
||||||
author.name,
|
author.name,
|
||||||
author.id,
|
author.id,
|
||||||
humanize_number(len(to_delete), override_locale="en_us"),
|
humanize_number(len(to_delete), override_locale="en_us"),
|
||||||
@ -204,7 +205,11 @@ class Cleanup(commands.Cog):
|
|||||||
@checks.mod_or_permissions(manage_messages=True)
|
@checks.mod_or_permissions(manage_messages=True)
|
||||||
@commands.bot_has_permissions(manage_messages=True)
|
@commands.bot_has_permissions(manage_messages=True)
|
||||||
async def user(
|
async def user(
|
||||||
self, ctx: commands.Context, user: str, number: positive_int, delete_pinned: bool = False
|
self,
|
||||||
|
ctx: commands.Context,
|
||||||
|
user: Union[discord.Member, RawUserIds],
|
||||||
|
number: positive_int,
|
||||||
|
delete_pinned: bool = False,
|
||||||
):
|
):
|
||||||
"""Delete the last X messages from a specified user in the current channel.
|
"""Delete the last X messages from a specified user in the current channel.
|
||||||
|
|
||||||
@ -221,15 +226,11 @@ class Cleanup(commands.Cog):
|
|||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
|
|
||||||
member = None
|
member = None
|
||||||
try:
|
if isinstance(user, discord.Member):
|
||||||
member = await commands.MemberConverter().convert(ctx, user)
|
member = user
|
||||||
except commands.BadArgument:
|
|
||||||
try:
|
|
||||||
_id = int(user)
|
|
||||||
except ValueError:
|
|
||||||
raise commands.BadArgument()
|
|
||||||
else:
|
|
||||||
_id = member.id
|
_id = member.id
|
||||||
|
else:
|
||||||
|
_id = user
|
||||||
|
|
||||||
author = ctx.author
|
author = ctx.author
|
||||||
|
|
||||||
@ -254,8 +255,8 @@ class Cleanup(commands.Cog):
|
|||||||
to_delete.append(ctx.message)
|
to_delete.append(ctx.message)
|
||||||
|
|
||||||
reason = (
|
reason = (
|
||||||
"{}({}) deleted {} messages "
|
"{}({}) deleted {} messages"
|
||||||
" made by {}({}) in channel {}."
|
" made by {}({}) in channel #{}."
|
||||||
"".format(
|
"".format(
|
||||||
author.name,
|
author.name,
|
||||||
author.id,
|
author.id,
|
||||||
@ -311,7 +312,7 @@ class Cleanup(commands.Cog):
|
|||||||
channel=channel, number=None, after=after, delete_pinned=delete_pinned
|
channel=channel, number=None, after=after, delete_pinned=delete_pinned
|
||||||
)
|
)
|
||||||
|
|
||||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
reason = "{}({}) deleted {} messages in channel #{}.".format(
|
||||||
author.name,
|
author.name,
|
||||||
author.id,
|
author.id,
|
||||||
humanize_number(len(to_delete), override_locale="en_US"),
|
humanize_number(len(to_delete), override_locale="en_US"),
|
||||||
@ -366,7 +367,7 @@ class Cleanup(commands.Cog):
|
|||||||
)
|
)
|
||||||
to_delete.append(ctx.message)
|
to_delete.append(ctx.message)
|
||||||
|
|
||||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
reason = "{}({}) deleted {} messages in channel #{}.".format(
|
||||||
author.name,
|
author.name,
|
||||||
author.id,
|
author.id,
|
||||||
humanize_number(len(to_delete), override_locale="en_US"),
|
humanize_number(len(to_delete), override_locale="en_US"),
|
||||||
@ -418,7 +419,7 @@ class Cleanup(commands.Cog):
|
|||||||
channel=channel, before=mtwo, after=mone, delete_pinned=delete_pinned
|
channel=channel, before=mtwo, after=mone, delete_pinned=delete_pinned
|
||||||
)
|
)
|
||||||
to_delete.append(ctx.message)
|
to_delete.append(ctx.message)
|
||||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
reason = "{}({}) deleted {} messages in channel #{}.".format(
|
||||||
author.name,
|
author.name,
|
||||||
author.id,
|
author.id,
|
||||||
humanize_number(len(to_delete), override_locale="en_US"),
|
humanize_number(len(to_delete), override_locale="en_US"),
|
||||||
@ -459,7 +460,7 @@ class Cleanup(commands.Cog):
|
|||||||
)
|
)
|
||||||
to_delete.append(ctx.message)
|
to_delete.append(ctx.message)
|
||||||
|
|
||||||
reason = "{}({}) deleted {} messages in channel {}.".format(
|
reason = "{}({}) deleted {} messages in channel #{}.".format(
|
||||||
author.name, author.id, len(to_delete), channel.name
|
author.name, author.id, len(to_delete), channel.name
|
||||||
)
|
)
|
||||||
log.info(reason)
|
log.info(reason)
|
||||||
@ -539,8 +540,8 @@ class Cleanup(commands.Cog):
|
|||||||
to_delete.append(ctx.message)
|
to_delete.append(ctx.message)
|
||||||
|
|
||||||
reason = (
|
reason = (
|
||||||
"{}({}) deleted {} "
|
"{}({}) deleted {}"
|
||||||
" command messages in channel {}."
|
" command messages in channel #{}."
|
||||||
"".format(
|
"".format(
|
||||||
author.name,
|
author.name,
|
||||||
author.id,
|
author.id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user