Commit graph

182 commits

Author SHA1 Message Date
488a1eec0c
Add /listremind and /delremind (#82)
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>
2023-08-12 13:54:51 +00:00
cac3ee9bf7
Scheduled event update bugfixes (#81)
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>
2023-08-12 13:47:14 +00:00
f260681b39
Split GuildUpdateService into separate services (#80)
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>
2023-08-05 18:02:40 +00:00
e9f7825e4a
Backfill member data when a guild is loaded or a new member joins it (#77)
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>
2023-08-04 13:52:54 +00:00
d023033ed4
Fix roles not returning on rejoin if welcome messages were disabled (#78)
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>
2023-08-03 20:34:01 +00:00
c9a7fb79ab
Log guild setting changes to PrivateFeedbackChannel (#79)
This PR makes the bot log guild settings to the Private Feedback
Channel. The functionality was present in pre-Remora Boyfriend, but was
missing afterwards, so I will call this a bug, making this PR a bugfix.

cc @mctaylors - embed design needs review

![image](https://github.com/TeamOctolings/Boyfriend/assets/61277953/5680f0d6-82fc-4c0e-b4f0-815b082997ec)

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-08-03 20:32:38 +00:00
84e730838b
Add a new .editorconfig and reformat code (#76)
*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>
2023-08-02 20:51:16 +00:00
4cb39a34b5
Add logging to file (#75)
This PR adds the package `Serilog.Extensions.Logging.File` to add
logging to file. I decided this was necessary after the bot unexpectedly
went down in a tmux session, leaving no traces behind.


![image](https://github.com/TeamOctolings/Boyfriend/assets/61277953/b6ff9e69-b370-4844-b552-db4a39933f62)

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-08-02 13:25:41 +00:00
940f2e64a0
Add soundtracks from different games (#74)
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)
2023-07-30 09:29:08 +00:00
f47ebe81c5
Do not wrap result errors when returning them (#73)
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>
2023-07-28 16:58:55 +00:00
a6df26af67
Resolving issues on #65 (#72)
Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
2023-07-26 18:07:05 +00:00
8f95e4cd2c
Replace "ToLower" with "ToLowerInvariant" to fix a missed warning (#71) 2023-07-25 16:20:09 +00:00
05fd343dce
Improved /settingslist + fixed /settings pt.1 (#65)
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>
2023-07-25 19:53:11 +05:00
397bb83ba8
Add code analysis to prohibit using bad methods and properties (#70)
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>
2023-07-24 20:35:45 +03:00
7b722a45cb
Rename users who attempt to hoist themselves (#53)
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Signed-off-by: mctaylors <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: nrdk <neroduck@vk.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-07-24 19:51:05 +03:00
dependabot[bot]
fbe772406d
Bump Remora.Discord.Extensions from 5.3.1 to 5.3.2 (#67)
Bumps Remora.Discord.Extensions from 5.3.1 to 5.3.2.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 17:00:24 +05:00
dependabot[bot]
abce09f26d
Bump Remora.Discord.Interactivity from 4.5.0 to 4.5.1 (#68)
Bumps Remora.Discord.Interactivity from 4.5.0 to 4.5.1.

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-07-24 16:57:41 +05:00
dependabot[bot]
f752ebf101
Bump Remora.Discord.Caching from 36.0.0 to 37.0.0 (#69)
Bumps Remora.Discord.Caching from 36.0.0 to 37.0.0.
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 16:46:17 +05:00
dependabot[bot]
40527dad06
Bump Remora.Discord.Hosting from 6.0.6 to 6.0.7 (#66)
Bumps Remora.Discord.Hosting from 6.0.6 to 6.0.7.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 16:43:38 +05:00
b4748a18c5
Add Color and Public parameters to LogActionAsync (#64)
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>
2023-07-23 23:07:36 +03:00
e31a9f73fa
Remove non-numbers from SnowflakeOption inputs (#63)
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>
2023-07-23 23:06:00 +03:00
27b8f15e3b
Force maximum Cognitive Complexity via InspectCode (#60)
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>
2023-07-21 08:54:52 +05:00
8c72dc663e
Do not assign Octol1ttle for Dependabot PRs (#59)
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>
2023-07-20 23:20:25 +03:00
dependabot[bot]
0938f518f8
Bump muno92/resharper_inspectcode from 1.7.1 to 1.8.0 (#58)
Bumps muno92/resharper_inspectcode from 1.7.1 to 1.8.0.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-20 18:44:10 +05:00
d43ee59099
Remove "code quality" badge (#57)
https://github.com/TeamOctolings/Boyfriend/assets/95250141/efdb0bef-930f-43e5-bba8-6554473f3580

Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
2023-07-20 07:55:02 +00:00
4624b59a8a
Reduce method complexity of /clear (#56)
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>
2023-07-20 10:44:07 +03:00
daa1dd4184
General fixes (#54)
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>
2023-07-20 07:36:21 +00:00
685688bbe8
Reduce method complexity of UtilityService#CheckInteractionsAsync (#55)
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>
2023-07-20 07:25:03 +00:00
e2bf083189
Reduce method complexity in /ban, /unban and some other commands (#50)
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>
2023-07-19 21:08:44 +00:00
c825848d7e
Split error logging events into separate files (#51)
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>
2023-07-19 21:01:53 +00:00
f97e99d82b
Increase thresholds for size labels (#52)
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>
2023-07-19 21:00:11 +00:00
f75926c604
Do not allow certain commands to be used in DMs (#49)
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>
2023-07-18 14:18:35 +00:00
c6dd3727c3
The Milestone Commit (#48)
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>
2023-07-18 12:25:02 +00:00
3eb17b96c5
Tidy up project structure, fix bug with edit logging (#47)
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>
2023-07-09 22:36:44 +05:00
2dd9f023ef
Fix some issues with slash commands & add missing docs (#46)
mctaylors: "but I use Rider too..."
2023-07-09 20:15:39 +05:00
abbb58f801
Switch to Remora.Discord (#41)
result checks go brrr

this also involves switching to using Discord's modern stuff like embeds
and interactions

and using brand-new for me programming concepts (dependency injection,
results)

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Signed-off-by: mctaylors <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: mctaylors <95250141+mctaylors@users.noreply.github.com>
Co-authored-by: nrdk <neroduck@vk.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-09 16:32:14 +03:00
2ab7a07784
Update README.md (#39) 2023-05-17 13:41:23 +03:00
8d740e1c52
Update CODEOWNERS
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-05-17 13:16:42 +05:00
c83a458633
Rearrange commands in !help (#37) 2023-05-16 10:58:35 +05:00
e80ced2d54
Update mctaylors' Language (#36)
coolest pull request fr
2023-05-15 15:30:58 +00:00
02949656bf
Change audit output if a message was deleted because of '!clear' (#34) 2023-05-12 19:56:14 +05:00
b0fd49fea2
Remove pointless PropertyGroups
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-04-27 22:55:18 +05:00
926dc0f1b7
Make sure the audit log enumerable is not empty when determining message deleter
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-04-27 22:53:28 +05:00
e35db12ab3
Merge remote-tracking branch 'origin/master' 2023-04-27 22:51:15 +05:00
cdfa0e11f7
Use DateTimeOffset#UtcNow instead of DateTimeOffset#Now (UtcNow is actually faster lol)
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-04-27 22:14:30 +05:00
dependabot[bot]
6dbfc1bfae
Bump muno92/resharper_inspectcode from 1.6.11 to 1.6.13 (#30)
Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 06:09:22 +00:00
dependabot[bot]
f01ce4fe1c
Bump muno92/resharper_inspectcode from 1.6.6 to 1.6.11 (#27)
Bumps
[muno92/resharper_inspectcode](https://github.com/muno92/resharper_inspectcode)
from 1.6.6 to 1.6.11.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-03 11:19:01 +05:00
41958deb0a
Fixed a memory leak caused by hitting rate limits, caused by attempts to add unset starter roles
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-03-28 22:47:01 +05:00
05ce680373
Bump Discord.Net from 3.9.0 to 3.10.0
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-03-28 15:28:34 +05:00
cac0bdc801
Fix calling commands with @mentions
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-03-20 12:33:54 +05:00