Giter Club home page Giter Club logo

Comments (3)

Gorialis avatar Gorialis commented on August 17, 2024

If this fixes itself when you do jsk reload jishaku, it is almost certain that jishaku.flags is evaluating before you set your environment variables, for whatever reason (do you use jishaku as a module?).

In such a case, the solution is just to make sure the environment variables are set before jishaku loads. Ideally, I would recommend that you ensure this outside of Python.

The method to do this varies depending on your deployment: if you use systemd, you can do this in your service file; if you use Docker, you can pass it when you start the container up; if you use docker-compose, you could add it to your compose file; if you use Kubernetes, then you could define it within your deployment manifest; if you don't do any of these and just run directly, then maybe you could create a bootstrap script, or add it to your ~/.bash_profile, or maybe your screen or tmux settings if you use either of those.

Ultimately, the way to solve this is going to depend on your own environment. I would like a better way to specify configuration preferences for jishaku in code for other reasons, but I've mostly been waiting on discord.py to figure out a way to establish this kind of infrastructure, because any attempt at my own solution would risk unsimplifying the loading routine from the current 'one line philosophy'.

Since there is no such infrastructure as of current, jishaku uses environment variables because it's an easily accessible and user-modifiable key-value mapping that I can guarantee is present in any system Python runs on.

There are caveats to this approach, being the order of operation (like seen here), and less granularity on what data I can accept as an configuration flag (for instance, in lieu of the current JISHAKU_NO_UNDERSCORE, I originally wanted to have something along the lines of JISHAKU_REPL_PREFIX, but an empty string for setting no prefix ("") is indistinguishable from it being unset on many systems, in which case I would want the default _ prefix - a problem that would be sidestepped with a Pythonic configuration interface, since I can tell the difference).

from jishaku.

BobDotCom avatar BobDotCom commented on August 17, 2024

After some quick tests, it appears that jsk reload jishaku does fix it, but that doesn't really make sense to me. The os.environ runs before the bot loads the extension (as shown in the code I posted), so I would only expect that it would load the environment variables would be set before. It works this way on my main bot, which has essentially the same code. While that bot runs on systemd, it is not having this problem so there is no reason to change it there yet. I did have an idea though, could bot variables be used, maybe as an alternative (with the env variables still working as well)? For example if bot.jishaku_no_underscore was a boolean, the True or False value would be able to toggle the option as well. If not set, they would default to the current defaults.

EDIT: After some more searching, I found the problem. I made an eval command, which is basically just a shortcut for jsk py, and for that I had used from jishaku.codeblocks import codeblock_converter at the beginning with my imports. This would explain why jishaku.flags evaluated before those variables had been set. Although, I still think bot variables would be a good idea.

from jishaku.

12944qwerty avatar 12944qwerty commented on August 17, 2024

Hi! I had the same problem. I have two bots. One bot works perfectly with jishaku. The other bot, unfortunately, has the same problem BobDotCom had. The environment variables aren't working. However, jsk reload jishaku didn't work either. It gave an error, but no traceback.

After running jsk, I found that the working bot has jishaku 1.19.1, dpy 1.3.4 and the other bot uses jishaku 1.20.0, dpy 1.5.1. Both use python 3.8.7. On startup, the second bot always returns an error saying that jishaku is already loaded. The first bot doesn't.

Jishaku doesn't load again in the second bot, uses newer version, and cannot load jishaku on startup. What is happening?? Should I downgrade dpy or jishaku? What could fix this? Please let me know, thanks!

EDIT: Upon further testing, I found that my cogs were being loaded twice, hence the error. My mistake, lol. I also was able to reload jishaku with this. Oops...

from jishaku.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.