mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
* Dependency update discord.py==1.0.1 websockets<7 [style] black==19.3b0 [Docs] jinja==2.10.1 urllib3==1.24.2 Changes related to breaking changes from discord.py have also been made to match As of this commit, help formatter is back to discord.py's default
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import discord
|
|
from redbot.core import commands
|
|
from redbot.core.i18n import Translator
|
|
|
|
_ = Translator("AdminConverters", __file__)
|
|
|
|
|
|
class MemberDefaultAuthor(commands.Converter):
|
|
async def convert(self, ctx: commands.Context, arg: str) -> discord.Member:
|
|
member_converter = commands.MemberConverter()
|
|
try:
|
|
member = await member_converter.convert(ctx, arg)
|
|
except commands.BadArgument:
|
|
if arg.strip() != "":
|
|
raise
|
|
else:
|
|
member = ctx.author
|
|
return member
|
|
|
|
|
|
class SelfRole(commands.Converter):
|
|
async def convert(self, ctx: commands.Context, arg: str) -> discord.Role:
|
|
admin = ctx.command.cog
|
|
if admin is None:
|
|
raise commands.BadArgument(_("The Admin cog is not loaded."))
|
|
|
|
conf = admin.conf
|
|
selfroles = await conf.guild(ctx.guild).selfroles()
|
|
|
|
role_converter = commands.RoleConverter()
|
|
role = await role_converter.convert(ctx, arg)
|
|
|
|
if role.id not in selfroles:
|
|
raise commands.BadArgument(_("The provided role is not a valid selfrole."))
|
|
return role
|