public string ToString(GuildHandler guildHandler) { return($"Trigger: {Trigger}, " + "User: "******"Any" : guildHandler.GetUser(UserId).GetShownName()) + ", " + "Channel: " + (guildHandler.FindTextChannel(ChannelId) == null ? "Any" : guildHandler.FindTextChannel(ChannelId).Name) + ", " + $"Chance: {Math.Round(Chance, 2)}%, Response: {Response}, Emote: {Emoji}"); }
public override void Initialize() { GuildHandler.JoinedGuild += OnJoinedNewGuild; GuildHandler.UserJoined += OnUserJoinedGuild; GuildHandler.UserLeft += OnUserLeftGuild; GuildHandler.UserBanned += OnUserBannedFromGuild; GuildHandler.UserUnbanned += OnUserUnbannedFromGuild; GuildHandler.GuildMemberUpdated += OnGuildMemberUpdated; _channelId = GetConfigCache("MessageChannelID", x => x.GetGuild().TextChannels.FirstOrDefault().ZeroIfNull()); _onJoinedNewGuild = GetConfigCache("OnJoinedNewGuild", x => new List <string> { "**[BOTNAME]** here, arrived ready and primed to crash at inoppertune times!" }); _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(_onJoinedNewGuild, "On Bot Joined"); AddConfigInfoForMessage(_onUserJoinedGuild, "On New Member"); AddConfigInfoForMessage(_onUserJoinedGuildByInvite, "On New Member Inviteds"); AddConfigInfoForMessage(_onUserLeftGuild, "On Member Left"); AddConfigInfoForMessage(_onUserBannedFromGuild, "On Member Banned"); AddConfigInfoForMessage(_onUserUnbannedFromGuild, "On Member Unbanned"); AddConfigInfoForMessage(_onUserNameChanged, "On Name Changed"); AddConfigInfo("Set Message Channel", "Set channel", new Action <int, SocketTextChannel>((x, y) => _channelId.SetValue(y.Id)), () => $"Message channel set to {GuildHandler.GetTextChannel(_channelId.GetValue ()).Name}", "Index", "Channel"); AddConfigInfo("Set Message Channel", "Set channel", new Action <int, ulong>((x, y) => _channelId.SetValue(y)), () => $"Message channel set to {GuildHandler.GetTextChannel(_channelId.GetValue()).Name}", "Index", "Channel"); AddConfigInfo("Set Message Channel", "Set channel", new Action <int, string>((x, y) => _channelId.SetValue(GuildHandler.FindTextChannel(y).Id)), () => $"Message channel set to {GuildHandler.GetTextChannel(_channelId.GetValue()).Name}", "Index", "Channel"); _inviteHandler = new InviteHandler(GuildHandler); _ = _inviteHandler.Intialize().ConfigureAwait(false); }
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!"); // TODO: Implement some basic error handling, such as what happens if you provide it with a non-existing channel. AddConfigInfo("Set Birthday Channel", "Set announcement channel.", new Action <string>(x => _announcementChannel.SetValue(GuildHandler.FindTextChannel(x).Id)), () => $"Channel channel set to {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.", "Channel Name"); AddConfigInfo("Set Birthday Channel", "Set announcement channel.", new Action <ulong>(x => _announcementChannel.SetValue(x)), () => $"Channel channel set to {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.", "Channel Id"); AddConfigInfo("Set Birthday Channel", "Set announcement channel.", new Action <SocketTextChannel>(x => _announcementChannel.SetValue(x.Id)), () => $"Channel channel set to {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.", "Channel"); AddConfigInfo("Set Birthday Channel", "Get announcement channel.", () => $"Current announcement channel is {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}."); AddConfigInfo("Set Birthday Message", "Set birthday message.", new Action <string>(x => _announcementMessage.SetValue(x)), () => $"New announcement message: '{_announcementMessage.GetValue()}'.", "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("Lomztein-CommandRoot", "AddCommand", _command); }
public override void Initialize() { GuildHandler.MessageReceived += OnMessageRecieved; _phrases = GetConfigCache("Phrases", x => new List <Phrase>()); #region AddConfigInfo("Add Phrase", "Add empty phrase.", new Action(() => { _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("Remove Phrase", "Remove phrase.", new Action <int>((x) => { _phrases.GetValue().RemoveAt(x); _phrases.Store(); }), () => $"Removed response phrase at the given index.", "Index"); AddConfigInfo("List Phrases", "List current phrases.", () => "Current phrases:\n" + string.Join('\n', _phrases.GetValue().Select(x => _phrases.GetValue().IndexOf(x) + " -> " + PhraseToString(x)))); AddConfigInfo("Set Phrase Trigger", "Set trigger", new Action(() => { _phrases.GetValue().LastOrDefault().triggerPhrase = string.Empty; _phrases.Store(); }), () => $"Phrase trigger reset."); AddConfigInfo("Set Phrase Trigger", "Set trigger", new Action <string>((y) => { _phrases.GetValue().LastOrDefault().triggerPhrase = y; _phrases.Store(); }), () => $"Phrase trigger updated.", "Trigger"); AddConfigInfo("Set Phrase Trigger", "Set trigger", new Action <int>((x) => { _phrases.GetValue()[x].triggerPhrase = string.Empty; _phrases.Store(); }), () => $"Phrase trigger reset.", "Index"); AddConfigInfo("Set Phrase Trigger", "Set trigger", new Action <int, string>((x, y) => { _phrases.GetValue()[x].triggerPhrase = y; _phrases.Store(); }), () => $"Phrase trigger updated.", "Index", "Trigger"); AddConfigInfo("Set Phrase User", "Set user", new Action(() => { _phrases.GetValue().LastOrDefault().userID = 0; _phrases.Store(); }), () => $"Phrase user reset."); AddConfigInfo("Set Phrase User", "Set user", new Action <SocketGuildUser>((y) => { _phrases.GetValue().LastOrDefault().userID = y.Id; _phrases.Store(); }), () => $"Phrase user updated.", "User"); AddConfigInfo("Set Phrase User", "Set user", new Action <string>((y) => { _phrases.GetValue().LastOrDefault().userID = GuildHandler.FindUser(y).Id; _phrases.Store(); }), () => $"Phrase user updated.", "Username"); AddConfigInfo("Set Phrase User", "Set user", new Action <ulong>((y) => { _phrases.GetValue().LastOrDefault().userID = y; _phrases.Store(); }), () => $"Phrase user updated.", "User ID"); AddConfigInfo("Set Phrase User", "Set user", new Action <int>((x) => { _phrases.GetValue()[x].userID = 0; _phrases.Store(); }), () => $"Phrase user reset.", "Index"); AddConfigInfo("Set Phrase User", "Set user", new Action <int, SocketGuildUser>((x, y) => { _phrases.GetValue()[x].userID = y.Id; _phrases.Store(); }), () => $"Phrase user updated.", "Index", "User"); AddConfigInfo("Set Phrase User", "Set user", new Action <int, string>((x, y) => { _phrases.GetValue()[x].userID = GuildHandler.FindUser(y).Id; _phrases.Store(); }), () => $"Phrase user updated.", "Index", "Username"); AddConfigInfo("Set Phrase User", "Set user", new Action <int, ulong>((x, y) => { _phrases.GetValue()[x].userID = y; _phrases.Store(); }), () => $"Phrase user updated.", "Index", "User ID"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action(() => { _phrases.GetValue().LastOrDefault().channelID = 0; _phrases.Store(); }), () => $"Phrase channel reset."); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <SocketTextChannel>((y) => { _phrases.GetValue().LastOrDefault().channelID = y.Id; _phrases.Store(); }), () => $"Phrase channel updated.", "Channel"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <string>((y) => { _phrases.GetValue().LastOrDefault().channelID = GuildHandler.FindTextChannel(y).Id; _phrases.Store(); }), () => $"Phrase channel updated.", "Channel Name"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <ulong>((y) => { _phrases.GetValue().LastOrDefault().channelID = y; _phrases.Store(); }), () => $"Phrase trigger updated.", "Channel ID"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <int>((x) => { _phrases.GetValue()[x].channelID = 0; _phrases.Store(); }), () => $"Phrase channel reset.", "Index"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <int, SocketTextChannel>((x, y) => { _phrases.GetValue()[x].channelID = y.Id; _phrases.Store(); }), () => $"Phrase channel updated.", "Index", "Channel"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <int, string>((x, y) => { _phrases.GetValue()[x].channelID = GuildHandler.FindTextChannel(y).Id; _phrases.Store(); }), () => $"Phrase channel updated.", "Index", "Channel Name"); AddConfigInfo("Set Phrase Channel", "Set channel", new Action <int, ulong>((x, y) => { _phrases.GetValue()[x].channelID = y; _phrases.Store(); }), () => $"Phrase trigger updated.", "Index", "Channel ID"); AddConfigInfo("Set Phrase Chance", "Set chance", new Action(() => { _phrases.GetValue().LastOrDefault().chance = 0; _phrases.Store(); }), () => $"Phrase chance reset."); AddConfigInfo("Set Phrase Chance", "Set chance", new Action <double>((y) => { _phrases.GetValue().LastOrDefault().chance = Math.Clamp(y, 0d, 100d); _phrases.Store(); }), () => $"Phrase chance updated.", "Chance"); AddConfigInfo("Set Phrase Response", "Set response", new Action(() => { _phrases.GetValue().LastOrDefault().response = string.Empty; _phrases.Store(); }), () => $"Phrase response reset."); AddConfigInfo("Set Phrase Response", "Set response", new Action <string>((y) => { _phrases.GetValue().LastOrDefault().response = y; _phrases.Store(); }), () => $"Phrase response updated.", "Response"); AddConfigInfo("Set Phrase Emoji", "Set emoji", new Action(() => { _phrases.GetValue().LastOrDefault().emoji = string.Empty; _phrases.Store(); }), () => $"Phrase Emoji reset."); AddConfigInfo("Set Phrase Emoji", "Set emoji", new Action <string>((y) => { _phrases.GetValue().LastOrDefault().emoji = y; _phrases.Store(); }), () => $"Phrase Emoji updated.", "Emoji"); AddConfigInfo("Set Phrase Chance", "Set chance", new Action <int>((x) => { _phrases.GetValue()[x].chance = 100; _phrases.Store(); }), () => $"Phrase chance reset.", "Index"); AddConfigInfo("Set Phrase Chance", "Set chance", new Action <int, double>((x, y) => { _phrases.GetValue()[x].chance = Math.Clamp(y, 0d, 100d); _phrases.Store(); }), () => $"Phrase chance updated.", "Index", "Chance"); AddConfigInfo("Set Phrase Response", "Set response", new Action <int>((x) => { _phrases.GetValue()[x].response = string.Empty; _phrases.Store(); }), () => $"Phrase response reset.", "Index"); AddConfigInfo("Set Phrase Response", "Set response", new Action <int, string>((x, y) => { _phrases.GetValue()[x].response = y; _phrases.Store(); }), () => $"Phrase response updated.", "Index", "Response"); AddConfigInfo("Set Phrase Emoji", "Set emoji", new Action <int>((x) => { _phrases.GetValue()[x].emoji = string.Empty; _phrases.Store(); }), () => $"Phrase Emoji reset.", "Index"); AddConfigInfo("Set Phrase Emoji", "Set emoji", new Action <int, string>((x, y) => { _phrases.GetValue()[x].emoji = y; _phrases.Store(); }), () => $"Phrase Emoji updated.", "Index", "Emoji"); #endregion }