public override void Initialize() { AssertPermission(GuildPermission.ManageChannels); _commandSet = new VoiceNameSet { ParentPlugin = this }; GuildHandler.ChannelCreated += OnChannelCreated; GuildHandler.ChannelDestroyed += OnChannelDestroyed; GuildHandler.UserVoiceStateUpdated += OnVoiceStateUpdated; GuildHandler.GuildMemberUpdated += OnGuildMemberUpdated; GuildHandler.ChannelUpdated += OnChannelUpdated; InitDefaultTags(); _channelNames = GetConfigCache("ChannelNames", x => x.GetGuild().VoiceChannels.ToDictionary(y => y.Id, z => z.Name)); _channelNames.Store(); _toIgnore = GetConfigCache("ToIgnore", x => new List <ulong> { (x.GetGuild().AFKChannel?.Id).GetValueOrDefault() }); _musicBotId = GetConfigCache("MusicBotId", x => (ulong)0); _internationalRoleId = GetConfigCache("MusicBotId", x => (ulong)0); _nameFormat = GetConfigCache("NameFormat", x => $"{_formatStart}{_formatNameStr}{_formatEnd} - {_formatStart}{_formatGameStr}{_formatEnd} {_formatStart}({_formatAmountPlayersStr}){_formatEnd}"); // lol _shortenedGameNames = GetConfigCache("ShortenedGameNames", x => new Dictionary <string, string>()); AddConfigInfo("Set Channel Name", "Display channel names", () => "Current channel names:\n" + string.Join('\n', _channelNames.GetValue().Select(x => x.Value).ToArray())); AddConfigInfo <SocketVoiceChannel, string>("Set Channel Name", "Set channel name", (x, y) => _channelNames.MutateValue(z => z[x.Id] = y), (success, x, y) => $"Succesfully set channel '{x.Name}' to '{y}'", "Channel", "New name"); AddConfigInfo <string, string>("Set Channel Name", "Set channel name", (x, y) => _channelNames.MutateValue(z => z[GuildHandler.GetVoiceChannel(x).Id] = y), (success, x, y) => "Succesfully set channel names.", "Channel", "New name"); AddConfigInfo <SocketVoiceChannel>("Dont Name Channel", "Ignore channel", x => _toIgnore.MutateValue(y => y.Add(x.Id)), (success, x) => $"Added channel '{x.Name}' to list of ignored channels.", "Channel"); AddConfigInfo <ulong>("Dont Name Channel", "Ignore channel", x => _toIgnore.MutateValue(y => y.Add(GuildHandler.GetVoiceChannel(x).Id)), (success, x) => $"Added channel '{GuildHandler.GetVoiceChannel (x).Name}' to list of ignored channels.", "ignored"); AddConfigInfo <string>("Dont Name Channel", "Ignore channel", x => _toIgnore.MutateValue(y => y.Add(GuildHandler.GetVoiceChannel(x).Id)), (success, x) => $"Added channel '{GuildHandler.GetVoiceChannel(x).Name}' to list of ignored channels.", "Channel"); AddConfigInfo <SocketVoiceChannel>("Do Name Channel", "Unignore channel", x => _toIgnore.MutateValue(y => y.Remove(x.Id)), (success, x) => $"Removed channel '{x.Name}' from list of ignored.", "Channel"); AddConfigInfo <ulong>("Do Name Channel", "Unignore channel", x => _toIgnore.MutateValue(y => y.Remove(GuildHandler.GetVoiceChannel(x).Id)), (success, x) => $"Removed channel '{GuildHandler.GetChannel(x)}' from list of ignored.", "Channel"); AddConfigInfo <string>("Do Name Channel", "Unignore channel", x => _toIgnore.MutateValue(y => y.Remove(GuildHandler.GetVoiceChannel(x).Id)), (success, x) => $"Removed channel '{GuildHandler.GetChannel(x)}' from list of ignored.", "Channel"); AddConfigInfo <SocketGuildUser>("Set Music Bot", "Set music bot.", x => _musicBotId.SetValue(x.Id), (success, x) => $"Set music bot to be {x.Id}.", "Music Bot"); AddConfigInfo <string>("Set Music Bot", "Set music bot.", x => _musicBotId.SetValue(GuildHandler.GetUser(x).Id), (success, x) => $"Set music bot to be {GuildHandler.GetUser(x).GetShownName()}.", "Music Bot"); AddConfigInfo("Set Music Bot", "Show music bot.", () => GuildHandler.FindUser(_musicBotId.GetValue()) == null ? "Current music bot doesn't exist :(" : "Current music bot is " + GuildHandler.GetUser(_musicBotId.GetValue()).GetShownName()); AddConfigInfo <SocketRole>("Set International Role", "Set role.", x => _internationalRoleId.SetValue(x.Id), (success, x) => $"Set international role to be {x}.", "Role"); AddConfigInfo <string>("Set International Role", "Set role.", x => _internationalRoleId.SetValue(GuildHandler.GetRole(x).Id), (success, x) => $"Set international role to be {GuildHandler.GetRole(x).Name}.", "Role Name"); AddConfigInfo("Set International Role", "Show role.", () => GuildHandler.FindRole(_internationalRoleId.GetValue()) == null ? "Current international role doesn't exist :(" : "Current international role is " + GuildHandler.GetRole(_internationalRoleId.GetValue()).Name); AddConfigInfo("Set Name Format", "Set format", () => $"Current format is '{_nameFormat.GetValue()}' which might look like this in practice: '{FormatName(_nameFormat.GetValue(), _formatStart, _formatEnd, "General 1", "Cool Game 3: The Coolest", 5)}'."); AddConfigInfo <string>("Set Name Format", "Set format", x => _nameFormat.SetValue(x), (success, x) => $"Set format to '{x}' which might look like this in practice: '{FormatName(x, _formatStart, _formatEnd, "General 1", "Cool Game 3: The Coolest", 5)}'.", "Format"); AddConfigInfo <string, string>("Shorten Game Name", "Shorten a games name", (x, y) => SetShortenedGameName(x, y), (success, x, y) => $"'{x}' will now be shortened to '{y}'.", "Game", "Name"); SendMessage("Moduthulhu-Command Root", "AddCommand", _commandSet); AddGeneralFeaturesStateAttribute("AutomatedVoiceNames", "Automatically changing voice channel names to reflect games played within."); RegisterMessageAction("AddTag", x => AddTag(new Tag((string)x[0], (string)x[1], (Func <SocketVoiceChannel, bool>)x[2]))); RegisterMessageAction("RemoveTag", x => RemoveTag((string)x[0])); SetStateChangeHeaders("Tags", "The following voice channel tags has been added", "The following voice channel tags has been removed", "The following voice channel tags has been modified"); RegisterMessageAction("UpdateChannel", x => UpdateChannel(GuildHandler.GetVoiceChannel((ulong)x[0])).ConfigureAwait(false)); }
private List <ulong> _temporaryChannels; // This isn't for config, but instead for keeping track of the active channels. public override void Initialize() { AssertPermission(Discord.GuildPermission.ManageChannels); GuildHandler.UserVoiceStateUpdated += UserVoiceStateUpdated; GuildHandler.ChannelCreated += OnChannelCreated; GuildHandler.ChannelDestroyed += OnChannelDeleted; _defaultChannels = GetConfigCache("DefaultVoiceChannels", x => x.GetGuild().VoiceChannels.Select(y => y.Id).ToList()); _newVoiceNames = GetConfigCache("NewVoiceNames", x => new List <string> { "Extra Voice 1", "Extra Voice 2" }); _desiredFreeChannels = GetConfigCache("DesiredFreeChannels", x => 1); _ignoreChannels = GetConfigCache("IgnoreChannels", x => new List <ulong> { x.GetGuild().AFKChannel.ZeroIfNull() }); _newChannelCategory = GetConfigCache("NewChannelCategory", x => (ulong)x.GetGuild().VoiceChannels.FirstOrDefault()?.CategoryId.GetValueOrDefault()); _newVoiceNames.OnModified += NewVoiceName_OnModified; AddConfigInfo <SocketVoiceChannel>("Add Default Channel", "Add default channel", x => _defaultChannels.MutateValue(y => y.Add(x.Id)), x => $"Added channel '{x.Name}' to list of default.", "Channel"); AddConfigInfo <ulong>("Add Default Channel", "Add default channel", x => _defaultChannels.MutateValue(y => y.Add(GuildHandler.GetVoiceChannel(x).Id)), x => $"Added channel '{GuildHandler.GetVoiceChannel(x).Name}' to list of default.", "Channel"); AddConfigInfo <string>("Add Default Channel", "Add default channel", x => _defaultChannels.MutateValue(y => y.Add(GuildHandler.GetVoiceChannel(x).Id)), x => $"Added channel '{GuildHandler.GetVoiceChannel(x).Name}' to list of default.", "Channel"); AddConfigInfo("Add Default Channel", "List default channels", () => "Current default channels are:\n" + string.Join('\n', _defaultChannels.GetValue().Select(x => GuildHandler.GetVoiceChannel(x).Name))); AddConfigInfo <SocketVoiceChannel>("Remove Default Channel", "Remove default channel", x => _defaultChannels.MutateValue(y => y.Remove(x.Id)), x => $"Removed channel '{x.Name}' from list of default.", "Channel"); AddConfigInfo <ulong>("Remove Default Channel", "Remove default channel", x => _defaultChannels.MutateValue(y => y.Remove(GuildHandler.GetVoiceChannel(x).Id)), x => $"Removed channel '{GuildHandler.GetVoiceChannel(x).Name}' from list of default.", "Channel"); AddConfigInfo <string>("Remove Default Channel", "Remove default channel", x => _defaultChannels.MutateValue(y => y.Remove(GuildHandler.GetVoiceChannel(x).Id)), x => $"Removed channel '{GuildHandler.GetVoiceChannel(x).Name}' from list of default.", "Channel"); AddConfigInfo <string>("Add Voice Name", "Add voice name", x => _newVoiceNames.MutateValue(y => y.Add(x)), x => $"Added '{x}' name to list of possible options.", "Name"); AddConfigInfo("Add Voice Name", "List voice names", () => "Current possible extra voice names:\n " + string.Join('\n', _newVoiceNames.GetValue())); AddConfigInfo <string>("Remove Voice Name", "Remove voice name", x => _newVoiceNames.MutateValue(y => y.Remove(x)), x => $"Removed '{x}' name from list of possible options.", "Name"); AddConfigInfo <int>("Set Desired Free Channels", "Set desired amount", x => _desiredFreeChannels.SetValue(x), x => $"Set desired amount to {x}", "Amount"); AddConfigInfo("Set Desired Free Channels", "Show desired amount", () => $"Current desired amount is {_desiredFreeChannels.GetValue ()}"); AddConfigInfo <SocketVoiceChannel>("Ignore Channel", "Ignore channel", x => _ignoreChannels.MutateValue(y => y.Add(x.Id)), x => $"Added channel '{x.Name}' to list of ignored.", "Channel"); AddConfigInfo <ulong>("Ignore Channel", "Ignore channel", x => _ignoreChannels.MutateValue(y => y.Add(GuildHandler.GetVoiceChannel(x).Id)), x => $"Added channel '{GuildHandler.GetVoiceChannel(x).Name}' to list of default.", "ignored"); AddConfigInfo <string>("Ignore Channel", "Ignore channel", x => _ignoreChannels.MutateValue(y => y.Add(GuildHandler.GetVoiceChannel(x).Id)), x => $"Added channel '{GuildHandler.GetVoiceChannel(x).Name}' to list of ignored.", "Channel"); AddConfigInfo <SocketVoiceChannel>("Unignore Channel", "Unignore channel", x => _ignoreChannels.MutateValue(y => y.Remove(x.Id)), x => $"Removed channel '{x.Name}' from list of ignored.", "Channel"); AddConfigInfo <ulong>("Unignore Channel", "Unignore channel", x => _ignoreChannels.MutateValue(y => y.Remove(GuildHandler.GetVoiceChannel(x).Id)), x => $"Removed channel '{GuildHandler.GetVoiceChannel(x).Name}' from list of ignored.", "Channel"); AddConfigInfo <string>("Unignore Channel", "Unignore channel", x => _ignoreChannels.MutateValue(y => y.Remove(GuildHandler.GetVoiceChannel(x).Id)), x => $"Removed channel '{GuildHandler.GetVoiceChannel(x).Name}' from list of ignored.", "Channel"); AddConfigInfo <SocketCategoryChannel>("Set New Channel Category", "Set category", x => _newChannelCategory.SetValue(x.Id), x => $"Set category where new channels will be created to {x.Name}", "Channel"); AddConfigInfo <ulong>("Set New Channel Category", "Set category", x => _newChannelCategory.SetValue(GuildHandler.GetCategoryChannel(x).Id), x => $"Set category where new channels will be created to {GuildHandler.GetCategoryChannel(x).Name}", "Channel"); AddConfigInfo <string>("Set New Channel Category", "Set category", x => _newChannelCategory.SetValue(GuildHandler.GetCategoryChannel(x).Id), x => $"Set category where new channels will be created to {GuildHandler.GetCategoryChannel(x).Name}", "Channel"); AddConfigInfo("Set New Channel Category", "Get category", () => $"New channels will currently be created in category {GuildHandler.GetCategoryChannel(_newChannelCategory.GetValue()).Name}"); }
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."); }
private void PurgeDuplicateEnabledPlugins() { List <string> value = _enabledPlugins.GetValue(); List <string> newValue = new List <string>(value); for (int x = 0; x < value.Count; x++) { for (int y = 0; y < value.Count; y++) { if (x == y) { continue; } string xx = value[x]; string yy = value[y]; string shortest = xx.Length > yy.Length ? yy : xx; string longest = xx.Length > yy.Length ? xx : yy; if (longest.StartsWith(shortest, StringComparison.Ordinal)) { newValue.Remove(longest); Log.Write(Log.Type.PLUGIN, $"Purged duplicate {shortest} plugin in enabled list."); } } } if (value.Count != newValue.Count) { _enabledPlugins.SetValue(newValue); } }
public override void Initialize() { if (!IsInNovember(DateTime.Now)) { throw new NotNovemberException("I can only nut during november, the one month where one must not nut."); } _chanceStartDay = GetConfigCache("ChanceStartDay", x => 10); _chanceStartPercent = GetConfigCache("ChanceStartPercent", x => 10f); _chancePerDayPercent = GetConfigCache("ChancePerDayPercent", x => 5f); _refractoryPeriod = GetConfigCache("RefractoryPeriod", x => 60 * 60 * 2); // two hours. _nutters = GetDataCache("Nutters", x => new List <ulong>()); AddConfigInfo <int>("setchancestartday", "", (x) => _chanceStartDay.SetValue(x), (success, x) => $"Start day set to day {x}.", "day"); AddConfigInfo <float>("setchancestartpercent", "", (x) => _chanceStartPercent.SetValue(x), (success, x) => $"Starting chance after starting day set to {x}%", "chance"); AddConfigInfo <float>("setchanceperday", "", (x) => _chancePerDayPercent.SetValue(x), (success, x) => $"Chance per day after starting day set to {x}%", "chance per day"); AddConfigInfo <int>("setrefractoryperiod", "", (x) => _refractoryPeriod.SetValue(x), (success, x) => $"Refractory period set to {x} seconds.", "seconds"); GuildHandler.Clock.OnDayPassed += CheckDate; _nutCommand = new NutCommand() { ParentPlugin = this }; SendMessage("Moduthulhu-Command Root", "AddCommand", _nutCommand); }
public override void Initialize() { cmd = new UrbanDefineCommand { ParentPlugin = this }; SendMessage("Moduthulhu-Command Root", "AddCommand", cmd); _enableHyperlinkReactions = GetConfigCache("EnableHyperlinkReactions", x => false); AddConfigInfo("Toggle Hyperlink Reactions", "Toggle reactions", () => _enableHyperlinkReactions.SetValue(!_enableHyperlinkReactions.GetValue()), (success) => _enableHyperlinkReactions.GetValue() ? "Hyperlink reactions has been enabled." : "Hyperlink reactions has been disabled."); GuildHandler.ReactionAdded += GuildHandler_ReactionAdded; }
public override void Initialize() { GuildHandler.UserJoined += GuildHandler_UserJoined; PopulateReferenceFunctions(); _title = GetConfigCache("Title", x => "Welcome to [ServerName]!"); _description = GetConfigCache("Description", x => "Hello [Joinee]! You have been invited and thus completely voluntarily joined [ServerName], and we are absolutely thrilled to have you here! There is absolutely no reason to believe any memetic hazards to have been at play!"); _url = GetConfigCache <string>("Url", x => null); _colourHex = GetConfigCache("Colour", x => "08F26E"); _iconUrl = GetConfigCache("IconUrl", x => "[ServerIconUrl]"); _author = GetConfigCache("Author", x => new EmbedAuthor(GuildHandler.BotUser.GetShownName(), null, GuildHandler.BotUser.GetAvatarUrl())); _fields = GetConfigCache("Fields", x => new List <FieldData>()); _footerText = GetConfigCache("Footer", x => "[DateNow]"); _command = new DemoWelcomeMessageCommand { ParentPlugin = this }; SendMessage("Moduthulhu-Command Root", "AddCommand", _command); AddConfigInfo <string>("Set Welcome Title", "Set title", x => _title.SetValue(x), (success, x) => $"Welcome message title has been set to '{x}'.", "Title"); AddConfigInfo <string>("Set Welcome Description", "Set description", x => _description.SetValue(x), (success, x) => $"Welcome message description has been set to '{x}'.", "Description"); AddConfigInfo <string>("Set Welcome Url", "Set url", x => _url.SetValue(x), (success, x) => $"Welcome message url has been set to '{x}'.", "Url"); AddConfigInfo <string>("Set Welcome Colour", "Set color (hex)", x => _colourHex.SetValue(x), (success, x) => $"Welcome message colour has been set to '#{x}'.", "Colour (hex)"); AddConfigInfo <string>("Set Welcome Icon Url", "Set icon url", x => _iconUrl.SetValue(x), (success, x) => $"Welcome message icon url has been set to '{x}'.", "Icon Url"); AddConfigInfo <string>("Set Welcome Footer", "Set footer", x => _footerText.SetValue(x), (success, x) => $"Welcome message footer has been set to '{x}'.", "Footer"); AddConfigInfo <string, string>("Add Welcome Field", "Add field", (x, y) => _fields.MutateValue(z => z.Add(new FieldData(x, y, false))), (success, x, y) => $"Added field with title '{x}' and value '{y}'", "Title", "Value"); AddConfigInfo <string, string, bool>("Add Welcome Field", "Add field", (x, y, z) => _fields.MutateValue(w => w.Add(new FieldData(x, y, z))), (success, x, y, z) => $"Added field with title '{x}' and value '{y}' that is inline: {z}", "Title", "Value", "Inline"); AddConfigInfo("Add Welcome Field", "Add field", () => $"Current fields in the welcome message embed:{string.Join ("\n", _fields.GetValue ().Select (x => $"**{x.Name}**\n{x.Value}"))}"); AddConfigInfo <string>("Remove Welcome Field", "Remove field", x => _fields.MutateValue(y => y.RemoveAll(z => z.Name == x)), (success, x) => $"Removed any fields with the title '{x}'.", "Title"); AddConfigInfo <IUser>("Set Welcome Author", "Set Author", x => _author.SetValue(new EmbedAuthor(x.GetShownName(), null, x.GetAvatarUrl())), (success, x) => $"Set welcome message author to {x.GetShownName ()}.", "User"); AddConfigInfo <string>("Set Welcome Author", "Set Author", x => _author.SetValue(new EmbedAuthor(x, null, null)), (success, x) => $"Set welcome message author to '{x}'.", "Author Name"); AddConfigInfo <string, string>("Set Welcome Author", "Set Author", (x, y) => _author.SetValue(new EmbedAuthor(x, null, y)), (success, x, y) => $"Set welcome message author to '{x}' with icon url '{y}'.", "Author Name", "Author Icon Url"); AddConfigInfo <string, string, string>("Set Welcome Author", "Set Author", (x, y, z) => _author.SetValue(new EmbedAuthor(x, z, y)), (success, x, y, z) => $"Set welcome message author to '{x}' with icon url '{y}' and url to {z}.", "Author Name", "Author Icon Url", "Author Url"); }
public override void Initialize() { _command = new SetColour { ParentPlugin = this }; GuildHandler.UserJoined += OnUserJoined; SendMessage("Moduthulhu-Command Root", "AddCommand", _command); _colourRolePrefix = GetConfigCache("ColourRolePrefix", x => "cl_"); _colourOnJoin = GetConfigCache("ColourOnJoin", x => false); AddConfigInfo <string>("Set Colour Prefix", "Set colour prefix", x => _colourRolePrefix.SetValue(x), (success, x) => $"Set colour prefix to '{x}'", "Prefix"); AddConfigInfo("Set Colour Prefix", "Get colour prefix", () => $"Current colour prefix is '{_colourRolePrefix.GetValue()}'."); AddConfigInfo("Colour on Join", "Colour on join?", () => _colourOnJoin.SetValue(!_colourOnJoin.GetValue()), (success) => _colourOnJoin.GetValue() ? $"New members now be automatically given a random available colour on join." : $"New members will no longer be coloured on join."); }
public GuildNotifier(GuildHandler parentGuild) { _parentGuild = parentGuild; _notificationChannel = new CachedValue <ulong>( new DoubleKeyJsonRepository("pluginconfig"), _parentGuild.GuildId, "NotificationChannel", () => (_parentGuild.GetGuild().TextChannels.FirstOrDefault()?.Id).GetValueOrDefault()); _allowNotifications = new CachedValue <bool>( new DoubleKeyJsonRepository("pluginconfig"), _parentGuild.GuildId, "AllowNotifications", () => true); _parentGuild.Config.Add("Set Notification Channel", "Set channel", "Universal Settings", new Action <SocketTextChannel>(x => _notificationChannel.SetValue(x.Id)), new Func <SocketTextChannel, string>(x => $"Set notification channel to {x.Mention}"), "Channel"); _parentGuild.Config.Add("Set Notification Channel", "Set channel", "Universal Settings", new Action(() => { }), new Func <string>( () => $"Current notification channel is {GetNotificationChannelName()}")); _parentGuild.Config.Add("Toggle Notifications", "Toggle notications", "Universal Settings", new Action(() => _allowNotifications.SetValue(!_allowNotifications.GetValue())), new Func <string>( () => _allowNotifications.GetValue() ? "You have opted in to bot notifications." : "You have opted out of bot notifications.")); }
public override void Initialize() { GuildHandler.ReactionAdded += OnReactionAdded; GuildHandler.ReactionRemoved += OnReactionRemoved; SendMessage("Lomztein-Command Root", "AddCommand", karmaCommand); karmaCommand.ParentPlugin = this; _upvoteEmoteId = GetConfigCache("UpvoteEmoteId", x => x.GetGuild().Emotes.Where(y => y.Name == "upvote").FirstOrDefault().ZeroIfNull()); _downvoteEmoteId = GetConfigCache("DownvoteEmoteId", x => x.GetGuild().Emotes.Where(y => y.Name == "downvote").FirstOrDefault().ZeroIfNull()); _karma = GetDataCache("Karma", x => new Dictionary <ulong, Selfworth>()); AddConfigInfo("Set Upvote Emote", "Get emote", () => $"Current upvote emote is '{GuildHandler.GetGuild().GetEmoteAsync(_upvoteEmoteId.GetValue()).Result.Name}'."); AddConfigInfo("Set Upvote Emote", "Set emote", new Action <string>(x => _upvoteEmoteId.SetValue((GuildHandler.GetGuild().GetEmoteAsync(_upvoteEmoteId.GetValue()).Result?.Id).GetValueOrDefault())), () => $"Set upvote emote to '{GuildHandler.GetGuild().GetEmoteAsync(_upvoteEmoteId.GetValue()).Result?.Name}'.", "Emote"); AddConfigInfo("Set Downvote Emote", "Get emote", () => $"Current downvote emote is '{GuildHandler.GetGuild().GetEmoteAsync(_downvoteEmoteId.GetValue()).Result.Name}'."); AddConfigInfo("Set Downvote Emote", "Set emote", new Action <string>(x => _downvoteEmoteId.SetValue((GuildHandler.GetGuild().GetEmoteAsync(_downvoteEmoteId.GetValue()).Result?.Id).GetValueOrDefault())), () => $"Set downote emote to '{GuildHandler.GetGuild().GetEmoteAsync(_downvoteEmoteId.GetValue()).Result?.Name}'.", "Emote"); }
public override void Initialize() { GuildHandler.ReactionAdded += OnReactionAdded; GuildHandler.ReactionRemoved += OnReactionRemoved; _karmaCommand = new KarmaCommandSet { ParentPlugin = this }; SendMessage("Moduthulhu-Command Root", "AddCommand", _karmaCommand); _upvoteEmoteId = GetConfigCache("UpvoteEmoteId", x => x.GetGuild().Emotes.Where(y => y.Name == "upvote").FirstOrDefault().ZeroIfNull()); _downvoteEmoteId = GetConfigCache("DownvoteEmoteId", x => x.GetGuild().Emotes.Where(y => y.Name == "downvote").FirstOrDefault().ZeroIfNull()); AddConfigInfo("Set Upvote Emote", "Get emote", () => $"Current upvote emote is '{GuildHandler.GetGuild().GetEmoteAsync(_upvoteEmoteId.GetValue()).Result.Name}'."); AddConfigInfo <string>("Set Upvote Emote", "Set emote", x => _upvoteEmoteId.SetValue((GuildHandler.GetGuild().GetEmoteAsync(_upvoteEmoteId.GetValue()).Result?.Id).GetValueOrDefault()), (success, x) => $"Set upvote emote to '{x}'.", "Emote"); AddConfigInfo("Set Downvote Emote", "Get emote", () => $"Current downvote emote is '{GuildHandler.GetGuild().GetEmoteAsync(_downvoteEmoteId.GetValue()).Result.Name}'."); AddConfigInfo <string>("Set Downvote Emote", "Set emote", x => _downvoteEmoteId.SetValue((GuildHandler.GetGuild().GetEmoteAsync(_downvoteEmoteId.GetValue()).Result?.Id).GetValueOrDefault()), (success, x) => $"Set downote emote to '{x}'.", "Emote"); AddGeneralFeaturesStateAttribute("Karma", "Tracking of total upvotes / downvotes per user."); }
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() { commandSet = new VoiceNameSet() { ParentPlugin = this }; GuildHandler.ChannelCreated += OnChannelCreated; GuildHandler.ChannelDestroyed += OnChannelDestroyed; GuildHandler.UserVoiceStateUpdated += OnVoiceStateUpdated; GuildHandler.GuildMemberUpdated += OnGuildMemberUpdated; InitDefaultTags(); _channelNames = GetConfigCache("ChannelNames", x => x.GetGuild().VoiceChannels.ToDictionary(y => y.Id, z => z.Name)); _toIgnore = GetConfigCache("ToIgnore", x => new List <ulong>() { (x.GetGuild().AFKChannel?.Id).GetValueOrDefault() }); //_nameFormat = GetConfigCache("NameFormat", x => "[TAGS][NAME] - [GAME]"); _musicBotId = GetConfigCache("MusicBotId", x => (ulong)0); _internationalRoleId = GetConfigCache("MusicBotId", x => (ulong)0); AddConfigInfo("Set Channel Name", "Display channel names", () => "Current channel names:\n" + string.Join('\n', _channelNames.GetValue().Select(x => x.Value).ToArray())); AddConfigInfo("Set Channel Name", "Set channel name", new Action <SocketVoiceChannel, string>((x, y) => _channelNames.MutateValue(z => z[x.Id] = y)), () => "Succesfully set channel names.", "Channel", "New name"); AddConfigInfo("Set Channel Name", "Set channel name", new Action <string, string>((x, y) => _channelNames.MutateValue(z => z[GuildHandler.FindVoiceChannel(x).Id] = y)), () => "Succesfully set channel names.", "Channel", "New name"); AddConfigInfo("Dont Name Channel", "Ignore channel", new Action <SocketVoiceChannel>((x) => _toIgnore.MutateValue(y => y.Add(x.Id))), () => "Added channel to list of ignored.", "Channel"); AddConfigInfo("Dont Name Channel", "Ignore channel", new Action <ulong>((x) => _toIgnore.MutateValue(y => y.Add(x))), () => "Added channel to list of default.", "ignored"); AddConfigInfo("Dont Name Channel", "Ignore channel", new Action <string>((x) => _toIgnore.MutateValue(y => y.Add(GuildHandler.FindVoiceChannel(x).Id))), () => "Added channel to list of ignored.", "Channel"); AddConfigInfo("Do Name Channel", "Unignore channel", new Action <SocketVoiceChannel>((x) => _toIgnore.MutateValue(y => y.Remove(x.Id))), () => "Removed channel from list of ignored.", "Channel"); AddConfigInfo("Do Name Channel", "Unignore channel", new Action <ulong>((x) => _toIgnore.MutateValue(y => y.Remove(x))), () => "Removed channel from list of ignored.", "Channel"); AddConfigInfo("Do Name Channel", "Unignore channel", new Action <string>((x) => _toIgnore.MutateValue(y => y.Remove(GuildHandler.FindVoiceChannel(x).Id))), () => "Removed channel from list of ignored.", "Channel"); AddConfigInfo("Set Music Bot", "Set music bot.", new Action <SocketGuildUser>((x) => _musicBotId.SetValue(x.Id)), () => $"Set music bot to be {GuildHandler.GetUser(_musicBotId.GetValue()).GetShownName()}.", "Music Bot"); AddConfigInfo("Set Music Bot", "Set music bot.", new Action <string>((x) => _musicBotId.SetValue(GuildHandler.FindUser(x).Id)), () => $"Set music bot to be {GuildHandler.GetUser(_musicBotId.GetValue()).GetShownName()}.", "Music Bot"); AddConfigInfo("Set Music Bot", "Show music bot.", () => GuildHandler.GetUser(_musicBotId.GetValue()) == null ? "Current music bot doesn't exist :(" : "Current music bot is " + GuildHandler.GetUser(_musicBotId.GetValue()).GetShownName()); AddConfigInfo("Set International Role", "Set role.", new Action <SocketRole>((x) => _internationalRoleId.SetValue(x.Id)), () => $"Set international role to be {GuildHandler.GetRole(_internationalRoleId.GetValue()).Name}.", "Role"); AddConfigInfo("Set International Role", "Set role.", new Action <string>((x) => _internationalRoleId.SetValue(GuildHandler.FindRole(x).Id)), () => $"Set international role to be {GuildHandler.GetRole(_internationalRoleId.GetValue()).Name}.", "Role Name"); AddConfigInfo("Set International Role", "Show role.", () => GuildHandler.GetRole(_internationalRoleId.GetValue()) == null ? "Current international role doesn't exist :(" : "Current international role is " + GuildHandler.GetRole(_internationalRoleId.GetValue()).Name); SendMessage("Lomztein-Command Root", "AddCommand", commandSet); }
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), 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), x => $"Channel channel set to {GuildHandler.GetTextChannel(x).Mention}.", "Channel Id"); AddConfigInfo <SocketTextChannel>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(x.Id), 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), 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."); }
private void ResetNotificationChannel() => _notificationChannel.SetValue((_parentGuild.GetGuild().TextChannels.FirstOrDefault()?.Id).GetValueOrDefault());
public override void Initialize() { InitConverters(_converters); _chanceToAutoConvert = GetConfigCache("ChanceToAutoConvert", x => 1d); AddConfigInfo <double>("chancetoautoconvert", "Auto conversion chance", x => _chanceToAutoConvert.SetValue(x), (success, chance) => "Auto conversion chance set to " + chance, "chance"); GuildHandler.MessageReceived += OnMessageRecieved; _command = new ConvertCommand() { ParentPlugin = this }; SendMessage("Moduthulhu-Command Root", "AddCommand", _command); }