mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 14:09:13 -06:00
fixes
This commit is contained in:
parent
e02153b7b6
commit
2680319015
@ -30,13 +30,12 @@ class Group(commands.Cog, name="group"):
|
|||||||
name=role.name, roleID=role.id, permissions=perms
|
name=role.name, roleID=role.id, permissions=perms
|
||||||
)
|
)
|
||||||
|
|
||||||
squadjs = mysql.connector.connect(user='squadjs', password=self.client.mysqlpass,
|
self.client.squadjs.connect()
|
||||||
host='asgard.orion-technologies.io', database='squadjs', use_pure=False)
|
|
||||||
membsup = []
|
membsup = []
|
||||||
for memb in role.members:
|
for memb in role.members:
|
||||||
membsup.append(memb.id)
|
membsup.append(memb.id)
|
||||||
if len(membsup) > 0:
|
if len(membsup) > 0:
|
||||||
memupcur = squadjs.cursor(buffered=True)
|
memupcur = self.client.squadjs.cursor(buffered=True)
|
||||||
in_params = ','.join(['%s'] * len(membsup))
|
in_params = ','.join(['%s'] * len(membsup))
|
||||||
sqlstate = "SELECT * FROM DBLog_SteamUsers WHERE discordID IN (%s)" % in_params
|
sqlstate = "SELECT * FROM DBLog_SteamUsers WHERE discordID IN (%s)" % in_params
|
||||||
log.info(sqlstate)
|
log.info(sqlstate)
|
||||||
@ -46,8 +45,8 @@ class Group(commands.Cog, name="group"):
|
|||||||
for data in udata:
|
for data in udata:
|
||||||
self.client.whitelistGrps[role.id].addMember(config.WhitelistMember(data[2], data[1], data[0]))
|
self.client.whitelistGrps[role.id].addMember(config.WhitelistMember(data[2], data[1], data[0]))
|
||||||
|
|
||||||
squadjs.commit()
|
self.client.squadjs.commit()
|
||||||
squadjs.close()
|
self.client.squadjs.close()
|
||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
async def add(
|
async def add(
|
||||||
@ -71,7 +70,7 @@ class Group(commands.Cog, name="group"):
|
|||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
shortname: str,
|
shortname: str,
|
||||||
remoteURL: str,
|
remoteurl: str,
|
||||||
perms: str = 'whitelist'
|
perms: str = 'whitelist'
|
||||||
):
|
):
|
||||||
if os.path.exists(f"wlgrps/{shortname}.cfg"):
|
if os.path.exists(f"wlgrps/{shortname}.cfg"):
|
||||||
@ -79,7 +78,7 @@ class Group(commands.Cog, name="group"):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
outfile = open(f"./wlgrps/{shortname}.cfg", "w")
|
outfile = open(f"./wlgrps/{shortname}.cfg", "w")
|
||||||
outfile.write(f"remotelist={remoteURL}\n")
|
outfile.write(f"remotelist={remoteurl}\n")
|
||||||
outfile.write(f"permissions={perms}\n")
|
outfile.write(f"permissions={perms}\n")
|
||||||
outfile.close()
|
outfile.close()
|
||||||
await interaction.response.send_message("created!")
|
await interaction.response.send_message("created!")
|
||||||
|
@ -18,13 +18,13 @@ class Whitelist(commands.Cog):
|
|||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
async def link(self, interaction: discord.Interaction, steam64: str):
|
async def link(self, interaction: discord.Interaction, steam64: str):
|
||||||
squadjs = mysql.connector.connect(user='squadjs', password=self.client.mysqlpass, host='asgard.orion-technologies.io', database='squadjs', use_pure=False)
|
self.client.squadjs.connect()
|
||||||
if not interaction.guild:
|
if not interaction.guild:
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
"This command must be ran within a discord server!"
|
"This command must be ran within a discord server!"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
updatecur = squadjs.cursor(buffered=True)
|
updatecur = self.client.squadjs.cursor(buffered=True)
|
||||||
try:
|
try:
|
||||||
updatecur.execute(self.client.squadjs_updateDiscordID, (interaction.user.id, steam64))
|
updatecur.execute(self.client.squadjs_updateDiscordID, (interaction.user.id, steam64))
|
||||||
rowsaffected = updatecur.rowcount
|
rowsaffected = updatecur.rowcount
|
||||||
@ -38,7 +38,7 @@ class Whitelist(commands.Cog):
|
|||||||
self.client.whitelistGrps[urole.id].members[f"{interaction.user.id}"].steam64 = steam64
|
self.client.whitelistGrps[urole.id].members[f"{interaction.user.id}"].steam64 = steam64
|
||||||
self.client.whitelistGrps[urole.id].updateGroup()
|
self.client.whitelistGrps[urole.id].updateGroup()
|
||||||
await interaction.response.send_message("SteamID already linked, roles updated.")
|
await interaction.response.send_message("SteamID already linked, roles updated.")
|
||||||
squadjs.commit()
|
self.client.squadjs.commit()
|
||||||
return
|
return
|
||||||
except mysql.connector.Error as err:
|
except mysql.connector.Error as err:
|
||||||
log.error("MYSQL error!")
|
log.error("MYSQL error!")
|
||||||
@ -48,6 +48,6 @@ class Whitelist(commands.Cog):
|
|||||||
if urole.id in self.client.whitelistGrps.keys():
|
if urole.id in self.client.whitelistGrps.keys():
|
||||||
disusername = interaction.user.nick if interaction.user.nick is not None else interaction.user.name
|
disusername = interaction.user.nick if interaction.user.nick is not None else interaction.user.name
|
||||||
self.client.whitelistGrps[urole.id].addMember(config.WhitelistMember(interaction.user.id, disusername, steam64))
|
self.client.whitelistGrps[urole.id].addMember(config.WhitelistMember(interaction.user.id, disusername, steam64))
|
||||||
squadjs.commit()
|
self.client.squadjs.commit()
|
||||||
squadjs.close()
|
self.client.squadjs.close()
|
||||||
await interaction.response.send_message(f"discord is linked to steamID, roles updated.")
|
await interaction.response.send_message(f"discord is linked to steamID, roles updated.")
|
||||||
|
@ -39,7 +39,8 @@ class Bot(commands.Bot):
|
|||||||
intents=intents,
|
intents=intents,
|
||||||
help_command=commands.DefaultHelpCommand(dm_help=True),
|
help_command=commands.DefaultHelpCommand(dm_help=True),
|
||||||
)
|
)
|
||||||
self.mysqlpass = mysqlpass
|
self.squadjs = mysql.connector.connect(user='squadjs', password=mysqlpass,
|
||||||
|
host='asgard.orion-technologies.io', database='squadjs', use_pure=False)
|
||||||
|
|
||||||
async def on_command(self, ctx: commands.Context):
|
async def on_command(self, ctx: commands.Context):
|
||||||
log.info(f"{ctx.author} ({ctx.author.id}) invoked command: {ctx.command.name}, {ctx.message}")
|
log.info(f"{ctx.author} ({ctx.author.id}) invoked command: {ctx.command.name}, {ctx.message}")
|
||||||
@ -60,6 +61,7 @@ class Bot(commands.Bot):
|
|||||||
|
|
||||||
async def on_member_update(self, before: discord.Member, after: discord.Member):
|
async def on_member_update(self, before: discord.Member, after: discord.Member):
|
||||||
disusername = after.nick if after.nick is not None else after.name
|
disusername = after.nick if after.nick is not None else after.name
|
||||||
|
self.squadjs.connect()
|
||||||
findcur = self.squadjs.cursor(buffered=True)
|
findcur = self.squadjs.cursor(buffered=True)
|
||||||
findcur.execute(self.squadjs_findByDiscordID, [f"{after.id}"])
|
findcur.execute(self.squadjs_findByDiscordID, [f"{after.id}"])
|
||||||
if findcur.arraysize <= 0:
|
if findcur.arraysize <= 0:
|
||||||
@ -92,6 +94,7 @@ class Bot(commands.Bot):
|
|||||||
continue
|
continue
|
||||||
self.whitelistGrps[addroleid].addMember(config.WhitelistMember(after.id, disusername, userdata[0]))
|
self.whitelistGrps[addroleid].addMember(config.WhitelistMember(after.id, disusername, userdata[0]))
|
||||||
self.squadjs.commit()
|
self.squadjs.commit()
|
||||||
|
self.squadjs.close()
|
||||||
|
|
||||||
async def setup_hook(self):
|
async def setup_hook(self):
|
||||||
log.info("Setting up bot")
|
log.info("Setting up bot")
|
||||||
|
Loading…
Reference in New Issue
Block a user