From 5105b43eff654839edc1d126fa8f33972bfee75b Mon Sep 17 00:00:00 2001 From: Macintxsh <95250141+mctaylors@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:42:37 +0300 Subject: [PATCH] Add WelcomeMessagesChannel setting (#269) Closes #232 Signed-off-by: mctaylors --- locale/Messages.resx | 3 +++ locale/Messages.ru.resx | 3 +++ locale/Messages.tt-ru.resx | 3 +++ src/Commands/SettingsCommandGroup.cs | 1 + src/Data/GuildSettings.cs | 5 +++++ src/Data/Options/AllOptionsEnum.cs | 1 + src/Messages.Designer.cs | 7 +++++++ src/Responders/GuildMemberJoinedResponder.cs | 4 ++-- 8 files changed, 25 insertions(+), 2 deletions(-) diff --git a/locale/Messages.resx b/locale/Messages.resx index ca48fba..c8ef510 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -657,4 +657,7 @@ Example of a valid input: `1h30m` + + Welcome messages channel + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index 7423347..eb8e57b 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -657,4 +657,7 @@ Пример правильного ввода: `1ч30м` + + Канал для приветствий + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index dc3bb6f..df50d8d 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -657,4 +657,7 @@ правильно пишут так: `1h30m` + + канал куда говорить здравствуйте + diff --git a/src/Commands/SettingsCommandGroup.cs b/src/Commands/SettingsCommandGroup.cs index acfb8ed..86f031f 100644 --- a/src/Commands/SettingsCommandGroup.cs +++ b/src/Commands/SettingsCommandGroup.cs @@ -46,6 +46,7 @@ public class SettingsCommandGroup : CommandGroup GuildSettings.RenameHoistedUsers, GuildSettings.PublicFeedbackChannel, GuildSettings.PrivateFeedbackChannel, + GuildSettings.WelcomeMessagesChannel, GuildSettings.EventNotificationChannel, GuildSettings.DefaultRole, GuildSettings.MuteRole, diff --git a/src/Data/GuildSettings.cs b/src/Data/GuildSettings.cs index cdaede6..5a99505 100644 --- a/src/Data/GuildSettings.cs +++ b/src/Data/GuildSettings.cs @@ -56,6 +56,11 @@ public static class GuildSettings /// public static readonly SnowflakeOption PrivateFeedbackChannel = new("PrivateFeedbackChannel"); + /// + /// Controls what channel should welcome messages be sent to. + /// + public static readonly SnowflakeOption WelcomeMessagesChannel = new("WelcomeMessagesChannel"); + public static readonly SnowflakeOption EventNotificationChannel = new("EventNotificationChannel"); public static readonly SnowflakeOption DefaultRole = new("DefaultRole"); public static readonly SnowflakeOption MuteRole = new("MuteRole"); diff --git a/src/Data/Options/AllOptionsEnum.cs b/src/Data/Options/AllOptionsEnum.cs index a96a9ac..e9637d6 100644 --- a/src/Data/Options/AllOptionsEnum.cs +++ b/src/Data/Options/AllOptionsEnum.cs @@ -21,6 +21,7 @@ public enum AllOptionsEnum [UsedImplicitly] RenameHoistedUsers, [UsedImplicitly] PublicFeedbackChannel, [UsedImplicitly] PrivateFeedbackChannel, + [UsedImplicitly] WelcomeMessagesChannel, [UsedImplicitly] EventNotificationChannel, [UsedImplicitly] DefaultRole, [UsedImplicitly] MuteRole, diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index ca460cf..5ad741e 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -1184,5 +1184,12 @@ namespace Octobot { return ResourceManager.GetString("TimeSpanExample", resourceCulture); } } + + internal static string SettingsWelcomeMessagesChannel + { + get { + return ResourceManager.GetString("SettingsWelcomeMessagesChannel", resourceCulture); + } + } } } diff --git a/src/Responders/GuildMemberJoinedResponder.cs b/src/Responders/GuildMemberJoinedResponder.cs index eee93b6..012bfad 100644 --- a/src/Responders/GuildMemberJoinedResponder.cs +++ b/src/Responders/GuildMemberJoinedResponder.cs @@ -51,7 +51,7 @@ public class GuildMemberJoinedResponder : IResponder return Result.FromError(returnRolesResult.Error); } - if (GuildSettings.PublicFeedbackChannel.Get(cfg).Empty() + if (GuildSettings.WelcomeMessagesChannel.Get(cfg).Empty() || GuildSettings.WelcomeMessage.Get(cfg) is "off" or "disable" or "disabled") { return Result.FromSuccess(); @@ -76,7 +76,7 @@ public class GuildMemberJoinedResponder : IResponder .Build(); return await _channelApi.CreateMessageWithEmbedResultAsync( - GuildSettings.PublicFeedbackChannel.Get(cfg), embedResult: embed, + GuildSettings.WelcomeMessagesChannel.Get(cfg), embedResult: embed, allowedMentions: Octobot.NoMentions, ct: ct); }