2.4.0 [Cat APIs, GH Actions, Refactorings and MANY improvements] #66
maj113
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone!
It's been a while since I last published a release for Angel6, that was mostly because implementing logging was difficult due to ongoing (and barely documented) API changes, music bot kept breaking and since there have been so many changes It has been really hard to write a proper changelog, between 2.3 and 2.4 there have been 559 commits and tracking these changes has been difficult so this time it there wont be a proper changelog but me describing what I know i changed between releases, okay so;
Music cog:
When I released 2.3 (later internally 2.3.1) I just switched to Opus from PCM since it was IMO much better, however back then I didn't think it would break the cog as badly as it did, there was no more Volume support, a good portion of functions had to be changed just so it played a song, let alone played it properly without anything breaking, looping was broken, pause was broken (still is to some extent), Queue would fail, skipping a song didn't work etc etc, fixing these issues was really hard mostly because the entire music cog was built for an older version of Discord.py (1.7.3) and upgrading to 2.0 meant it would introduce breaking changes and thanks to extremely poor documentation we had back when 2.0 released it was pretty hard to fix some of those.
This release was mostly spent fixing bugs and getting the bot to play the song faster. It now takes roughly 3 sec to play the song compared to the previous 5-6 sec
Changes:
I've documented most of the code (more or less just to make PyLint happy).
code has been cleaned up and I've made it much less error prone than it was in 2.3.
I rewrote some of the code so less external modules are needed.
Code was updated to respect changes in discord.py 2.0,
The cog uses AsyncIO now a lot since that speeds it up by at least 20% while also doing multiple things at the same time.
The codestyle was changed considerably and the cog is now mostly pep-8 compliant, codestyle is enforced with Black auto formatter, format is no longer used and has been replaced with f-strings since It's easier to read and looks cleaner.
Most of the work went into a couple pesky functions (
audio_player_task
,create_source
,create_embed
,_play
...)In
audio_player_task
we no longer duplicate code like crazy, some stuff was called multiple times for absolutely no apparent reason, this function andcreate_source
were the causes of absolute shit performance since the code was almost fully blocking and called outdated and blocking functionsJust like in
audio_player_task
the functioncreate_source
was giving me nightmares daily, fixed something and couple days later 10 new issues were found, the code was slimmed down to 13 lines down from 38 because for some reason it called Youtube-DL'sextract_info
twice.Logging wise it's now much better and more options are set when using the
debug
command line argument, FFmpeg now has adjustable logging level, It now saves a log to alog.txt
file too so one can check the log of the last bot sessionA new function
checkloop
was created which is called onskip
andstop
commands which checks if loop is enabled, disables It, issues either stop or skip and re-enables loop if skip was usedMany embeds had their looks improved, better error messages and overall verbosity has been improved.
While internally there were many more changes It's mostly minor and not visible outside of the code so that's more or less it for the music cog.
Angel6:
The main
angel6-Rewrite
file had many "under the hood" changes but I've mostly spent time implementing logging, making commands appear more visually pleasing when invoked, handling errors in moderation commands while also making sure one can't e.g. ban themselves, I've also introduced a couple new commands: giflist and gifsend, cat/anime image API, asbot (more about that later), other commands got improved significantly for a better UX, a lot of time was spent on profiling which API wrapper was the best and it seems that PyCord is still the best (I don't trust the original discord.py library since it may just go EOL again).Changes:
On the Angel6 side I mostly focused on getting logging events working, currently I've implemented these events:
Logging:
on_message
: Logs the messages to the terminal.on_member_join
andon_member_remove
: Sends a message to a specified channel when someone joins or leaves the server.on_message_delete
: Sends a message to the logging channel with the contents of the deleted message and the name of the user who sent the message.on_guild_channel_create
andon_guild_channel_delete
: Sends a message to the logging channel with the name of the channel, which category is in and who made/deleted the channel.on_guild_channel_update
: Sends a message to the logging channel with the name before and after the change e.g. (channel1
->channel2
)it does the same if the category changed.
on_user_update
: Sends a message when someone either changes their avatar or their username/display name.on_guild_role_create
, on_guild_role_delete, on_guild_role_update
: Sends a message to the logging channel with the role name that was added/deleted/changed, by who it was changed, what permissions were changed.Asbot:
That's how the function is called internally, It uses an asynchronous
ainput
from aioconsole to wait for an input/message in the terminal, which then gets relayed to the specified channel, no this is not self botting, it uses regularctx.send
.Cat/Neko API:
I've added this because It wasn't hard to implement, internally I use 2 APIs:
https://api.thecatapi.com/v1/images/search
andhttps://api.nekosapi.com/v2/images/random?filter[ageRating]=sfw
, the image gets embedded in a discord embed so its not just a raw image displayed, currently using search is not supported but I might implement this later.giflist/gifsend:
The
giflist
command will list the gifs that are for now hard coded in a dict ("gifname":"gifurl"
), It show an embed with a field for each gif and the command to send that gifThe
gifsend
command will send the gif and delete the authors message, it uses the name of the gif so if the name of the gif was gif1 the command argument would be~gifsend gif1
.Other bot changes:
Like I've said earlier most of the under the hood changes went into PEP-8 compliance, codestyle, formatting, error handling and more
The bot currently has a code rating for about 9.95/10, codestyle is enforced with black, code has been extensively documented, verbosity of errors has been improved and now sends an error both to the terminal and to the channel (before it only sent it to the terminal which means that if a command fails to execute there will be no indication of that).
Just like in music.py I've streamlined the code, used f-strings instead of format and string concatenation since It's much shorter and looks cleaner, I've also updated some functions to use new python 3.11 code which is faster all in all.
On the UX side I updated a lot of embeds to look nicer/ more visually appealing, have color (not just blurple this time).
GitHub changes:
Possibly the most major update on the repo side is the much nicer Readme.md, take a look at the bot gallery.
We now have massively overhauled Github Actions, Linting, CodeQL and Security scanning using Bandit and DevSkim This should help anyone that want's to contribute
Moving forward:
I can see why writing changelogs was so hard; I didn't use branches or Pull Requests, this changelog/release notes could be done in 10 minutes, I guess I was just too lazy and changing that in the middle of the release would be pointless and probably even more confusing, from 2.4.0 on I'll be only using branching and pull requests to work on bigger changes, for stuff like actions and readme ill still just directly commit to master
That's it for this changelog, get the latest release by cloning the project and make sure to do
git pull
once in a while"Thanks for using my Bot or something" - Maj
This discussion was created from the release 2.4.0 [Cat APIs, GH Actions, Refactorings and MANY improvements].
Beta Was this translation helpful? Give feedback.
All reactions