[mod-roles] Done
This commit is contained in:
parent
b5f8c2c923
commit
fdf12bd2bd
5
main.py
5
main.py
@ -396,14 +396,13 @@ class ClientById:
|
|||||||
return channel.send(*args, **kwargs)
|
return channel.send(*args, **kwargs)
|
||||||
|
|
||||||
async def get_role(self, id_=None, name=None):
|
async def get_role(self, id_=None, name=None):
|
||||||
if id_:
|
if id_ is not None:
|
||||||
for guild in self.client.guilds:
|
for guild in self.client.guilds:
|
||||||
role = discord.utils.get(guild.roles, id=id_)
|
role = discord.utils.get(guild.roles, id=id_)
|
||||||
if role:
|
if role:
|
||||||
return role
|
return role
|
||||||
if name:
|
if name is not None:
|
||||||
for guild in self.client.guilds:
|
for guild in self.client.guilds:
|
||||||
print(list(r.name for r in guild.roles))
|
|
||||||
role = discord.utils.get(guild.roles, name=name)
|
role = discord.utils.get(guild.roles, name=name)
|
||||||
if role:
|
if role:
|
||||||
return role
|
return role
|
||||||
|
@ -103,4 +103,4 @@ class MainClass(BaseClassPython):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
# Save now to avoid deleting unkown message
|
# Save now to avoid deleting unkown message
|
||||||
await self.objects.save_object('errorsList', self.errorsList)
|
self.objects.save_object('errorsList', self.errorsList)
|
||||||
|
@ -31,5 +31,11 @@ class MainClass(BaseClassPython):
|
|||||||
if len(args) <= 1:
|
if len(args) <= 1:
|
||||||
await message.channel.send("Il manque des arguments à la commande")
|
await message.channel.send("Il manque des arguments à la commande")
|
||||||
for role in args[0:]:
|
for role in args[0:]:
|
||||||
role = await self.client.id.get_role(name = role)
|
drole = await self.client.id.get_role(name="Invité")
|
||||||
print(role.name)
|
if drole is None or str(drole.id) not in self.config.roles.keys():
|
||||||
|
await message.channel.send(f"Le role {role} n'est pas disponible.")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
await message.author.add_roles(drole)
|
||||||
|
except discord.errors.Forbidden:
|
||||||
|
await message.channel.send(f"Je n'ai pas la permission d'attribuer le role {role}.")
|
||||||
|
Loading…
Reference in New Issue
Block a user