lunarflu HF Staff commited on
Commit
ebe5be1
·
1 Parent(s): 54b8e0e

[main] syncing stage2 test changes

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -19,9 +19,9 @@ from falcon import try_falcon
19
  from falcon import continue_falcon
20
 
21
  import deepfloydif
22
- from deepfloydif import try_deepfloydif
23
-
24
-
25
  #-------------------------------------------------------------------------------------------------------------------------------------
26
  MY_GUILD = discord.Object(id=1077674588122648679) # HF = 879548962464493619, test = 1077674588122648679
27
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
@@ -33,17 +33,18 @@ DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
33
  DEEPFLOYD_CHANNEL_ID = 1121834257959092234 # 1121834257959092234 = test
34
  #df = Client("huggingface-projects/IF", HF_TOKEN)
35
  #-------------------------------------------------------------------------------------------------------------------------------------
36
- # This structure allows commands to work instantly (instead of needing to sync global commands for up to an hour)
37
  class MyClient(discord.Client):
 
38
  def __init__(self, *, intents: discord.Intents):
39
  super().__init__(intents=intents)
40
  self.tree = app_commands.CommandTree(self)
 
41
  async def setup_hook(self):
42
  # This copies the global commands over to our guild
43
  self.tree.copy_global_to(guild=MY_GUILD)
44
  await self.tree.sync(guild=MY_GUILD)
45
- intents = discord.Intents.all()
46
- client = MyClient(intents=intents)
47
  #-------------------------------------------------------------------------------------------------------------------------------------
48
  @client.event
49
  async def on_ready():
@@ -72,12 +73,22 @@ async def on_message(message):
72
  prompt='Enter a prompt to generate an image! Can generate realistic text, too!')
73
  async def deepfloydif(interaction: discord.Interaction, prompt: str):
74
  try:
75
- await try_deepfloydif(interaction, prompt, client)
76
 
77
 
78
  except Exception as e:
79
  print(f"Error: {e}")
80
- #-------------------------------------------------------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
81
  #-------------------------------------------------------------------------------------------------------------------------------------
82
  # running in thread
83
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
 
19
  from falcon import continue_falcon
20
 
21
  import deepfloydif
22
+ from deepfloydif import deepfloydif_stage_1
23
+ from deepfloydif import deepfloydif_stage_2
24
+ from deepfloydif import deepfloydif_stage_2_react_check
25
  #-------------------------------------------------------------------------------------------------------------------------------------
26
  MY_GUILD = discord.Object(id=1077674588122648679) # HF = 879548962464493619, test = 1077674588122648679
27
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
 
33
  DEEPFLOYD_CHANNEL_ID = 1121834257959092234 # 1121834257959092234 = test
34
  #df = Client("huggingface-projects/IF", HF_TOKEN)
35
  #-------------------------------------------------------------------------------------------------------------------------------------
 
36
  class MyClient(discord.Client):
37
+ """This structure allows commands to work instantly (instead of needing to sync global commands for up to an hour)"""
38
  def __init__(self, *, intents: discord.Intents):
39
  super().__init__(intents=intents)
40
  self.tree = app_commands.CommandTree(self)
41
+
42
  async def setup_hook(self):
43
  # This copies the global commands over to our guild
44
  self.tree.copy_global_to(guild=MY_GUILD)
45
  await self.tree.sync(guild=MY_GUILD)
46
+
47
+ client = MyClient(intents=discord.Intents.default())
48
  #-------------------------------------------------------------------------------------------------------------------------------------
49
  @client.event
50
  async def on_ready():
 
73
  prompt='Enter a prompt to generate an image! Can generate realistic text, too!')
74
  async def deepfloydif(interaction: discord.Interaction, prompt: str):
75
  try:
76
+ await deepfloydif_stage_1(interaction, prompt, client)
77
 
78
 
79
  except Exception as e:
80
  print(f"Error: {e}")
81
+ #-------------------------------------------------------------------------------------------------------------------------------------
82
+ @client.event
83
+ async def on_reaction_add(reaction, user):
84
+ """Checks for a reaction in order to call dfif2"""
85
+ try:
86
+ await deepfloydif_stage_2_react_check(reaction, user)
87
+
88
+
89
+
90
+ except Exception as e:
91
+ print(f"Error: {e} (known error, does not cause issues, low priority)")
92
  #-------------------------------------------------------------------------------------------------------------------------------------
93
  # running in thread
94
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)