mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 16:29:13 -06:00
fix: properly allow user to set steam64
This commit is contained in:
parent
48540cd884
commit
dbca836d47
@ -1,29 +1,47 @@
|
|||||||
import discord
|
import discord
|
||||||
|
import logging
|
||||||
from autowl import config
|
from autowl import config
|
||||||
from autowl.bot import Bot
|
from autowl.bot import Bot
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Whitelist(commands.Cog):
|
class Whitelist(commands.Cog):
|
||||||
def __init__(self, client: Bot):
|
def __init__(self, client: Bot):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
async def register(self, interaction: discord.Interaction, steam64: int):
|
async def register(self, interaction: discord.Interaction, steam64: int):
|
||||||
ctx: commands.Context = await self.client.get_context(interaction)
|
if not interaction.guild:
|
||||||
if not ctx.guild:
|
await interaction.response.send_message(
|
||||||
ctx.reply("This command must be ran within a discord server!")
|
"This command must be ran within a discord server!"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not len(self.client.whitelist.keys()):
|
||||||
|
await interaction.response.send_message(
|
||||||
|
"There are no Whitelist roles defined, unable to continue!"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
steam64_updated = False
|
steam64_updated = False
|
||||||
for role in ctx.author.roles:
|
for role in interaction.user.roles:
|
||||||
for group in self.client.whitelist:
|
for group in self.client.whitelist:
|
||||||
if role.id == group.discord_role_id:
|
if role.id == self.client.whitelist[group].discord_role_id:
|
||||||
steam64_updated = True
|
steam64_updated = True
|
||||||
group.members[ctx.author.id] = config.WhitelistMember(
|
self.client.whitelist[group].members[
|
||||||
ctx.author.name, steam64
|
interaction.user.id
|
||||||
)
|
] = config.WhitelistMember(interaction.user.name, steam64)
|
||||||
|
|
||||||
if steam64_updated:
|
if steam64_updated:
|
||||||
ctx.reply(f"Updated {ctx.author.name}'s whitelist steam64 to {steam64}!")
|
log.info(
|
||||||
|
f"Updated {interaction.user.name}'s ({interaction.user.id}) whitelist steam64 to {steam64}"
|
||||||
|
)
|
||||||
|
await interaction.response.send_message(
|
||||||
|
f"Updated `{interaction.user.name}`'s whitelist steam64 to `{steam64}`!"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(f"Unable to update `{interaction.user.name}`'s whitelist steam64 as they are not in a valid Whitelisted group")
|
||||||
|
Loading…
Reference in New Issue
Block a user