Comments (3)
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.
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.
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)
- NotOwner not raised when user isnt owner HOT 2
- jsk ast fails with an error in certain cases HOT 2
- ability to add user who can run jishaku on the fly HOT 2
- Button disable
- Add Whois command HOT 2
- Unsupport discord.py v1.7.x HOT 1
- Python 3.9.13 not supported HOT 1
- Proper user configurable jsk py dict vars HOT 1
- change jishaku commands names HOT 1
- Jishaku version occasionally appears as vNone in selftest HOT 4
- Adding asqlite to options for the sql features HOT 3
- Unhandled code branch in `jishaku voice` command.
- Cog already loaded when loading it HOT 1
- I canβt use jishaku shell command HOT 2
- `jishaku timeit` raises an AttributeError upon use. HOT 1
- Tracking: need for a new release
- KeyError on Python version 3.11.0 HOT 3
- AttributeError: 'Context' object has no attribute 'add_reaction' HOT 2
- Question about next possible release to pypi HOT 2
- Convert message links to Message objects in REPLs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jishaku.