mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Admin] Add [p]selfroleset clear command (#5387)
This commit is contained in:
parent
d56f31a708
commit
b64ece3ee9
@ -160,6 +160,22 @@ Add a role, or a selection of roles, to the list of available selfroles.
|
|||||||
|
|
||||||
* ``<role>``: The role to add to the list. |role-input|
|
* ``<role>``: The role to add to the list. |role-input|
|
||||||
|
|
||||||
|
.. _admin-command-selfroleset-clear:
|
||||||
|
|
||||||
|
"""""""""""""""""
|
||||||
|
selfroleset clear
|
||||||
|
"""""""""""""""""
|
||||||
|
|
||||||
|
**Syntax**
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
[p]selfroleset clear
|
||||||
|
|
||||||
|
**Description**
|
||||||
|
|
||||||
|
Clear the list of available selfroles for this server.
|
||||||
|
|
||||||
.. _admin-command-selfroleset-remove:
|
.. _admin-command-selfroleset-remove:
|
||||||
|
|
||||||
""""""""""""""""""
|
""""""""""""""""""
|
||||||
|
|||||||
@ -3,10 +3,11 @@ import logging
|
|||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from redbot.core import Config, checks, commands
|
from redbot.core import Config, checks, commands
|
||||||
from redbot.core.i18n import Translator, cog_i18n
|
from redbot.core.i18n import Translator, cog_i18n
|
||||||
from redbot.core.utils.chat_formatting import box
|
from redbot.core.utils.chat_formatting import box
|
||||||
|
from redbot.core.utils.predicates import MessagePredicate
|
||||||
|
|
||||||
from .announcer import Announcer
|
from .announcer import Announcer
|
||||||
from .converters import SelfRole
|
from .converters import SelfRole
|
||||||
|
|
||||||
@ -509,6 +510,40 @@ class Admin(commands.Cog):
|
|||||||
|
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
|
|
||||||
|
@selfroleset.command(name="clear")
|
||||||
|
async def selfroleset_clear(self, ctx: commands.Context):
|
||||||
|
"""Clear the list of available selfroles for this server."""
|
||||||
|
current_selfroles = await self.config.guild(ctx.guild).selfroles()
|
||||||
|
|
||||||
|
if not current_selfroles:
|
||||||
|
return await ctx.send(_("There are currently no selfroles."))
|
||||||
|
|
||||||
|
await ctx.send(
|
||||||
|
_("Are you sure you want to clear this server's selfrole list?") + " (yes/no)"
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
pred = MessagePredicate.yes_or_no(ctx, user=ctx.author)
|
||||||
|
await ctx.bot.wait_for("message", check=pred, timeout=60)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
await ctx.send(_("You took too long to respond."))
|
||||||
|
return
|
||||||
|
if pred.result:
|
||||||
|
for role in current_selfroles:
|
||||||
|
role = ctx.guild.get_role(role)
|
||||||
|
if role is None:
|
||||||
|
continue
|
||||||
|
if not self.pass_user_hierarchy_check(ctx, role):
|
||||||
|
await ctx.send(
|
||||||
|
_(
|
||||||
|
"I cannot clear the selfroles because the selfrole '{role.name}' is higher than or equal to your highest role in the Discord hierarchy."
|
||||||
|
).format(role=role)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
await self.config.guild(ctx.guild).selfroles.clear()
|
||||||
|
await ctx.send(_("Selfrole list cleared."))
|
||||||
|
else:
|
||||||
|
await ctx.send(_("No changes have been made."))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
async def serverlock(self, ctx: commands.Context):
|
async def serverlock(self, ctx: commands.Context):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user