lunarflu HF Staff commited on
Commit
3148736
Β·
1 Parent(s): 34b1666

[main] more cleanup

Browse files
Files changed (1) hide show
  1. app.py +11 -16
app.py CHANGED
@@ -4,24 +4,20 @@ import gradio as gr
4
  from gradio_client import Client
5
  import os
6
  import threading
7
- #import json
8
- #import random
9
- #from PIL import Image
10
  import asyncio
11
- #import glob
12
-
13
  import falcon
14
  from falcon import try_falcon
15
  from falcon import continue_falcon
16
-
17
  import deepfloydif
18
  from deepfloydif import deepfloydif_stage_1
19
  from deepfloydif import deepfloydif_stage_2
20
  from deepfloydif import deepfloydif_stage_2_react_check
21
- #-------------------------------------------------------------------------------------------------------------------------------------
22
- MY_GUILD = discord.Object(id=1077674588122648679) # HF = 879548962464493619, test = 1077674588122648679
 
 
23
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
24
- #-------------------------------------------------------------------------------------------------------------------------------------
25
  class MyClient(discord.Client):
26
  """This structure allows slash commands to work instantly (instead of needing to sync global commands for up to an hour)"""
27
  def __init__(self, *, intents: discord.Intents):
@@ -34,12 +30,12 @@ class MyClient(discord.Client):
34
  await self.tree.sync(guild=MY_GUILD)
35
 
36
  client = MyClient(intents=discord.Intents.all())
37
- #-------------------------------------------------------------------------------------------------------------------------------------
38
  @client.event
39
  async def on_ready():
40
  print(f'Logged in as {client.user} (ID: {client.user.id})')
41
  print('------')
42
- #-------------------------------------------------------------------------------------------------------------------------------------
43
  @client.tree.command()
44
  @app_commands.describe(prompt='Enter some text to chat with the bot! Like this: /falcon Hello, how are you?')
45
  async def falcon(interaction: discord.Interaction, prompt: str):
@@ -48,7 +44,7 @@ async def falcon(interaction: discord.Interaction, prompt: str):
48
  await try_falcon(interaction, prompt)
49
  except Exception as e:
50
  print(f"Error: {e}")
51
- #-------------------------------------------------------------------------------------------------------------------------------------
52
  @client.event
53
  async def on_message(message):
54
  """Checks channel and continues Falcon conversation if it's the right Discord Thread"""
@@ -57,7 +53,7 @@ async def on_message(message):
57
  await message.remove_reaction('πŸ”', client.user) # test=πŸ” hf=πŸ”
58
  except Exception as e:
59
  print(f"Error: {e}")
60
- #-------------------------------------------------------------------------------------------------------------------------------------
61
  @client.tree.command()
62
  @app_commands.describe(prompt='Enter a prompt to generate an image! Can generate realistic text, too!')
63
  async def deepfloydif(interaction: discord.Interaction, prompt: str):
@@ -67,7 +63,7 @@ async def deepfloydif(interaction: discord.Interaction, prompt: str):
67
 
68
  except Exception as e:
69
  print(f"Error: {e}")
70
- #-------------------------------------------------------------------------------------------------------------------------------------
71
  @client.event
72
  async def on_reaction_add(reaction, user):
73
  """Checks for a reaction in order to call dfif2"""
@@ -76,9 +72,8 @@ async def on_reaction_add(reaction, user):
76
 
77
  except Exception as e:
78
  print(f"Error: {e} (known error, does not cause issues, low priority)")
79
- #-------------------------------------------------------------------------------------------------------------------------------------
80
  """This allows us to run the Discord bot in a Python thread"""
81
- DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
82
  def run_bot():
83
  client.run(DISCORD_TOKEN)
84
  threading.Thread(target=run_bot).start()
 
4
  from gradio_client import Client
5
  import os
6
  import threading
 
 
 
7
  import asyncio
 
 
8
  import falcon
9
  from falcon import try_falcon
10
  from falcon import continue_falcon
 
11
  import deepfloydif
12
  from deepfloydif import deepfloydif_stage_1
13
  from deepfloydif import deepfloydif_stage_2
14
  from deepfloydif import deepfloydif_stage_2_react_check
15
+
16
+ # HF GUILD SETTINGS
17
+ MY_GUILD_ID = 1077674588122648679 if os.getenv("TEST_ENV", False) else 879548962464493619
18
+ MY_GUILD = discord.Object(id=MY_GUILD_ID)
19
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
20
+
21
  class MyClient(discord.Client):
22
  """This structure allows slash commands to work instantly (instead of needing to sync global commands for up to an hour)"""
23
  def __init__(self, *, intents: discord.Intents):
 
30
  await self.tree.sync(guild=MY_GUILD)
31
 
32
  client = MyClient(intents=discord.Intents.all())
33
+
34
  @client.event
35
  async def on_ready():
36
  print(f'Logged in as {client.user} (ID: {client.user.id})')
37
  print('------')
38
+
39
  @client.tree.command()
40
  @app_commands.describe(prompt='Enter some text to chat with the bot! Like this: /falcon Hello, how are you?')
41
  async def falcon(interaction: discord.Interaction, prompt: str):
 
44
  await try_falcon(interaction, prompt)
45
  except Exception as e:
46
  print(f"Error: {e}")
47
+
48
  @client.event
49
  async def on_message(message):
50
  """Checks channel and continues Falcon conversation if it's the right Discord Thread"""
 
53
  await message.remove_reaction('πŸ”', client.user) # test=πŸ” hf=πŸ”
54
  except Exception as e:
55
  print(f"Error: {e}")
56
+
57
  @client.tree.command()
58
  @app_commands.describe(prompt='Enter a prompt to generate an image! Can generate realistic text, too!')
59
  async def deepfloydif(interaction: discord.Interaction, prompt: str):
 
63
 
64
  except Exception as e:
65
  print(f"Error: {e}")
66
+
67
  @client.event
68
  async def on_reaction_add(reaction, user):
69
  """Checks for a reaction in order to call dfif2"""
 
72
 
73
  except Exception as e:
74
  print(f"Error: {e} (known error, does not cause issues, low priority)")
75
+
76
  """This allows us to run the Discord bot in a Python thread"""
 
77
  def run_bot():
78
  client.run(DISCORD_TOKEN)
79
  threading.Thread(target=run_bot).start()