#error [Daemon]: Server is now starting. Python 3.8.16 [Daemon]: Server is now running. :/home/container$ ${STARTUP_COMMAND} Traceback (most recent call last): File "main.py", line 22, in from discord import interaction ImportError: cannot import name 'interaction' from 'discord' (/home/container/.local/lib/python3.8/site-packages/discord/__init__.py) [Daemon]: Server is now offline. #code @bot.hybrid_command(name="imagine", description=current_language["imagine"]) @app_commands.choices(style=[ app_commands.Choice(name='Imagine V3', value='IMAGINE_V3'), app_commands.Choice(name='Imagine V4 Beta', value='IMAGINE_V4_Beta'), app_commands.Choice(name='Imagine V4 creative', value='V4_CREATIVE'), app_commands.Choice(name='Anime', value='ANIME_V2'), app_commands.Choice(name='Realistic', value='REALISTIC'), app_commands.Choice(name='Disney', value='DISNEY'), app_commands.Choice(name='Studio Ghibli', value='STUDIO_GHIBLI'), app_commands.Choice(name='Graffiti', value='GRAFFITI'), app_commands.Choice(name='Medieval', value='MEDIEVAL'), app_commands.Choice(name='Fantasy', value='FANTASY'), app_commands.Choice(name='Neon', value='NEON'), app_commands.Choice(name='Cyberpunk', value='CYBERPUNK'), app_commands.Choice(name='Landscape', value='LANDSCAPE'), app_commands.Choice(name='Japanese Art', value='JAPANESE_ART'), app_commands.Choice(name='Steampunk', value='STEAMPUNK'), app_commands.Choice(name='Sketch', value='SKETCH'), app_commands.Choice(name='Comic Book', value='COMIC_BOOK'), app_commands.Choice(name='Cosmic', value='COMIC_V2'), app_commands.Choice(name='Logo', value='LOGO'), app_commands.Choice(name='Pixel art', value='PIXEL_ART'), app_commands.Choice(name='Interior', value='INTERIOR'), app_commands.Choice(name='Mystical', value='MYSTICAL'), app_commands.Choice(name='Super realism', value='SURREALISM'), app_commands.Choice(name='Minecraft', value='MINECRAFT'), app_commands.Choice(name='Dystopian', value='DYSTOPIAN') ]) @app_commands.choices(ratio=[ app_commands.Choice(name='Square (1:1)', value='RATIO_1X1'), app_commands.Choice(name='Vertical (9:16)', value='RATIO_9X16'), app_commands.Choice(name='Horizontal (16:9)', value='RATIO_16X9'), app_commands.Choice(name='Standard (4:3)', value='RATIO_4X3'), app_commands.Choice(name='Classic (3:2)', value='RATIO_3X2') ]) @app_commands.choices(upscale=[ app_commands.Choice(name='Yea sure', value='True'), app_commands.Choice(name='No thanks', value='False') ]) class ImagineView(View): def __init__(self): super().__init__() self.regenerate_button = Button(style=discord.ButtonStyle.primary, label="Regenerate", custom_id="regenerate_button") @self.regenerate_button.callback async def on_regenerate_button(self, interaction: Interaction): # @regenerate_button.callback # async def on_regenerate_button(self, interaction: Interaction): await interaction.response.defer() prompt = interaction.message.embeds[0].fields[0].value style = interaction.message.embeds[0].fields[1].value ratio = interaction.message.embeds[0].fields[2].value negative = None if len(interaction.message.embeds[0].fields) > 3: negative = interaction.message.embeds[0].fields[3].value upscale = None if interaction.message.embeds[0].footer.text.startswith("⚠️ Upscaling"): upscale = "True" temp_message = await interaction.channel.send("https://giphy.com/gifs/awesome-circle-loading-WiIuC6fAOoXD2") imagefileobj = await generate_image(prompt, style, ratio, negative, upscale) file = discord.File(imagefileobj, filename=f"image.png") embed = Embed(color=0x141414) embed.set_author(name="Generated Image") embed.add_field(name="Prompt", value=f"{prompt}", inline=False) embed.add_field(name="Style", value=f"{style}", inline=True) embed.add_field(name="Ratio", value=f"{ratio}", inline=True) embed.set_image(url="attachment://image.png") if upscale == "True": embed.set_footer(text="⚠️ Upscaling was added while keeping the user who uses Discord Web in mind. The difference between a proper image and an upscaled image is clear when using the command from the browser.") else: embed.set_footer(text="To create more images use /imagine") if negative is not None: embed.add_field(name="Negative", value=f"{negative}", inline=False) await interaction.edit_original_message(content=f"Generated image for {interaction.user.mention}", file=file, embed=embed) await temp_message.delete() @bot.hybrid_command(name="imagine", description=current_language["imagine"]) async def imagine(ctx, prompt: str, style: str, ratio: str, negative: str = None, upscale: str = None): if upscale is not None and upscale == 'True': upscale_status = True else: upscale_status = False temp_message = await ctx.send("https://giphy.com/gifs/awesome-circle-loading-WiIuC6fAOoXD2") is_nsfw = await detectnsfw(prompt) blacklisted = any(words in prompt.lower() for words in blacklisted_words) if is_nsfw or blacklisted: await temp_message.edit(content="⚠️ Your prompt potentially contains sensitive or inappropriate content. Please revise your prompt.") return imagefileobj = await generate_image(prompt, style, ratio, negative, upscale_status) file = discord.File(imagefileobj, filename=f"image.png") embed = Embed(color=0x141414) embed.set_author(name="Generated Image") embed.add_field(name="Prompt", value=f"{prompt}", inline=False) embed.add_field(name="Style", value=f"{style}", inline=True) embed.add_field(name="Ratio", value=f"{ratio}", inline=True) embed.set_image(url="attachment://image.png") if upscale_status: embed.set_footer(text="⚠️ Upscaling was added while keeping the user who uses Discord Web in mind. The difference between a proper image and an upscaled image is clear when using the command from the browser.") else: embed.set_footer(text="To create more images use /imagine") if negative is not None: embed.add_field(name="Negative", value=f"{negative}", inline=False) view = ImagineView() view.add_item(view.regenerate_button) await temp_message.delete() await ctx.send(content=f"Generated image for {ctx.author.mention}", file=file, embed=embed, view=view) await temp_message.edit(content=f"{current_language['imagine_msg']}")