public override void Initialize() { GuildHandler.UserJoined += OnUserJoinedGuild; GuildHandler.UserLeft += OnUserLeftGuild; GuildHandler.UserBanned += OnUserBannedFromGuild; GuildHandler.UserUnbanned += OnUserUnbannedFromGuild; GuildHandler.GuildMemberUpdated += OnGuildMemberUpdated; _channelId = GetConfigCache("MessageChannelID", x => x.GetGuild().TextChannels.FirstOrDefault().ZeroIfNull()); _onUserJoinedGuild = GetConfigCache("OnUserJoinedGuild", x => new List <string> { "**[USERNAME]** has joined this server!" }); _onUserJoinedGuildByInvite = GetConfigCache("OnUserJoinedNewGuildByInvite", x => new List <string> { "**[USERNAME]** has joined this server through the help of **[INVITERNAME]**!" }); _onUserLeftGuild = GetConfigCache("OnUserLeftGuild", x => new List <string> { "**[USERNAME]** has left this server. :C" }); _onUserBannedFromGuild = GetConfigCache("OnUserBannedFromGuild", x => new List <string> { "**[USERNAME]** has been banned from this server." }); _onUserUnbannedFromGuild = GetConfigCache("OnUserUnbannedFromGuild", x => new List <string> { "**[USERNAME]** has been unbanned from this server!" }); _onUserNameChanged = GetConfigCache("OnUserNameChanged", x => new List <string> { "**[USERNAME] changed their name to **[NEWNAME]**!" }); AddConfigInfoForMessage(_onUserJoinedGuild, "On New Member"); AddConfigInfoForMessage(_onUserLeftGuild, "On Member Left"); AddConfigInfoForMessage(_onUserBannedFromGuild, "On Member Banned"); AddConfigInfoForMessage(_onUserUnbannedFromGuild, "On Member Unbanned"); AddConfigInfoForMessage(_onUserNameChanged, "On Name Changed"); AddConfigInfoForMessage(_onUserJoinedGuildByInvite, "On New Member Invited"); // TODO: Split names and descriptions into seperate methods, and link using an identifier. AddConfigInfo <SocketTextChannel>("Set Message Channel", "Set channel", y => _channelId.SetValue(y.Id), (success, y) => $"Message channel set to {y.Mention}", "Channel"); AddConfigInfo <ulong>("Set Message Channel", "Set channel", y => _channelId.SetValue(GuildHandler.GetTextChannel(y).Id), (success, y) => $"Message channel set to {GuildHandler.GetTextChannel(y).Mention}", "Channel"); AddConfigInfo <string>("Set Message Channel", "Set channel", y => _channelId.SetValue(GuildHandler.GetTextChannel(y).Id), (success, y) => $"Message channel set to {GuildHandler.GetTextChannel(y).Mention}", "Channel"); if (HasPermission(GuildPermission.ManageGuild)) { _inviteHandler = new InviteHandler(GuildHandler); _ = _inviteHandler.Intialize().ConfigureAwait(false); } AddGeneralFeaturesStateAttribute("ServerMessages", "Automated messages when certain server events occur."); }
public override void Initialize() { GuildHandler.MessageReceived += OnMessageRecieved; _phrases = GetConfigCache("Phrases", x => new List <Phrase>()); #region AddConfigInfo("Add Phrase", "Add empty phrase.", () => { _phrases.GetValue().Add(new Phrase()); _phrases.Store(); }, () => $"Added new empty response phrase at index {_phrases.GetValue ().Count - 1}. You must edit it using the other config options available here."); AddConfigInfo <int>("Remove Phrase", "Remove phrase.", x => { _phrases.GetValue().RemoveAt(x); _phrases.Store(); }, x => $"Removed response phrase at the index {x}.", "Index"); AddConfigInfo("List Phrases", "List current phrases.", () => "Current phrases:\n" + string.Join('\n', _phrases.GetValue().Select(x => _phrases.GetValue().IndexOf(x) + " -> " + x.ToString(GuildHandler)))); AddConfigInfo("Set Phrase Trigger", "Set trigger", () => { _phrases.GetValue().LastOrDefault().Trigger = string.Empty; _phrases.Store(); }, () => $"Most recent phrase trigger reset."); AddConfigInfo <string>("Set Phrase Trigger", "Set trigger", y => { _phrases.GetValue().LastOrDefault().Trigger = y; _phrases.Store(); }, y => $"Most recent phrase trigger set to {y}.", "Trigger"); AddConfigInfo <int>("Set Phrase Trigger", "Set trigger", x => { _phrases.GetValue()[x].Trigger = string.Empty; _phrases.Store(); }, x => $"Phrase trigger at index {x} reset.", "Index"); AddConfigInfo <int, string>("Set Phrase Trigger", "Set trigger", (x, y) => { _phrases.GetValue()[x].Trigger = y; _phrases.Store(); }, (x, y) => $"Phrase trigger at index {x} updated to '{y}'.", "Index", "Trigger"); AddConfigInfo("Set Phrase User", "Set user", () => { _phrases.GetValue().LastOrDefault().UserId = 0; _phrases.Store(); }, () => $"Most recent phrase user reset."); AddConfigInfo <SocketGuildUser>("Set Phrase User", "Set user", y => { _phrases.GetValue().LastOrDefault().UserId = y.Id; _phrases.Store(); }, x => $"Most recent phrase user updated to '{x.GetShownName ()}'.", "User"); AddConfigInfo <string>("Set Phrase User", "Set user", y => { _phrases.GetValue().LastOrDefault().UserId = GuildHandler.GetUser(y).Id; _phrases.Store(); }, y => $"Most recent phrase user updated to '{GuildHandler.GetUser (y).GetShownName ()}'.", "Username"); AddConfigInfo <ulong>("Set Phrase User", "Set user", y => { _phrases.GetValue().LastOrDefault().UserId = y; _phrases.Store(); }, y => $"Most recent phrase user updated to '{GuildHandler.GetUser (y).GetShownName ()}.", "User ID"); AddConfigInfo <int>("Set Phrase User", "Set user", x => { _phrases.GetValue()[x].UserId = 0; _phrases.Store(); }, x => $"Phrase user at index {x} reset.", "Index"); AddConfigInfo <int, SocketGuildUser>("Set Phrase User", "Set user", (x, y) => { _phrases.GetValue()[x].UserId = y.Id; _phrases.Store(); }, (x, y) => $"Phrase user at index {x} updated to '{y.GetShownName()}'.", "Index", "User"); AddConfigInfo <int, string>("Set Phrase User", "Set user", (x, y) => { _phrases.GetValue()[x].UserId = GuildHandler.FindUser(y).Id; _phrases.Store(); }, (x, y) => $"Phrase user at index {x} updated to '{GuildHandler.GetUser (y).GetShownName ()}'.", "Index", "Username"); AddConfigInfo <int, ulong>("Set Phrase User", "Set user", (x, y) => { _phrases.GetValue()[x].UserId = y; _phrases.Store(); }, (x, y) => $"Phrase user at index {x} updated to '{GuildHandler.GetUser(y).GetShownName ()}'.", "Index", "User ID"); AddConfigInfo("Set Phrase Channel", "Set channel", () => { _phrases.GetValue().LastOrDefault().ChannelId = 0; _phrases.Store(); }, () => $"Most recent phrase channel reset."); AddConfigInfo <SocketTextChannel>("Set Phrase Channel", "Set channel", y => { _phrases.GetValue().LastOrDefault().ChannelId = y.Id; _phrases.Store(); }, x => $"Most recent phrase channel updated to '{x.Name}'.", "Channel"); AddConfigInfo <string>("Set Phrase Channel", "Set channel", y => { _phrases.GetValue().LastOrDefault().ChannelId = GuildHandler.GetTextChannel(y).Id; _phrases.Store(); }, x => $"Most recent phrase channel updated to '{GuildHandler.GetTextChannel (x).Name}'.", "Channel Name"); AddConfigInfo <ulong>("Set Phrase Channel", "Set channel", y => { _phrases.GetValue().LastOrDefault().ChannelId = y; _phrases.Store(); }, x => $"Most recent phrase channel updated to '{GuildHandler.GetTextChannel (x).Name}'.", "Channel ID"); AddConfigInfo <int>("Set Phrase Channel", "Set channel", x => { _phrases.GetValue()[x].ChannelId = 0; _phrases.Store(); }, x => $"Phrase channel at index {x} reset.", "Index"); AddConfigInfo <int, SocketTextChannel>("Set Phrase Channel", "Set channel", (x, y) => { _phrases.GetValue()[x].ChannelId = y.Id; _phrases.Store(); }, (x, y) => $"Phrase channel at index {x} updated to '{y.Name}'.", "Index", "Channel"); AddConfigInfo <int, string>("Set Phrase Channel", "Set channel", (x, y) => { _phrases.GetValue()[x].ChannelId = GuildHandler.GetTextChannel(y).Id; _phrases.Store(); }, (x, y) => $"Phrase channel at index {x} updated to '{GuildHandler.GetTextChannel(y).Name}'.", "Index", "Channel Name"); AddConfigInfo <int, ulong>("Set Phrase Channel", "Set channel", (x, y) => { _phrases.GetValue()[x].ChannelId = y; _phrases.Store(); }, (x, y) => $"Phrase channel at index {x} '{GuildHandler.GetTextChannel (y)}'.", "Index", "Channel ID"); AddConfigInfo("Set Phrase Chance", "Set chance", () => { _phrases.GetValue().LastOrDefault().Chance = 0; _phrases.Store(); }, () => $"Most recent chance reset."); AddConfigInfo <double>("Set Phrase Chance", "Set chance", y => { _phrases.GetValue().LastOrDefault().Chance = Math.Clamp(y, 0d, 100d); _phrases.Store(); }, y => $"Most recent phrase chance updated to {y}.", "Chance"); AddConfigInfo("Set Phrase Response", "Set response", () => { _phrases.GetValue().LastOrDefault().Response = string.Empty; _phrases.Store(); }, () => $"Most recent phrase response reset."); AddConfigInfo <string>("Set Phrase Response", "Set response", y => { _phrases.GetValue().LastOrDefault().Response = y; _phrases.Store(); }, x => $"Most recent phrase response updated {x}.", "Response"); AddConfigInfo("Set Phrase Emoji", "Set emoji", () => { _phrases.GetValue().LastOrDefault().Emoji = string.Empty; _phrases.Store(); }, () => $"Most recent phrase emoji reset."); AddConfigInfo <string>("Set Phrase Emoji", "Set emoji", y => { _phrases.GetValue().LastOrDefault().Emoji = y; _phrases.Store(); }, x => $"Most recent phrase emoji updated {x}.", "Emoji"); AddConfigInfo <int>("Set Phrase Chance", "Set chance", x => { _phrases.GetValue()[x].Chance = 100; _phrases.Store(); }, x => $"Phrase at index {x} chance reset.", "Index"); AddConfigInfo <int, double>("Set Phrase Chance", "Set chance", (x, y) => { _phrases.GetValue()[x].Chance = Math.Clamp(y, 0d, 100d); _phrases.Store(); }, (x, y) => $"Phrase at index {x} chance updated to {y}.", "Index", "Chance"); AddConfigInfo <int>("Set Phrase Response", "Set response", x => { _phrases.GetValue()[x].Response = string.Empty; _phrases.Store(); }, x => $"Phrase at index {x} response reset.", "Index"); AddConfigInfo <int, string>("Set Phrase Response", "Set response", (x, y) => { _phrases.GetValue()[x].Response = y; _phrases.Store(); }, (x, y) => $"Phrase at index {x} response updated to {y}.", "Index", "Response"); AddConfigInfo <int>("Set Phrase Emoji", "Set emoji", x => { _phrases.GetValue()[x].Emoji = string.Empty; _phrases.Store(); }, x => $"Phrase at index {x} emoji reset.", "Index"); AddConfigInfo <int, string>("Set Phrase Emoji", "Set emoji", (x, y) => { _phrases.GetValue()[x].Emoji = y; _phrases.Store(); }, (x, y) => $"Phrase at index {x} emoji updated to {y}.", "Index", "Emoji"); #endregion AddGeneralFeaturesStateAttribute("AutomatedPhrases", "Automatic response to certain phrases as configured."); }
public override void Initialize() { _announcementChannel = GetConfigCache("AnnouncementChannel", x => x.GetGuild().TextChannels.FirstOrDefault(y => y.Name == "general" || y.Name == "main" || y.Name == "chat").ZeroIfNull()); _announcementMessage = GetConfigCache("AnnouncementMessage", x => "Congratulations to **[USERNAME]** as today they celebrate their [AGE] birthday!"); AddConfigInfo <string>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(GuildHandler.GetVoiceChannel(x).Id), (success, x) => $"Channel channel set to {GuildHandler.GetTextChannel(x).Mention}.", "Channel Name"); AddConfigInfo <ulong>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(GuildHandler.GetVoiceChannel(x).Id), (success, x) => $"Channel channel set to {GuildHandler.GetTextChannel(x).Mention}.", "Channel Id"); AddConfigInfo <SocketTextChannel>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(x.Id), (success, x) => $"Channel channel set to {x.Name}", "Channel"); AddConfigInfo("Set Birthday Channel", "Get announcement channel.", () => $"Current announcement channel is {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}."); AddConfigInfo <string>("Set Birthday Message", "Set birthday message.", x => _announcementMessage.SetValue(x), (success, x) => $"New announcement message: '{x}'.", "Message"); AddConfigInfo("Set Birthday Message", "Get birthday message.", () => $"Current announcement message: '{_announcementMessage.GetValue()}'."); _command = new BirthdayCommand { ParentPlugin = this }; _allBirthdays = GetDataCache("Birthdays", x => new Dictionary <ulong, BirthdayDate>()); GuildHandler.Clock.OnHourPassed += Clock_OnHourPassed; SendMessage("Moduthulhu-Command Root", "AddCommand", _command); AddGeneralFeaturesStateAttribute("BirthdayGreetings", "Automatic birthday wishing if desired."); }