[main] bringing back dfif stuff
Browse files
app.py
CHANGED
|
@@ -30,8 +30,8 @@ DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
|
| 30 |
|
| 31 |
|
| 32 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 33 |
-
# This structure allows commands to work instantly (instead of needing to sync global commands for up to an hour)
|
| 34 |
class MyClient(discord.Client):
|
|
|
|
| 35 |
def __init__(self, *, intents: discord.Intents):
|
| 36 |
super().__init__(intents=intents)
|
| 37 |
self.tree = app_commands.CommandTree(self)
|
|
@@ -41,8 +41,7 @@ class MyClient(discord.Client):
|
|
| 41 |
self.tree.copy_global_to(guild=MY_GUILD)
|
| 42 |
await self.tree.sync(guild=MY_GUILD)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
client = MyClient(intents=intents)
|
| 46 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 47 |
@client.event
|
| 48 |
async def on_ready():
|
|
@@ -53,6 +52,7 @@ async def on_ready():
|
|
| 53 |
@app_commands.describe(
|
| 54 |
prompt='Enter some text to chat with the bot! Like this: /falcon Hello, how are you?')
|
| 55 |
async def falcon(interaction: discord.Interaction, prompt: str):
|
|
|
|
| 56 |
try:
|
| 57 |
await try_falcon(interaction, prompt)
|
| 58 |
|
|
@@ -61,6 +61,7 @@ async def falcon(interaction: discord.Interaction, prompt: str):
|
|
| 61 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 62 |
@client.event
|
| 63 |
async def on_message(message):
|
|
|
|
| 64 |
try:
|
| 65 |
await continue_falcon(message)
|
| 66 |
await message.remove_reaction('π', client.user) # test=π hf=π
|
|
@@ -68,7 +69,26 @@ async def on_message(message):
|
|
| 68 |
except Exception as e:
|
| 69 |
print(f"Error: {e}")
|
| 70 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 73 |
|
| 74 |
def run_bot():
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
| 33 |
class MyClient(discord.Client):
|
| 34 |
+
"""This structure allows commands to work instantly (instead of needing to sync global commands for up to an hour)"""
|
| 35 |
def __init__(self, *, intents: discord.Intents):
|
| 36 |
super().__init__(intents=intents)
|
| 37 |
self.tree = app_commands.CommandTree(self)
|
|
|
|
| 41 |
self.tree.copy_global_to(guild=MY_GUILD)
|
| 42 |
await self.tree.sync(guild=MY_GUILD)
|
| 43 |
|
| 44 |
+
client = MyClient(intents=discord.Intents.default())
|
|
|
|
| 45 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 46 |
@client.event
|
| 47 |
async def on_ready():
|
|
|
|
| 52 |
@app_commands.describe(
|
| 53 |
prompt='Enter some text to chat with the bot! Like this: /falcon Hello, how are you?')
|
| 54 |
async def falcon(interaction: discord.Interaction, prompt: str):
|
| 55 |
+
"""Command that begins a new conversation with Falcon"""
|
| 56 |
try:
|
| 57 |
await try_falcon(interaction, prompt)
|
| 58 |
|
|
|
|
| 61 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 62 |
@client.event
|
| 63 |
async def on_message(message):
|
| 64 |
+
"""Checks channel and continues Falcon conversation if it's the right Discord Thread"""
|
| 65 |
try:
|
| 66 |
await continue_falcon(message)
|
| 67 |
await message.remove_reaction('π', client.user) # test=π hf=π
|
|
|
|
| 69 |
except Exception as e:
|
| 70 |
print(f"Error: {e}")
|
| 71 |
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 72 |
+
@client.tree.command()
|
| 73 |
+
@app_commands.describe(
|
| 74 |
+
prompt='Enter a prompt to generate an image! Can generate realistic text, too!')
|
| 75 |
+
async def deepfloydif(interaction: discord.Interaction, prompt: str):
|
| 76 |
+
"""DeepfloydIF stage 1 generation"""
|
| 77 |
+
try:
|
| 78 |
+
await deepfloydif_stage_1(interaction, prompt, client)
|
| 79 |
+
|
| 80 |
+
except Exception as e:
|
| 81 |
+
print(f"Error: {e}")
|
| 82 |
+
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 83 |
+
@client.event
|
| 84 |
+
async def on_reaction_add(reaction, user):
|
| 85 |
+
"""Checks for a reaction in order to call dfif2"""
|
| 86 |
+
try:
|
| 87 |
+
await deepfloydif_stage_2_react_check(reaction, user)
|
| 88 |
+
|
| 89 |
+
except Exception as e:
|
| 90 |
+
print(f"Error: {e} (known error, does not cause issues, low priority)")
|
| 91 |
+
#-------------------------------------------------------------------------------------------------------------------------------------
|
| 92 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 93 |
|
| 94 |
def run_bot():
|