def add(self, ctx: DogbotContext, type: AutoroleType, *roles: discord.Role):
"""Adds autoroles."""
for role in roles:
if role.position > ctx.guild.me.top_role.position:
await ctx.send('I can\'t autorole the role \"{0.name}\". It\'s too high on the role list. Move my '
'role above it.'.format(role))
return
log.debug('Adding autorole. (type=%s, roles=%s)', type, roles)
try:
async with ctx.acquire() as conn:
await conn.execute('INSERT INTO autoroles (guild_id, type, roles) VALUES ($1, $2, $3)', ctx.guild.id,
type.name, list(map(lambda r: r.id, roles)))
except asyncpg.UniqueViolationError:
return await ctx.send('There\'s already autoroles for that type on this server.')
await ctx.ok()
评论列表
文章目录