Fix verification
This commit is contained in:
parent
dc5919ff86
commit
be6d88449e
1 changed files with 35 additions and 31 deletions
|
@ -3,8 +3,8 @@ import asyncio
|
|||
from random import randint
|
||||
|
||||
from dis_snek import InteractionContext, Scale, Snake
|
||||
from dis_snek.models.application_commands import slash_command
|
||||
from dis_snek.models.discord.components import Button, ButtonStyles, spread_to_rows
|
||||
from dis_snek.models.snek.application_commands import slash_command
|
||||
from dis_snek.models.snek.command import cooldown
|
||||
from dis_snek.models.snek.cooldowns import Buckets
|
||||
from jarvis_core.db import q
|
||||
|
@ -41,10 +41,10 @@ class VerifyCog(Scale):
|
|||
await ctx.defer()
|
||||
role = await Setting.find_one(q(guild=ctx.guild.id, setting="verified"))
|
||||
if not role:
|
||||
await ctx.send("This guild has not enabled verification", delete_after=5)
|
||||
message = await ctx.send("This guild has not enabled verification", ephemeral=True)
|
||||
return
|
||||
if await ctx.guild.get_role(role.value) in ctx.author.roles:
|
||||
await ctx.send("You are already verified.", delete_after=5)
|
||||
if await ctx.guild.fetch_role(role.value) in ctx.author.roles:
|
||||
await ctx.send("You are already verified.", ephemeral=True)
|
||||
return
|
||||
components = create_layout()
|
||||
message = await ctx.send(
|
||||
|
@ -53,30 +53,34 @@ class VerifyCog(Scale):
|
|||
)
|
||||
|
||||
try:
|
||||
context = await self.bot.wait_for_component(
|
||||
messages=message, check=lambda x: ctx.author.id == x.author.id, timeout=30
|
||||
verified = False
|
||||
while not verified:
|
||||
response = await self.bot.wait_for_component(
|
||||
messages=message,
|
||||
check=lambda x: ctx.author.id == x.context.author.id,
|
||||
timeout=30,
|
||||
)
|
||||
|
||||
correct = context.context.custom_id.split("||")[-1] == "yes"
|
||||
correct = response.context.custom_id.split("||")[-1] == "yes"
|
||||
if correct:
|
||||
for row in components:
|
||||
for component in row.components:
|
||||
component.disabled = True
|
||||
setting = await Setting.find_one(guild=ctx.guild.id, setting="verified")
|
||||
role = await ctx.guild.get_role(setting.value)
|
||||
await ctx.author.add_roles(role, reason="Verification passed")
|
||||
setting = await Setting.find_one(guild=ctx.guild.id, setting="unverified")
|
||||
setting = await Setting.find_one(q(guild=ctx.guild.id, setting="verified"))
|
||||
role = await ctx.guild.fetch_role(setting.value)
|
||||
await ctx.author.add_role(role, reason="Verification passed")
|
||||
setting = await Setting.find_one(q(guild=ctx.guild.id, setting="unverified"))
|
||||
if setting:
|
||||
role = await ctx.guild.get_role(setting.value)
|
||||
await ctx.author.remove_roles(role, reason="Verification passed")
|
||||
role = await ctx.guild.fetch_role(setting.value)
|
||||
await ctx.author.remove_role(role, reason="Verification passed")
|
||||
|
||||
await context.context.edit_origin(
|
||||
await response.context.edit_origin(
|
||||
content=f"Welcome, {ctx.author.mention}. Please enjoy your stay.",
|
||||
components=components,
|
||||
)
|
||||
await context.context.message.delete(delay=5)
|
||||
await response.context.message.delete(delay=5)
|
||||
else:
|
||||
await context.context.edit_origin(
|
||||
await response.context.edit_origin(
|
||||
content=(
|
||||
f"{ctx.author.mention}, incorrect. "
|
||||
"Please press the button that says `YES`"
|
||||
|
|
Loading…
Add table
Reference in a new issue