lunarflu HF Staff commited on
Commit
fe5d109
Β·
1 Parent(s): d138499

[main] some docstrings

Browse files
Files changed (1) hide show
  1. app.py +6 -13
app.py CHANGED
@@ -25,16 +25,9 @@ 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)
28
-
29
-
30
-
31
-
32
-
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)
@@ -55,6 +48,7 @@ async def on_ready():
55
  @app_commands.describe(
56
  prompt='Enter some text to chat with the bot! Like this: /falcon Hello, how are you?')
57
  async def falcon(interaction: discord.Interaction, prompt: str):
 
58
  try:
59
  await try_falcon(interaction, prompt)
60
  except Exception as e:
@@ -62,9 +56,10 @@ async def falcon(interaction: discord.Interaction, prompt: str):
62
  #-------------------------------------------------------------------------------------------------------------------------------------
63
  @client.event
64
  async def on_message(message):
 
65
  try:
66
  await continue_falcon(message)
67
- #await message.remove_reaction('πŸ”', client.user) # test=πŸ” hf=πŸ”
68
  except Exception as e:
69
  print(f"Error: {e}")
70
  #-------------------------------------------------------------------------------------------------------------------------------------
@@ -72,10 +67,10 @@ async def on_message(message):
72
  @app_commands.describe(
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
  #-------------------------------------------------------------------------------------------------------------------------------------
@@ -85,12 +80,10 @@ async def on_reaction_add(reaction, user):
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)
95
  def run_bot():
96
  client.run(DISCORD_TOKEN)
 
25
  #-------------------------------------------------------------------------------------------------------------------------------------
26
  MY_GUILD = discord.Object(id=1077674588122648679) # HF = 879548962464493619, test = 1077674588122648679
27
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
 
 
 
 
 
 
 
28
  #-------------------------------------------------------------------------------------------------------------------------------------
29
  class MyClient(discord.Client):
30
+ """This structure allows slash commands to work instantly (instead of needing to sync global commands for up to an hour)"""
31
  def __init__(self, *, intents: discord.Intents):
32
  super().__init__(intents=intents)
33
  self.tree = app_commands.CommandTree(self)
 
48
  @app_commands.describe(
49
  prompt='Enter some text to chat with the bot! Like this: /falcon Hello, how are you?')
50
  async def falcon(interaction: discord.Interaction, prompt: str):
51
+ """Command that begins a new conversation with Falcon"""
52
  try:
53
  await try_falcon(interaction, prompt)
54
  except Exception as e:
 
56
  #-------------------------------------------------------------------------------------------------------------------------------------
57
  @client.event
58
  async def on_message(message):
59
+ """Checks channel and continues Falcon conversation if it's the right Discord Thread"""
60
  try:
61
  await continue_falcon(message)
62
+ await message.remove_reaction('πŸ”', client.user) # test=πŸ” hf=πŸ”
63
  except Exception as e:
64
  print(f"Error: {e}")
65
  #-------------------------------------------------------------------------------------------------------------------------------------
 
67
  @app_commands.describe(
68
  prompt='Enter a prompt to generate an image! Can generate realistic text, too!')
69
  async def deepfloydif(interaction: discord.Interaction, prompt: str):
70
+ """DeepfloydIF stage 1 generation"""
71
  try:
72
  await deepfloydif_stage_1(interaction, prompt, client)
73
 
 
74
  except Exception as e:
75
  print(f"Error: {e}")
76
  #-------------------------------------------------------------------------------------------------------------------------------------
 
80
  try:
81
  await deepfloydif_stage_2_react_check(reaction, user)
82
 
 
 
83
  except Exception as e:
84
  print(f"Error: {e} (known error, does not cause issues, low priority)")
85
  #-------------------------------------------------------------------------------------------------------------------------------------
86
+ """This allows us to run the Discord bot in a Python thread"""
87
  DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
88
  def run_bot():
89
  client.run(DISCORD_TOKEN)