-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add osu! verification and automatic role assignment
- Loading branch information
Showing
15 changed files
with
454 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) Pasi4K5 <https://www.github.com/Pasi4K5> | ||
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Numerous.ApiClients.Osu.Models; | ||
|
||
namespace Numerous.ApiClients.Osu; | ||
|
||
public static class Extensions | ||
{ | ||
public static bool IsRankedMapper(this OsuUser user) | ||
{ | ||
return user.RankedBeatmapsetCount > 0 | ||
|| user.GuestBeatmapsetCount > 0; | ||
} | ||
|
||
public static bool IsLovedMapper(this OsuUser user) | ||
{ | ||
return user.LovedBeatmapsetCount > 0; | ||
} | ||
|
||
public static bool IsUnrankedMapper(this OsuUser user) | ||
{ | ||
return | ||
(user.GraveyardBeatmapsetCount > 0 || user.PendingBeatmapsetCount > 0) | ||
&& !user.IsRankedMapper(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (C) Pasi4K5 <https://www.github.com/Pasi4K5> | ||
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Discord.Interactions; | ||
|
||
namespace Numerous.ApiClients.Osu; | ||
|
||
public enum OsuUserGroup | ||
{ | ||
[ChoiceDisplay("Unranked Mapper")] UnrankedMapper = -1, | ||
[ChoiceDisplay("Ranked Mapper")] RankedMapper = -2, | ||
[ChoiceDisplay("Loved Mapper")] LovedMapper = -3, | ||
[ChoiceDisplay("GMT")] GlobalModerationTeam = 4, | ||
[ChoiceDisplay("NAT")] NominationAssessmentTeam = 7, | ||
[ChoiceDisplay("Developers")] Developers = 11, | ||
[ChoiceDisplay("Community Contributors")] OsuAlumin = 16, | ||
[ChoiceDisplay("Technical Support Team")] TechnicalSupportTeam = 17, | ||
[ChoiceDisplay("Beatmap Nominators")] BeatmapNominators = 28, | ||
[ChoiceDisplay("Project Loved")] ProjectLoved = 31, | ||
[ChoiceDisplay("Beatmap Nominators (Probationary)")] BeatmapNominatorsProbationary = 32, | ||
[ChoiceDisplay("ppy")] Ppy = 33, | ||
[ChoiceDisplay("Featured Artists")] FeaturedArtists = 35, | ||
[ChoiceDisplay("Beatmap Spotlight Curators")] BeatmapSpotlightCurators = 48, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (C) Pasi4K5 <https://www.github.com/Pasi4K5> | ||
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Discord; | ||
using Discord.Interactions; | ||
using JetBrains.Annotations; | ||
using Numerous.ApiClients.Osu; | ||
|
||
namespace Numerous.Discord.Commands; | ||
|
||
[Group("config", "Configuration commands")] | ||
[DefaultMemberPermissions(GuildPermission.Administrator)] | ||
public sealed class ConfigCommandModule : CommandModule | ||
{ | ||
[Group("role", "Role configuration commands")] | ||
public sealed class RoleCommandModule(OsuVerifier verifier) : CommandModule | ||
{ | ||
[UsedImplicitly] | ||
[SlashCommand("set", "Configures which role to assign to which users.")] | ||
public async Task SetRole( | ||
[Summary("group", "The group to set the role for.")] OsuUserGroup group, | ||
[Summary("role", "The role to assign to users in the group.")] IRole role | ||
) | ||
{ | ||
await verifier.SetRoleAsync(Context.Guild, group, role); | ||
|
||
await RespondWithEmbedAsync( | ||
$"Set role for group {group} to {role.Mention}.", | ||
ResponseType.Success | ||
); | ||
} | ||
|
||
[UsedImplicitly] | ||
[SlashCommand("remove", "Stops automatically assigning the given role.")] | ||
public async Task RemoveRole( | ||
[Summary("group", "The group to remove the role for.")] OsuUserGroup group | ||
) | ||
{ | ||
await verifier.RemoveRoleAsync(Context.Guild, group); | ||
|
||
await RespondWithEmbedAsync( | ||
$"Removed role for group {group}.", | ||
ResponseType.Success | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.