-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add #insiders-info interactions (#255)
* Add #insiders-info interactions * Restrict /send-insiders-info-buttons to Trial Moderators * Add config value for insiderChat Co-authored-by: Erisa A <erisa@erisa.uk> * Add OwnerOverride to SlashRequireHomeserverPerm & /send-insiders-info-buttons * Check whether insidersChannel is set in config before using it * Check whether user already has insider roles when giving insiderChat * config: Make insiderCommandLockedToChannel an alias of insidersChannel Also changes usages to InsidersChannel; config.json accepts both, but only InsidersChannel can be used in code --------- Co-authored-by: Erisa A <erisa@erisa.uk>
- Loading branch information
1 parent
6938b9e
commit f21ccb9
Showing
6 changed files
with
245 additions
and
6 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
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,39 @@ | ||
namespace Cliptok.Commands.InteractionCommands | ||
{ | ||
public class InsidersInteractions : ApplicationCommandModule | ||
{ | ||
[SlashCommand("send-insiders-info-buttons", "Sends a message with buttons to get Insider roles for #insiders-info.", false)] | ||
[SlashRequireHomeserverPerm(ServerPermLevel.Admin, ownerOverride: true), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)] | ||
public static async Task SendInsidersInfoButtonMessage(InteractionContext ctx) | ||
{ | ||
if (Program.cfgjson.InsiderInfoChannel != 0 && ctx.Channel.Id != Program.cfgjson.InsiderInfoChannel) | ||
{ | ||
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} This command only works in <#{Program.cfgjson.InsiderInfoChannel}>!", ephemeral: true); | ||
return; | ||
} | ||
|
||
DiscordComponent[] buttons = | ||
[ | ||
new DiscordButtonComponent(DiscordButtonStyle.Primary, "insiders-info-roles-menu-callback", "Choose your Insider roles"), | ||
new DiscordButtonComponent(DiscordButtonStyle.Secondary, "insiders-info-chat-btn-callback", "I just want to chat for now") | ||
]; | ||
|
||
string insidersChannelMention; | ||
if (Program.cfgjson.InsidersChannel == 0) | ||
{ | ||
insidersChannelMention = "#insiders"; | ||
Program.discord.Logger.LogWarning("#insiders-info message sent with hardcoded #insiders mention! Is insidersChannel set in config.json?"); | ||
} | ||
else | ||
{ | ||
insidersChannelMention = $"<#{Program.cfgjson.InsidersChannel}>"; | ||
} | ||
|
||
var builder = new DiscordInteractionResponseBuilder() | ||
.WithContent($"{Program.cfgjson.Emoji.Insider} Choose your Insider roles here! Or, you can choose to chat in {insidersChannelMention} without being notified about new builds.") | ||
.AddComponents(buttons); | ||
|
||
await ctx.CreateResponseAsync(builder); | ||
} | ||
} | ||
} |
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