Will 4ddd576315 [V3 Admin] Rewrite of Squid-Plugins Admin cog (#825)
* Add/remove roles

* Announcement

* Edit role stuff

A bit of refactoring

* Selfrole stuff

* Add announce ignore capabilities

* announce configurations

Announcement fixes

* Serverlock initial commit

* Add some admin tests

better test

* Update for new config

* Add user hierarchy checks

* Fix tests

* Update from rebase

* Fix config getter

* Fix async getters/selfrole
2017-10-14 18:05:08 -04:00

34 lines
1.1 KiB
Python

import discord
from discord.ext import commands
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.instance
if admin is None:
raise commands.BadArgument("Admin 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