This PR fixes an issue that caused guild data JSON files to be corrupted
upon saving. As it turns out `File.OpenWrite(string)` does not clear the
file before writing to it. That means, if a file contains `{"MyKey":
"MyValue"}` and I write `{}` to it using `File.OpenWrite(string)`, the
contents of the file will be `{}MyKey": "MyValue"}`. This is a malformed
JSON and will cause an error upon next bot startup.
In addition, this PR blacklists the `File.OpenWrite` method using
`CodeAnalysis/BannedSymbols.txt` to prevent its accidental use in the
future.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR adds autocomplete for setting keys in `/editsetting` slash
command. The usage of options provided by auto-complete is enforced
client-side.
Closes#97Closes#95
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR adds a BackgroundGuildDataSaverService which will save all guild
data to disk every 5 minutes using a PeriodicTimer.
Closes#96
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR renames commands `/settingslist` and `/settings` to
`/listsettings` and `/editsettings` respectively. This helps avoid
confusion and accidental use of the wrong command while conforming to a
common naming style, similar to remind commands.
cc @mctaylors wiki needs updating
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR fixes an exception that would occur when deserialization of
ScheduledEventData would be attempted. The exception is fixed by
providing a constructor containing all properties and adding the
`[JsonConstructor]` attribute.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR closes#85.
This PR fixes many issues related to scheduled events. Most importantly,
scheduled events that are no longer present in the guild, but still have
data related to them, won't be left rotting.
This requires deletion of `ScheduledEvents.json` files in all guilds.
Maybe I'll start writing datafixers one day...
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR closes#87.
This PR splits the workflow into 2 files: `build-pr.yml` and
`build-push.yml`.
The former runs InspectCode to make sure issues don't get through, while
the latter builds and uploads Boyfriend and publishes it to a remote
production server via SSH.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Without this embed, if there are no reminders created by the user, the
bot will endlessly think because StringBuilder will be empty and normal
embed will not be shown.
This PR fixes EventEarlyNotification timestamp not displaying correctly
and also has some other changes:
- Add xmldocs for `/settingslist`'s `page` option in
SettingsCommandGroup.cs
- Add option description for `index` for `/delreminder`
- Some corrections of grammatical errors in Messages.tt-ru.resx
- Fix `ArgumentOutOfRangeException` in `/settingslist` that appears if
the user uses a negative integer in `page`
---------
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR fixes a fatal crash that occurs when the bot tries to send an
early notification for a scheduled event. An exception is thrown by
`string#Format` when the argument list provided doesn't match the
argument list in the template. This is fixed by correcting the template
and the argument list
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR closes#61.
This PR adds the `/listremind` command and the `/delremind` command. The
`/delremind` command requires an index to determine which reminder to
delete.
cc @mctaylors review embed design and feature experience
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR fixes the following bugs in ScheduledEventUpdateService:
- When a scheduled event is first added into ScheduledEventData, its
status update code will be skipped. This results in some messages not
being sent to the EventNotificationChannel
- When the status update code returns an unsuccessful Result, the status
in ScheduledEventData will still be updated, meaning that the code will
not retry.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
GuildUpdateService is a service that contains way too many
responsibilities with everything strictly coupled to each other. The
code is buggy, hard to refactor and swallows errors. This prompted me to
make this PR, which splits it into three independant services:
- SongUpdateService (responsible for changing songs presence);
- MemberUpdateService (responsible for updating member datas: unbanning
users, adding the default role, sending reminders, filtering nicknames);
- ScheduledEventUpdateService (responsible for updating scheduled
events: sending notifications, automatically starting events).
All of these services and their methods use Results to push errors all
the way up in the stack, making sure no error is missed. To make logging
and debugging easier, an extension method for `ILogger` was created -
`LogResult`. The method checks if the result was successful or if its
failure was caused by a user or environment error before logging
anything - providing cleaner code and logs. `ExceptionError`s will also
have their exception stacktrace and type logged (except in Remora code).
This PR also fixes an issue that prevented banned users from being
unbanned when their punishment was over.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR backfills member data when a guild is loaded or a new member
joins it. The reason for that is some actions that happen on member tick
(default role grant, nickname filtering) would only occur if a member
had data related to them (due to being banned or setting a reminder). In
addition, the `.editorconfig` was updated with new inspections provided
by a new release of Rider, 2023.2
See explanations for some changes in comments.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR fixes an issue where, if the `PublicFeedbackChannel` wasn't set
or the welcome message was disabled, `GuildMemberJoinedResponder` would
`return` early, causing roles to not be granted back if
`ReturnRolesOnRejoin` was enabled, by moving the `if return` after the
code that grants back roles
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
*I'll start working on features and bugfixes after this PR, I promise*
very short summary:
- no more braceless statements
- braces are on new lines now
- `sealed` on everything that can be `sealed`
- no more awkwardly looking alignment of fields/parameters
- no more `Service` suffix on service fields. yeah.
- no more `else`s. who needs them?
- code style is now enforced by CI
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR adds some soundtracks from five different games to the bot's
listening activity.
List of soundtracks added:
- Jukio Kallio, Daniel Hagström - Fall 'n' Roll (Fall Guys)
- SCATTLE - Hypertension (Super Meat Boy)
- KEYGEN CHURCH - Tenebre Rosso Sangue (ULTRAKILL)
- Chipzel - Swing Me Another 6 (Dicey Dungeons)
- ~Floex - The Glasshouse With Butterfly (Machinarium)~
- Noisecream - Mist of Rage (My Friend Pedro)
This PR removes the wrapping of in-house created result errors with
`Result.FromError` (I did not know this was possible until today, lol),
which reduces code verbosity and makes it easier to read, and replaces
`ArgumentNullError` with `ArgumentInvalidError` when retrieving IDs from
a command context, which, in my opinion, is more correct.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR is mainly aimed at improving /settingslist and fixing /settings
List of things to do before merging:
- [x] #62
- [x] Add the pages feature to /settingslist
- [x] Add bullets like these ->
![](https://github.com/TeamOctolings/Boyfriend/assets/95250141/fdf1a3b8-bb64-473d-9f57-bc6e34812811)
And since the development has already been taking more than 2 days, I
suggest splitting the PR into 2 parts.
List of other things that will be in the future PR:
- mctaylors#1
- Fix bot not answering when an invalid setting is specified in
/settings
- Options list for /settings
---------
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
This PR adds the package `Microsoft.CodeAnalysis.BannedApiAnalyzers` to
scan for banned code (defined by `CodeAnalysis/BannedSymbols.txt`) and
provide warnings if it is used. The list of banned symbols is borrowed
from osu! and other projects
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR adds the `color` and `isPublic` parameters to
`UtilityService#LogActionAsync`. Previously, all embeds would be sent in
both public and private feedback channels with the green embed color. It
is now possible to change these fields, allowing for usage of the red
color in punishment commands and allowing to hide the result of `/clear`
from public eyes.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR allows passing mentions as an input to SnowflakeOption by
removing non-number characters from the input string.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR uses a new feature of the InspectCode action: extensions. By
adding the `Cognitive Complexity` extension, InspectCode can provide
warnings and force the contributors to follow standards regarding
complex methods. This functionality was previously provided by
CodeFactor, but it is no longer used. Here's the full changelog of this
PR:
- Allowed Actions to run on push for any branch, not just `master`;
- Added `Cognitive Complexity` plugin for InspectCode;
- Significantly reduced complexity of KickCommandGroup, MuteCommandGroup
and GuildUpdateService
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR disables automatic assignation of all PRs created by Dependabot
to me. There are now more people working on Boyfriend than just me. In
fact, this project, in theory, can live without me as there are other
members working on it.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Depends on #54
This PR reduces the method complexity of
`ClearCommandGroup#ClearMessagesAsync` by doing the following:
- Splitting the command method into 2 parts: ExecuteClear and
ClearMessagesAsync. The former will check all the needed results and
will pass the outputs into the latter;
- Using the recently extracted method `UtilityService#LogActionAsync` to
log deletion of messages.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Depends on #55
These changes are really small and I don't know how to reasonably split
them into multiple PRs, but here's the changelog:
- The result of the `UtilityService#LogActionAsync` call in
`BanCommandGroup#BanUserAsync` is no longer ignored and it's errors will
now prevent feedback from being sent;
- Converted `if` statement to a `return` with ternary in
`LanguageOption`;
- Slightly decreased method complexity of
`MessageDeletedResponder#RespondAsync` by cleverly using Results;
- Changed the order of parameters for `UtilityService#LogActionAsync` to
flow better;
- Removed the exemption for `ConvertIfToReturnStatement` for
InspectCode.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR reduces method complexity in
`UtilityService#CheckInteractionsAsync` by splitting the method into two
parts, similar to `/ban` and `/unban`. Additionally, it converts the
last `if` statement to a `return` with ternary.
After this is merged, status checks on #54 should succeed and that PR
should be merged.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR does numerous things to reduce method complexity:
- Created an extension method
`FeedbackService#SendContextualEmbedResultAsync`, which directly takes a
`Result<Embed>` and checks it once in the extension method instead of
multiple times in all commands;
- Split the command methods for `/ban` and `/unban` into 2 parts:
`Execute(Un)Ban` and `(Un)BanUserAsync`. The former will check all the
needed results and will pass the outputs into the latter;
- Extracted the method for logging an action into Private- and
PublicFeedbackChannels. It now resides in UtilityService. Right now,
only `/ban` and `/unban` make use of that method;
- Created an extension method `Snowflake#EmptyOrEqualTo`, that combines
the task of checking if a Snowflake is empty and checking if that
Snowflake is equal to another Snowflake.
Similar changes will be made to other command groups in future PRs. This
is not done here to make the reviewing process easier.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR splits `LoggingPreparationErrorEvent` and
`ErrorLoggingPostExecutionEvent` classes into separate files and puts
these files in a separate namespace: `Boyfriend.Commands.Events`. This
makes these classes easier to find and distinguish from commands groups.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR adds a `labels.yml` file to configure the `pull-request-size`
bot. The new thresholds are:
- 0-9 lines for XS
- 10-49 lines for S
- 50-99 lines for M
- 100-499 lines for L
- 500-999 lines for XL
- \>1000 for XXL
In the file, these thresholds are doubled to accomodate for the fact
that both additions and deletions are counted (e.g. editing 10 lines
will result in 10 additions and 10 deletions, 20 in total)
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This PR prevents usage of `/about`, `/ping` and `/remind` inside DMs.
While it may look like these commands do not require a guild attached to
them, the language system depends on having a guild to fetch settings
from, so it is not possible to use these commands in DMs.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
mctaylors:
- updated readme 7 times (and only adding new logo from /about)
-
[removed](aeeb3d4399)
bot footer from created event embed on the second try
-
[changed](4b9b91d9e4)
cdn from discord to upload.systems
Octol1ttle:
- Guild settings code has been overhauled. Instead of instances of a
`GuildConfiguration` class being (de-)serialized when used with listing
and setting options provided by reflection, there are now multiple
`Option` classes responsible for the type of option they are storing.
The classes support getting a value, validating and setting values with
Results, and getting a user-friendly representation of these values.
This makes use of polymorphism, providing clean and easier to use and
refactor code.
- Gateway event responders have been split into their own separate
files, which should make it easier to find and modify responders when
needed.
- Warning suppressions regarding unused and never instantiated classes
have been replaced by `[ImplicitUse]` annotations provided by
`JetBrains.Annotations`. This avoids hiding real issues and provides a
better way to suppress false warnings while being explicit.
- It is no longer possible to execute some slash commands if they are
run without the correct permissions
- Dependencies are now more explicitly defined
neroduckale:
- Made easter eggs case-insensitive
---------
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: nrdk <neroduck@vk.com>
The project structure has been changed because the previous one had
everything in 1 folder. From this PR onwards, the following is true:
- The source code is stored in `src/`
- `*.resx` and `Messages.Designer.cs` is stored in `locale/`
- Documentation is stored on the wiki and in `docs/`
- Miscellaneous files, such as dotfiles, are stored in the root folder
of the repository
This PR additionally fixes an issue that would cause logs of edited
messages to not be syntax highlighted. This happened because the
responder of edited messages was changed to use the universal
`InBlockCode` extension method which did not support syntax highlighting
until this PR
This PR additionally changes CODEOWNERS to be more reliable. Previously,
it would be possible for some PRs to be unable to be approved because
the only person who can approve them is the same person who opened the
PR.
---------
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>