Spaces:
Running
Running
generate unique invite link every time button is pressed
Browse files
app.py
CHANGED
@@ -47,18 +47,20 @@ class DMButton(Button):
|
|
47 |
|
48 |
async def callback(self, interaction: discord.Interaction):
|
49 |
# await interaction.user.send(self.message) # this is for DMs, but users may have DMs disabled
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
@bot.command(name='sendbutton')
|
53 |
async def send_button(ctx):
|
54 |
if ctx.author.id == 811235357663297546:
|
55 |
-
|
56 |
-
user_tokens[ctx.author.id] = unique_string
|
57 |
-
unique_link = f"{GRADIO_APP_URL}?user_id={ctx.author.id}&token={unique_string}"
|
58 |
-
button = DMButton(label="Verify Discord Account", style=discord.ButtonStyle.primary, message=f"To complete the verification process, visit this Space and click the 'sign in with Hugging Face' button: {unique_link}")
|
59 |
view = View()
|
60 |
view.add_item(button)
|
61 |
-
await ctx.send(
|
62 |
|
63 |
|
64 |
# Gradio ------------------------------------------------------------------------------------------------------------
|
|
|
47 |
|
48 |
async def callback(self, interaction: discord.Interaction):
|
49 |
# await interaction.user.send(self.message) # this is for DMs, but users may have DMs disabled
|
50 |
+
unique_string = generate_unique_string()
|
51 |
+
user_tokens[self.user_id] = unique_string
|
52 |
+
unique_link = f"{GRADIO_APP_URL}?user_id={self.user_id}&token={unique_string}"
|
53 |
+
message = f"To complete the verification process, visit this Space and click the '🤗Sign in with Hugging Face' button: {unique_link}"
|
54 |
+
await interaction.response.send_message(message, ephemeral=True)
|
55 |
+
|
56 |
|
57 |
@bot.command(name='sendbutton')
|
58 |
async def send_button(ctx):
|
59 |
if ctx.author.id == 811235357663297546:
|
60 |
+
button = DMButton(label="Verify Discord Account", style=discord.ButtonStyle.primary}, user_id=ctx.author.id)
|
|
|
|
|
|
|
61 |
view = View()
|
62 |
view.add_item(button)
|
63 |
+
await ctx.send("Click the button below to generate your verification link:",view=view) #
|
64 |
|
65 |
|
66 |
# Gradio ------------------------------------------------------------------------------------------------------------
|