Spaces:
Running
Running
fix (user_id is dynamically generated from whoever clicks the button now)
Browse files
app.py
CHANGED
@@ -60,17 +60,17 @@ async def sendlink(ctx, user: discord.User):
|
|
60 |
|
61 |
|
62 |
class DMButton(Button):
|
63 |
-
def __init__(self, label, style
|
64 |
super().__init__(label=label, style=style)
|
65 |
-
self.user_id = user_id
|
66 |
|
67 |
async def callback(self, interaction: discord.Interaction):
|
68 |
# await interaction.user.send(self.message) # this is for DMs, but users may have DMs disabled
|
69 |
-
|
70 |
-
|
|
|
71 |
unique_string = generate_unique_string()
|
72 |
-
user_tokens[
|
73 |
-
unique_link = f"{GRADIO_APP_URL}?user_id={
|
74 |
message = f"To complete the verification process, visit this Space and click the '🤗Sign in with Hugging Face' button: {unique_link}"
|
75 |
await interaction.response.send_message(message, ephemeral=True)
|
76 |
|
@@ -78,7 +78,7 @@ class DMButton(Button):
|
|
78 |
@bot.command(name='sendbutton')
|
79 |
async def send_button(ctx):
|
80 |
if ctx.author.id == 811235357663297546:
|
81 |
-
button = DMButton(label="Verify Discord Account", style=discord.ButtonStyle.primary
|
82 |
view = ButtonView()
|
83 |
view.add_item(button)
|
84 |
await ctx.send("Click the button below to generate your verification link:",view=view) #
|
|
|
60 |
|
61 |
|
62 |
class DMButton(Button):
|
63 |
+
def __init__(self, label, style):
|
64 |
super().__init__(label=label, style=style)
|
|
|
65 |
|
66 |
async def callback(self, interaction: discord.Interaction):
|
67 |
# await interaction.user.send(self.message) # this is for DMs, but users may have DMs disabled
|
68 |
+
user_id = interaction.user.id
|
69 |
+
if int(user_id) in user_tokens:
|
70 |
+
del user_tokens[int(user_id)] # always delete all past tokens when creating new link
|
71 |
unique_string = generate_unique_string()
|
72 |
+
user_tokens[user_id] = unique_string
|
73 |
+
unique_link = f"{GRADIO_APP_URL}?user_id={user_id}&token={unique_string}"
|
74 |
message = f"To complete the verification process, visit this Space and click the '🤗Sign in with Hugging Face' button: {unique_link}"
|
75 |
await interaction.response.send_message(message, ephemeral=True)
|
76 |
|
|
|
78 |
@bot.command(name='sendbutton')
|
79 |
async def send_button(ctx):
|
80 |
if ctx.author.id == 811235357663297546:
|
81 |
+
button = DMButton(label="Verify Discord Account", style=discord.ButtonStyle.primary)
|
82 |
view = ButtonView()
|
83 |
view.add_item(button)
|
84 |
await ctx.send("Click the button below to generate your verification link:",view=view) #
|