#import miruClient

1 messages · Page 1 of 1 (latest)

lyric mural
#

Hello everyone, I recently updated to the latest version of hikari-miru. I am using Miru, Hikari, and Lightbulb.

Miru now requires that I create a miru.Client to control my Modals and buttons, according to documentation found here: https://miru.hypergonial.com/guides/migrating_from_v3/

I have my commands split across multiple files. Within those files, I also take care of creating views, modals, etc.

When attempting to import my miru.Client into any file, my Lightbulb extensions stop working completely. When adding the import, I get this error:

Exception has occurred: ExtensionMissingLoad
Extension 'Editors.Editor' is missing a load function
File "iHidThisPath\main.py", line 12, in <module>
bot.load_extensions("Editors.Editor", "Teams.Team", "Clients.Client")
File "iHidThisPath\Editor.py", line 12, in <module>
from main import miruClient
File "iHidThisPath\main.py", line 12, in <module>
bot.load_extensions("Editors.Editor", "Teams.Team", "Clients.Client")
lightbulb.errors.ExtensionMissingLoad: Extension 'Editors.Editor' is missing a load function

I have load and unload functions written. Upon removing my imports, my code runs just fine (of course without modal/button functionality). I would sometimes get the following error, indicating a circular import:

Exception has occurred: ImportError
cannot import name 'miruClient' from partially initialized module 'MIRU_Control' (most likely due to a circular import) (iHidThisPath\MIRU_Control.py)

Though, chatGPT and I have doubled checked that there are no circular imports that I am causing. I would really like to avoid restructuring all of my code. If there is no proper solution to this, I'd probably revert to an older version of Miru. Thank you.

PS: I am willing to give more information if needed.

Learn what changed in v4 and how to migrate your bot from v3!

stone apex
#

And it helps if you show code

lyric mural
lyric mural
stone apex
lyric mural
#

Editor.py

# imports
import hikari as hk
import lightbulb as lb
import json
import miru

# importing stuff from files
from DB_Control import *
from helpers import *
from Clients import Client
from main import GUILD_ID, bot    # TEST THIS EXTENSIVELY

# lightbulb plugin creation
plugin = lb.Plugin("Editor")

class Editor():
    def __init__():
    ... (# a simple class for controlling backend operations like reading and writing to files)

# a command family called editor and its sub commands
@plugin.command
@lb.command("editor", "editor config")
@lb.implements(lb.SlashCommandGroup)
async def editor():
    pass
...

class ConfigModal(miru.Modal):
    email = miru.TextInput(label="Email Address", required=True, placeholder="[email protected]")
    phone = miru.TextInput(label="Phone Number", required=True, placeholder="0000000000")
    paymentPlatform = miru.TextInput(label="Payment Platform", required=True, placeholder="Paypal / Cashapp / Venmo")
    paymentHandle = miru.TextInput(label="Payment Handle (username on platform)", required=True, placeholder="@example / $example")
    async def callback(self, context:miru.ModalContext):
        editorObject = Editor(context.author.id)
        editorObject.email = self.email.value
        editorObject.phone = self.phone.value

        editorObject.exportConfig()
        
        await context.respond("Your config has been updated. Thank you.", flags=hk.MessageFlag.EPHEMERAL)

def load(bot):
    bot.add_plugin(plugin)
    
def unload(bot):
    bot.remove_plugin(plugin)

MIRU_Control.py was made to trouble shoot, looked something like this:

import hikari as hk
import lightbulb as lb
from main import bot

miruClient = miru.Client(bot)

def getMiruClient():
     return miruClient
#

I simplified a lot of code, down to mainly a skeleton

#

If you don't have an outright solution, no worries, I can revert to a previous version

#

My largest issue is using lightulb extensions alongside Miru's new client system

karmic cliff
#

oh dear

#

and as Jax has said, chatgpt is a terrible way to solve coding problems

lyric mural
lyric mural
#

have you had a case where it has been really bad at doing something even so simple

stone apex
#

Most of these simple things can be done correctly by an IDE, linter, and/or formatter

#

ChatGPT is just merging articles and other scarce training data