Code Monkey home page Code Monkey logo

goldy-bot-framework's People

Contributors

thegoldenpro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

goldy-bot-framework's Issues

Remove "normal cmd only" from commands.

As the title says. Let's remove this option for commands.

With slash commands becoming more and more popular I don't see why you would ever want to force a command to be prefix only. Even if you had a reason it would cause confusion, it would throw off the consistency of slash commands within goldy bot and consistency is one of our goals.

So from this every command WILL be a slash command no matter what and by default a prefix command too but you can disable the prefix command with the slash_cmd_only parameter just like usual. It's only the normal_cmd_only parameter that is disappearing.

Better Embed() interface.

I need something that will prevent the code at embed["description"] =:

embed["description"] = embed["description"].format() just seems extremely weird. Perhaps we should have a method like .format_description() on the embed that does exactly what .format() does but without doing the weird piece of code where you format a description then add that newly formatted description to the embed's description again.

class Goldy(GoldyBot.Extension):
    def __init__(self):
        super().__init__()

        self.goldy_embed = GoldyBot.Embed(
            title = "๐Ÿ’› Goldy Bot - Stats",
            description = """
            ***__Version:__*
            โ€ข GoldyBot: ``{version}``
            โ€ข Nextcore: ``{nc_version}``
            โ€ข Python: ``{py_version}``

            *__Resources:__*
            โ€ข Ping: ``{ping}``
            โ€ข OS: ``{os}``
            โ€ข CPU: ``{cpu}%``
            โ€ข RAM: ``{ram} GB``
            โ€ข DISK: ``{disk} MB/s``

            *Developed with {heart} By <@332592361307897856>***
            """,
            colour = Colours.YELLOW,
            thumbnail = GoldyBot.EmbedImage(self.goldy.bot_user.avatar_url)
        )
    
    @GoldyBot.command(name="goldy", description="๐Ÿ’› Shows you stats about the current Goldy Bot framework instance.")
    async def goldy_cmd(self, platter: GoldyBot.GoldPlatter):
        embed = self.goldy_embed.copy()

        embed["description"] = embed["description"].format(
            version = GoldyBot.info.VERSION,
            nc_version = nextcore.__version__,
            py_version = self.goldy.system.python_version,
            ping = (lambda x: "(Not Available)" if x is None else f"{round(x * 1000, 2)}ms")(self.goldy.latency),
            os = self.goldy.system.os,
            cpu = self.goldy.system.cpu,
            ram = self.goldy.system.ram,
            disk = self.goldy.system.disk,

            heart = "๐Ÿค"
        )

        await platter.send_message(embeds=[embed], reply=True)

dms only slash commands

  • The ability to flag commands as dm only commands.
  • When there is Perms.BOT_DEV in required_roles only allow that command in bot developer's dms.

Remove ding on exit.

The only thing I use pygame for is its sound mixer module so I can play the ding sound effect mp3 as other libraries were fussy about playing .mp3 files but now I've come to notice that this was one of my worse discussions with Goldy Bot. It's overkill and unstable as fuck (breaks often). It's now broken my git actions because of an installation error, it's time for pygame to go in Goldy Bot v5.0dev12.

Fix weird on_message exception.

I'm getting some weird tracebacks on the alpha production bot that show the content is empty. We need to ignore those message events. I'll send the traceback here soon.

Rename GoldenPlatter.

As the title says, let's rename this back to GoldPlatter, it looks much better and is easier to type lmao.

Add defer to nextcore utils.

As the title says, we need to add defer to the framework so we can send a wait request to discord for interactions that will take a while to reply to.

Hide prefix commands

Commands now have a new attribute called is_hidden.

Let's add to the command loader for prefix commands and to not respond to the command at all if the command is hidden and the member has no permission.

STOP WAITING FOR HELLO!!!

bro won't stop reconnecting, I've been having this bug in v5.0dev5 for a very long while.

Before I blame nextcore for this let's recreate this outside of goldy bot:

  • Recreate outside of Goldy Bot.

image

Command system rewrite

Yes, I'm insane. As the title says, I'll be rewriting hundreds of lines from the command system.

Commands will have a complete restructure as I'm not happy with the current state of things.

Extension reloading is broken.

Ordinary extensions seem to be fine but when you reload a package extension (package module) it tends to only reload init.py and not the other modules under and sometimes it doesn't reload anything; very confusing behaviour, this is the case with mal_cord.

BIG database bug in dev7

There's currently a bug in dev7's .edit() database method.

It's happening when find_one returns none here: https://github.com/Goldy-Bot/Goldy-Bot-V5/blob/212f0a1ffe0a532c7bdc060a11b3ace9237a887c/GoldyBot/goldy/database/databases/__init__.py#L30-L31

Traceback

[DEBUG] (Goldy Bot) - [Database] [goldy_main] Found '{'_id': '1016435541199294484'}' in 'guild_configs.'
[DEBUG] (Goldy Bot) - [SlashCommand] [timestamp] Attempting to phrase invoke data into parameters...
[DEBUG] (Goldy Bot) - [SlashCommand] [timestamp] Attempting to invoke command...
[DEBUG] (Goldy Bot) - [PermissionSystem] This command has no required perms. Your free! ๐Ÿ”“[INFO] (Goldy Bot) - [SlashCommand] [timestamp] Command invoked by 'emretech#0'.
[DEBUG] (Goldy Bot) - [SlashCommand] [timestamp] Calling sub command...
[DEBUG] (Goldy Bot) - [SlashCommand] [set_defaults] Attempting to phrase invoke data into parameters...
[DEBUG] (Goldy Bot) - [SlashCommand] [set_defaults] Found arg 'America/Los_Angeles'.
[DEBUG] (Goldy Bot) - [SlashCommand] [set_defaults] Found arg '0'.
[DEBUG] (Goldy Bot) - [SlashCommand] [set_defaults] Got args --> {'timezone': 'America/Los_Angeles', 'date_format': 0}
[DEBUG] (Goldy Bot) - [SlashCommand] [set_defaults] Attempting to invoke command...
[DEBUG] (Goldy Bot) - [PermissionSystem] This command has no required perms. Your free! ๐Ÿ”“[INFO] (Goldy Bot) - [SlashCommand] [set_defaults] Command invoked by 'emretech#0'.
[INFO] (Goldy Bot) - [Member] [emretech] [Database Wrapper] Pulling updated member data from database...
[DEBUG] (Goldy Bot) - [Member] [emretech] [Database Wrapper] Finding member's data collections...
[DEBUG] (Goldy Bot) - [Member] [emretech] [Database Wrapper] Found member's global data.
[DEBUG] (Goldy Bot) - [Member] [emretech] [Database Wrapper] Found member's guild data for 'nextcore_orx_Server'.
[INFO] (Goldy Bot) - [Member] [emretech] [Database Wrapper] Pushing data to the database...
[DEBUG] (Goldy Bot) - [Database] [goldy_member_data] '{'_id': '1'}' was not found in 'guild_configs.'
[ERROR] (Goldy Bot) - [SlashCommand] [set_defaults] Error occurred in the command 'set_defaults' executed by 'emretech#0'!
Exception occured in event handler
Traceback (most recent call last):
  File "/app/GoldyBot/goldy/commands/slash_command.py", line 77, in invoke
    return_value = await super().invoke(
  File "/app/GoldyBot/goldy/commands/command.py", line 179, in invoke
    return await lambda_func()
  File "/app/GoldyBot/internal_extensions/timestamps.py", line 172, in set_defaults
    await member_data.push(DatabaseEnums.MEMBER_GLOBAL_DATA, {"timezone": timezone, "datetime_formats": datetime_formats})
  File "/app/GoldyBot/goldy/database/wrappers/member.py", line 32, in push
    await database.edit(self.member.id, {"_id": doc_id}, data, overwrite = False)
  File "/app/GoldyBot/goldy/database/databases/__init__.py", line 31, in edit
    new_data = utils.update_dict(document_data, data) # Override the document's data with the new data.
  File "/app/GoldyBot/utils/_dict.py", line 7, in update_dict
    c = d1.copy()
AttributeError: 'NoneType' object has no attribute 'copy'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/nextcore/common/dispatcher.py", line 464, in _run_event_handler
    await maybe_coro(callback, *args)
  File "/usr/local/lib/python3.10/site-packages/nextcore/common/maybe_coro.py", line 69, in maybe_coro
    return await result
  File "/app/GoldyBot/goldy/commands/listener.py", line 75, in on_interaction
    await command[1].invoke(
  File "/app/GoldyBot/goldy/commands/slash_command.py", line 88, in invoke
    raise front_end_errors.UnknownError(platter, e, self.logger)
  File "/app/GoldyBot/goldy/nextcore_utils/front_end_errors.py", line 162, in __init__
    raise error
  File "/app/GoldyBot/goldy/commands/slash_command.py", line 85, in invoke
    await self.__invoke_sub_command(data, platter)
  File "/app/GoldyBot/goldy/commands/slash_command.py", line 150, in __invoke_sub_command
    await command.invoke(platter)
  File "/app/GoldyBot/goldy/commands/slash_command.py", line 88, in invoke
    raise front_end_errors.UnknownError(platter, e, self.logger)
GoldyBot.goldy.nextcore_utils.front_end_errors.UnknownError: Error occurred in the command 'set_defaults' executed by 'emretech#0'!
[DEBUG] (Goldy Bot) - [SlashCommand] [set_defaults] Interaction callback message was sent.

Remove silver platter

As the title says, remove silver platter from recipes and replace it with the golden platter.

OMG we need autocomplete, it's amazing.

As the title says we need to integrate autocomplete into the framework. I want to be able to use this in the timestamp command so I can suggest the use of shortcut aliases options like today and now in the date and time parameters.

This feature will bring a lot of potential to goldy bot extensions.

This is a good example video of how discord.py does it: https://youtu.be/zSzFHxOkCfo

Extension system rewrite

Okay so 3 days ago I learnt this now needs some rewriting and reorganising.

From now on extensions will always be loaded, there's no option to unload them from memory. However what you can do is disable them, which will disable every single command in that extension.

We should add a new front end exception to the command loader that raises when the command is disabled, notifying the user.

Utilize goldy bot extension's pyproject.toml.

Sorry, I'm too lazy to explain right now.

  • Somehow grab the required dependencies and install them but NOT during runtime.
  • Phrase metadata (such as description, author, tags and version)
  • Install extension's dependencies if they are missing from the environment.

Move all bot developer only commands.

As the title says, I would like to move all Dev only commands like /extensions to a one admin command that can only be used by the bot Dev and registered admins in DMs.

BUG: Goldy Bot still crashes when "raise_on_load_error" is set to false.

When raise_on_load_error is set to false goldy bot is meant to ignore the extension and continue loading other stuff but when the user forgets the load() function the command in the extension loads but the actual extension doesn't so it leads to this error below:

[DEBUG] (Goldy Bot) - [Token] Searching current working directory for .env file if exists...
[DEBUG] (Goldy Bot) - [Token] Grabbing discord token...
[DEBUG] (Goldy Bot) - [Token] Grabbing database token...
[DEBUG] (Goldy Bot) - [Token] Done
[INFO] (Goldy Bot) - [Database] AsyncIOMotorClient Connected!
[DEBUG] (Goldy Bot) - [JSONConfig] Opening config file at './goldy.json'...
[DEBUG] (Goldy Bot) - [JSONConfig] Phrasing json in config to dict...
[DEBUG] (Goldy Bot) - [JSONConfig] Done!
[DEBUG] (Goldy Bot) - [Goldy] Nextcore shard manager connecting...
[DEBUG] (Goldy Bot) - [Goldy] Application data requested!
[DEBUG] (Goldy Bot) - [Database] [goldy_main] Found '{'_id': '863416692083916820'}' in 'guild_configs.'
[DEBUG] (Goldy Bot) - [Database] [goldy_main] Edited '{'_id': '863416692083916820'}' into '{'_id': '863416692083916820', 'code_name': 'test_server', 'prefix': '!', 'roles': {}, 'channels': {}, 'allowed_extensions': [], 'disallowed_extensions': [], 'hidden_extensions': []}.'
[INFO] (Goldy Bot) - [ExtensionLoader] Found extension folder at 'D:\test_goldybot\extensions'.
[DEBUG] (Goldy Bot) - [ExtensionLoader] Found the module 'test.py' in extensions.
[WARNING] (Goldy Bot) - [ExtensionLoader] Couldn't find extension path at 'D:\test_goldybot\env\Lib\site-packages\GoldyBot\internal_extensions'!
[DEBUG] (Goldy Bot) - [Command] [hello] Command initialized!
[DEBUG] (Goldy Bot) - [ExtensionLoader] Calling the 'load()' function in the extension at D:\test_goldybot\extensions\test.py...
[ERROR] (Goldy Bot) - [ExtensionLoader] We encountered an error while trying to load extension at 'D:\test_goldybot\extensions\test.py'! You most likely forgot the 'load()' function.
ERROR --> module 'D:\test_goldybot\extensions\test' has no attribute 'load'
Traceback (most recent call last):
  File "run.py", line 5, in <module>
    goldy.start() # Launch goldy bot.
  File "D:\test_goldybot\env\lib\site-packages\GoldyBot\goldy\__init__.py", line 96, in start
    self.async_loop.run_until_complete(
  File "C:\Users\jassi\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "D:\test_goldybot\env\lib\site-packages\GoldyBot\goldy\__init__.py", line 127, in __start_async
    await self.setup()
  File "D:\test_goldybot\env\lib\site-packages\GoldyBot\goldy\__init__.py", line 158, in setup
    await self.command_loader.load()
  File "D:\test_goldybot\env\lib\site-packages\GoldyBot\goldy\commands\loader.py", line 38, in load
    if command.extension.is_ignored == False:
  File "D:\test_goldybot\env\lib\site-packages\GoldyBot\goldy\commands\__init__.py", line 105, in extension
    return utils.cache_lookup(self.extension_name, extensions_cache)[1]
TypeError: 'NoneType' object is not subscriptable

Because the extension is not loaded when the command is loaded it cannot find the extension leading to this traceback.

Make the goldy bot framework actually a framework ๐Ÿ˜ญ

  • Remove git submodule internal extensions
  • Add functionality for goldy bot to git clone extensions specified in goldy.json
  • update extension's template to include framework version inference. (idk how we'll implement this)
  • make timestamps.py an external extension.

BUG in new command system!

I found a BUG with the new command system.

This happens after trying to run the /goldy slash command. (it's triggering a prefix command ๐Ÿค”)

[DEBUG] (Goldy Bot) - [Database] [goldy_main] Found '{'_id': '863416692083916820'}' in 'guild_configs.'
[DEBUG] (Goldy Bot) - [PrefixCommand] [goldy] Attempting to phrase invoke data into parameters...
Exception occured in event handler
Traceback (most recent call last):
  File "/home/goldy/Documents/Projects/Python/.goldy_bot/Goldy-Bot-V5/env/lib/python3.8/site-packages/nextcore/common/dispatcher.py", line 464, in _run_event_handler
    await maybe_coro(callback, *args)
  File "/home/goldy/Documents/Projects/Python/.goldy_bot/Goldy-Bot-V5/env/lib/python3.8/site-packages/nextcore/common/maybe_coro.py", line 69, in maybe_coro
    return await result
  File "../GoldyBot/goldy/commands/listener.py", line 68, in on_interaction
    await command[1].invoke(
  File "../GoldyBot/goldy/commands/prefix_command.py", line 61, in invoke
    params = self.__invoke_data_to_params(data)
  File "../GoldyBot/goldy/commands/prefix_command.py", line 95, in __invoke_data_to_params
    for arg in data["content"].split(" ")[1:]:
KeyError: 'content'

For some reason, it triggers the prefix command instead of the slash command.

Further logs show that the prefix command is being registered with the slash command id. This shouldn't be possible.

[DEBUG] (Goldy Bot) - [CommandLoader] Slash command 'goldy' payload grabbed.
[DEBUG] (Goldy Bot) - [CommandLoader] Command 'goldy' loaded.
[DEBUG] (Goldy Bot) - [PrefixCommand] [goldy] 'goldy' has been registered with id 'goldy'!
[DEBUG] (Goldy Bot) - [CommandLoader] Command 'goldy' loaded.
[DEBUG] (Goldy Bot) - [CommandLoader] Slash command 'timestamp' payload grabbed.
[DEBUG] (Goldy Bot) - [CommandLoader] Command 'timestamp' loaded.
[DEBUG] (Goldy Bot) - [PrefixCommand] [timestamp] 'timestamp' has been registered with id 'timestamp'!
[DEBUG] (Goldy Bot) - [CommandLoader] Command 'timestamp' loaded.
[DEBUG] (Goldy Bot) - [CommandLoader] Slash command 'extensions' payload grabbed.
[DEBUG] (Goldy Bot) - [CommandLoader] Command 'extensions' loaded.
[DEBUG] (Goldy Bot) - [PrefixCommand] [extensions] 'extensions' has been registered with id 'extensions'!
[DEBUG] (Goldy Bot) - [CommandLoader] Command 'extensions' loaded.
[INFO] (Goldy Bot) - [Goldy] Nextcore shards are connected and READY!
[DEBUG] (Goldy Bot) - [SlashCommand] [test] 'test' has been registered with id '1126485978496905296'!
[DEBUG] (Goldy Bot) - [SlashCommand] [setup_tree] 'setup_tree' has been registered with id '1126485978496905297'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [hello] 'hello' has been registered with id '1126485978496905298'!
[DEBUG] (Goldy Bot) - [SlashCommand] [bear] 'bear' has been registered with id '1126485978496905299'!
[DEBUG] (Goldy Bot) - [SlashCommand] [nuke] 'nuke' has been registered with id '1126485979012800532'!
[DEBUG] (Goldy Bot) - [SlashCommand] [game] 'game' has been registered with id '1126485979012800534'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [hi] 'hi' has been registered with id '1126485979012800535'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [test_database] 'test_database' has been registered with id '1126485979012800536'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [test_extension] 'test_extension' has been registered with id '1126485979012800537'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [test_args] 'test_args' has been registered with id '1126485979012800539'!
[DEBUG] (Goldy Bot) - [SlashCommand] [test_mention_striper_role] 'test_mention_striper_role' has been registered with id '1126485979486752889'!
[DEBUG] (Goldy Bot) - [SlashCommand] [test_mention_striper_channel] 'test_mention_striper_channel' has been registered with id '1126485979486752890'!
[DEBUG] (Goldy Bot) - [SlashCommand] [test_mention_striper_user] 'test_mention_striper_user' has been registered with id '1126485979486752891'!
[DEBUG] (Goldy Bot) - [SlashCommand] [test_attachment] 'test_attachment' has been registered with id '1126485979486752892'!
[DEBUG] (Goldy Bot) - [SlashCommand] [test_options] 'test_options' has been registered with id '1126485979486752893'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [test_buttons] 'test_buttons' has been registered with id '1126485979486752894'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [test_channels] 'test_channels' has been registered with id '1126485979486752895'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [test_guilds] 'test_guilds' has been registered with id '1126485979486752896'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [stop] 'stop' has been registered with id '1126485979486752898'!
[DEBUG] (Goldy Bot) - [PrefixCommand] [goldy] 'goldy' has been registered with id '1126286658359263234'!

optimize the DatabaseWrapper

As the title says, the database wrapper is kinda messy. I think we might not need all of this stuff like creating the documents if they don't exist in the update method. If we are able to remove those things will be 100 times cleaner.

Let's check if we can insert data into a document regardless of whether it exists or not, basically if it doesn't exist create it but I want this to be done from the database class.

Transition from Guild cmds --> Global cmds.

As the title says, I need to transition to global commands for production. However I want to keep guild bound commands for development purposes for obvious reasons.

So somehow we got to implement two separate modes, production mode and development mode.

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.