Gorialis / jishaku

A debugging and testing cog for discord.py rewrite bots.
https://jishaku.readthedocs.io/en/latest/
MIT License
539 stars 176 forks source link

Proper user configurable jsk py dict vars #199

Open danrfq opened 1 year ago

danrfq commented 1 year ago

The Problem

In the jishaku python's command, there's some aliases we can use to shorten our evaluation code, such as me for Context.me, get for discord.utils.get, etc.

I wonder if configurable aliases like those is possible to implement.

The Ideal Solution

My idea is to add more aliases to jishaku. Something like this design is what I'm thinking of:

import jishaku, discord

jishaku.EvalAliases.add(
  [
    "Embed", discord.Embed,
    "ref", ctx.message.reference.resolved,
  ]
)

The Current Solution

Fork the repository and add the desired aliases manually into the get_var_dict_from_ctx function in repl_builtins.py file.

Summary

A feature that allows the user to configure or add jsk py aliases to use in the command.

I don't know if this feature is already possible to do or implemented, so I'm making an issue to make sure.

Gorialis commented 1 year ago

The problem with this implementation in particular is that it isn't reload-safe. Technically speaking jishaku.Flags isn't fully reload-safe either, but if you use the environment variables you can create persistent settings anyway.

The approaches to dynamic config like this I have in my head are:

Ultimately all of these approaches suck in some way that's blocked me from really doing this in the long run - better configuration is something heavily requested and I've wanted to add, but I need to think it over and try to minimize the footguns involved in implementing it.