mirror of
https://github.com/CAG2Mark/SuperUserBot.git
synced 2024-12-26 06:56:27 +01:00
no longer require members intent
This commit is contained in:
parent
46e533dfad
commit
60eae4309a
1 changed files with 15 additions and 8 deletions
23
bot.py
23
bot.py
|
@ -36,10 +36,7 @@ class Bot:
|
||||||
logger = logging.getLogger("superuserbot")
|
logger = logging.getLogger("superuserbot")
|
||||||
|
|
||||||
def __init__(self, token, guild_data: GuildData, remove_queue: RemoveQueue) -> None:
|
def __init__(self, token, guild_data: GuildData, remove_queue: RemoveQueue) -> None:
|
||||||
intents = disnake.Intents.default()
|
client = commands.InteractionBot()
|
||||||
intents.members = True
|
|
||||||
|
|
||||||
client = commands.InteractionBot(intents=intents)
|
|
||||||
self.client = client
|
self.client = client
|
||||||
self.data: GuildData = guild_data
|
self.data: GuildData = guild_data
|
||||||
self.rq = remove_queue
|
self.rq = remove_queue
|
||||||
|
@ -79,9 +76,19 @@ class Bot:
|
||||||
await inter.response.send_message(embed=error_embed("Misconfigured sudo role. Please contact an administrator."), ephemeral=True)
|
await inter.response.send_message(embed=error_embed("Misconfigured sudo role. Please contact an administrator."), ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
await inter.user.add_roles(sudo_role)
|
try:
|
||||||
|
await inter.user.add_roles(sudo_role)
|
||||||
del_time = int(datetime.utcnow().timestamp()) + duration * 60
|
except disnake.errors.Forbidden:
|
||||||
|
await inter.response.send_message(embed=error_embed("I do not have permission to grant you the sudo role. Please contact an administrator."), ephemeral=True)
|
||||||
|
return;
|
||||||
|
except disnake.errors.NotFound:
|
||||||
|
await inter.response.send_message(embed=error_embed("Could not find the sudo role. Please contact an administrator."), ephemeral=True)
|
||||||
|
return;
|
||||||
|
except:
|
||||||
|
await inter.response.send_message(embed=error_embed("Unkown error when giving you the sudo role. Please contact an administrator."), ephemeral=True)
|
||||||
|
return;
|
||||||
|
|
||||||
|
del_time = int(datetime.utcnow().timestamp()) + duration
|
||||||
self.rq.add(del_time, inter.user.id, inter.guild_id, sudo_role_id)
|
self.rq.add(del_time, inter.user.id, inter.guild_id, sudo_role_id)
|
||||||
|
|
||||||
await inter.response.send_message(embed=success_embed("You are now in sudo mode."), ephemeral=True)
|
await inter.response.send_message(embed=success_embed("You are now in sudo mode."), ephemeral=True)
|
||||||
|
@ -139,7 +146,7 @@ class Bot:
|
||||||
guild = client.get_guild(guild)
|
guild = client.get_guild(guild)
|
||||||
if not guild: continue
|
if not guild: continue
|
||||||
|
|
||||||
user = guild.get_member(user)
|
user = await guild.get_or_fetch_member(user)
|
||||||
if not user: continue
|
if not user: continue
|
||||||
|
|
||||||
role = user.get_role(role)
|
role = user.get_role(role)
|
||||||
|
|
Loading…
Reference in a new issue