def addrole(self, ctx, rolename, user: discord.Member=None):
"""Adds a role to a user, defaults to author
Role name must be in quotes if there are spaces."""
author = ctx.message.author
channel = ctx.message.channel
server = ctx.message.server
if user is None:
user = author
role = self._role_from_string(server, rolename)
if role is None:
await self.bot.say('That role cannot be found.')
return
if not channel.permissions_for(server.me).manage_roles:
await self.bot.say('I don\'t have manage_roles.')
return
await self.bot.add_roles(user, role)
await self.bot.say('Added role {} to {}'.format(role.name, user.name))
评论列表
文章目录