This PR makes it so that roles in MemberData are updated only in
MemberUpdateService. This reduces possible points of failures,
maintenance burden and reliance on gateway events
Because the Discord API sucks at providing data when needed, this PR
makes it so that events are synchronized every tick instead of on
gateway events. This fixes an issue where the bot won't know about a
scheduled event if it was created before the bot was started
We're moving!
---------
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
Flipping `>` to `<=` changed null handling semantics within the
operator, causing the unban/unmute code to always run
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
If a user was muted using the `MuteRole` method and then banned, the
UnknownMember warning will flood your logs when `DateTimeOffset.UtcNow >
data.MutedUntil` becomes true, because there is no user in the server to
unmute.
---------
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
- Added support for `MuteRole`, now if you add any role to this setting,
then try to mute a member, all his roles will be removed except for the
one you set in this setting.
- Fixed `/unmute`, that tried to set target's display name to unmute
reason.
---------
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
This PR closes#105
This PR fixes exceptions caused by changing a collection's contents
while it is being enumerated. This can often happen with Guild- and
MemberDatas. By using `ToArray()` on these global collections and using
it in the `foreach` loop, we create a new copy of the collection,
preventing any modification to it.
While this does introduce a lot of memory allocations, there is no
fixing that. Usually, the fix to these exceptions would be to convert
the `foreach` to a reverse-`for`. However, because indices cannot be
used on these collections, that is not possible.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
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>