void IModule.Install(ModuleManager manager) { //Initiate variables _manager = manager; _client = manager.Client; //Message received _client.MessageReceived += async (s, e) => { //Delete help requests if (e.Message.Text.StartsWith("!help")) await e.Message.Delete(); }; //User banned _client.UserBanned += async (s, e) => { await e.Server.DefaultChannel.SendMessage($"{e.User.Mention} ({e.User.NickOrName()}) was banned! :skull:"); }; //User joined _client.UserJoined += async (s, e) => { await e.Server.DefaultChannel.SendMessage($"{e.User.Mention} has joined the server! Welcome! :smile: \r\nYou can use !help to know more about my functions! :kissing_heart:"); }; //User left _client.UserLeft += async (s, e) => { await e.Server.DefaultChannel.SendMessage($"{e.User.NickOrName()} has left the server. :cry:"); PointModule.DeleteUser(e.Server, e.User); }; }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; manager.CreateCommands("", group => { //register skip command. group.CreateCommand("rainbow"). Parameter("nothing", ParameterType.Unparsed). Description("Skips the current song in the music queue."). Do(RainbowCommand); }); _colors = new List<ColorDefinition>() { new ColorDefinition("Blue", Color.Blue), new ColorDefinition("Teal", Color.Teal), new ColorDefinition("Gold", Color.Gold), new ColorDefinition("Green", Color.Green), new ColorDefinition("Purple", Color.Purple), new ColorDefinition("Orange", Color.Orange), new ColorDefinition("Magenta", Color.Magenta), new ColorDefinition("Red", Color.Red), new ColorDefinition("DarkBlue", Color.DarkBlue), new ColorDefinition("DarkTeal", Color.DarkTeal), new ColorDefinition("DarkGold", Color.DarkGold), new ColorDefinition("DarkGreen", Color.DarkGreen), new ColorDefinition("DarkMagenta", Color.DarkMagenta), new ColorDefinition("DarkOrange", Color.DarkOrange), new ColorDefinition("DarkPurple", Color.DarkPurple), new ColorDefinition("DarkRed", Color.DarkRed), }; }
void IModule.Install(ModuleManager manager) { manager.CreateCommands("", group => { group.CreateCommand("qupte") .Description("Ruby for f***s sake...") .MinPermissions((int) PermissionLevel.User) .Do(async e => { const string quptePoolDir = Constants.DataFolderDir + @"12\"; if (!Directory.Exists(quptePoolDir)) return; await e.Channel.SendFile(Directory.GetFiles(quptePoolDir).PickRandom()); }); group.CreateCommand("twink") .Description("Moves Rebbit and Crixius to the Portuguese Twink Containment Zone TM (R) (c)") .Do(async e => { Channel channel = e.Server.GetChannel(TwinkChannelId); await MoveToVoice(channel, e.Server.GetUser(CrixiusId), e.Server.GetUser(RebbitId)); }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { commands.ForEach(com => com.Init(cgb)); }); }
public void Install(ModuleManager manager) { _client = manager.Client; manager.CreateCommands("", group => { group.CreateCommand("jobguide") .Description("shows a link to class guides") .Parameter("Job") .Do(async e => { if (e.Args.Length != 1 || string.IsNullOrEmpty(e.Args[0])) { await _client.SendMessage(e.Message.Channel, string.Format("Hi {0}, if you would like to see job guides, please say: !job guide [WHM/ DRK, e.t.c.]", e.Message.User)); } var newsItems = await _botServices.News.GetOrAddNewsItems(new SyndicationSearchFields { Type = SyndicationType.JobGuides, Url = GetJobGuideUrl(e.Args[0]), Take = 3 }); for (int i = 0; i < newsItems.Count(); i++) { await _client.SendMessage(e.Message.Channel, string.Format("\n**{0}.** {1}", i + 1, newsItems.ElementAt(i).ToDiscordMessage())); } }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance); cgb.CreateCommand("~hentai") .Description("Shows a random NSFW hentai image from gelbooru and danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~hentai yuri") .Parameter("tag", ParameterType.Unparsed) .Do(async e => { string tag = e.GetArg("tag"); if (tag == null) tag = ""; await e.Send(":heart: Gelbooru: " + await SearchHelper.GetGelbooruImageLink(tag)); await e.Send(":heart: Danbooru: " + await SearchHelper.GetDanbooruImageLink(tag)); }); cgb.CreateCommand("~danbooru") .Description("Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~danbooru yuri+kissing") .Parameter("tag", ParameterType.Unparsed) .Do(async e => { string tag = e.GetArg("tag"); if (tag == null) tag = ""; await e.Send(await SearchHelper.GetDanbooruImageLink(tag)); }); cgb.CreateCommand("~gelbooru") .Description("Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)\n**Usage**: ~gelbooru yuri+kissing") .Parameter("tag", ParameterType.Unparsed) .Do(async e => { string tag = e.GetArg("tag"); if (tag == null) tag = ""; await e.Send(await SearchHelper.GetGelbooruImageLink(tag)); }); cgb.CreateCommand("~e621") .Description("Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.\n**Usage**: ~e621 yuri kissing") .Parameter("tag", ParameterType.Unparsed) .Do(async e => { string tag = e.GetArg("tag"); if (tag == null) tag = ""; await e.Send(await SearchHelper.GetE621ImageLink(tag)); }); cgb.CreateCommand("~cp") .Description("We all know where this will lead you to.") .Parameter("anything", ParameterType.Unparsed) .Do(async e => { await e.Send("http://i.imgur.com/MZkY1md.jpg"); }); cgb.CreateCommand("~boobs") .Description("Real adult content.") .Do(async e => { try { var obj = JArray.Parse(await SearchHelper.GetResponseAsync($"http://api.oboobs.ru/boobs/{_r.Next(0, 9304)}"))[0]; await e.Send($"http://media.oboobs.ru/{ obj["preview"].ToString() }"); } catch (Exception ex) { await e.Send($"💢 {ex.Message}"); } }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { cgb.AddCheck(PermissionChecker.Instance); commands.ForEach(com => com.Init(cgb)); cgb.CreateCommand(Prefix + "modules") .Alias(".modules") .Description("List all bot modules.") .Do(async e => { await e.Channel.SendMessage("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.Client.GetService<ModuleService>().Modules.Select(m => m.Name))); }); cgb.CreateCommand(Prefix + "commands") .Alias(".commands") .Description("List all of the bot's commands from a certain module.") .Parameter("module", ParameterType.Unparsed) .Do(async e => { var cmds = NadekoBot.Client.GetService<CommandService>().AllCommands .Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower()); var cmdsArray = cmds as Command[] ?? cmds.ToArray(); if (!cmdsArray.Any()) { await e.Channel.SendMessage("That module does not exist."); return; } await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", cmdsArray.Select(c => c.Text))); }); }); }
public void Install(ModuleManager manager) { _client = manager.Client; manager.CreateCommands("", group => { group.CreateCommand("gear") .Description("shows a link to gear and BiS information about a given job") .Parameter("Job") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); group.CreateCommand("garland") .Description("shows a link to gathering information including node spawns") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); group.CreateCommand("chocobo") .Description("shows a link to the chocobo colour calculator") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); group.CreateCommand("tripletriad") .Description("shows a link to the Triple Triad deck manager") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); group.CreateCommand("minions") .Description("shows a link to a player's minion information") .Parameter("Forename") .Parameter("Surname") .Parameter("Server") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); group.CreateCommand("minicactpot") .Description("shows a link to the minicactpot calculator") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); group.CreateCommand("sightseeing") .Description("shows a link to the sightseeing log helper") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Tools.GetUrlFromCommand(e)); }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { cgb.AddCheck(PermissionChecker.Instance); commands.ForEach(c => c.Init(cgb)); }); }
public void Install(ModuleManager manager) { _client = manager.Client; _client.UserJoined += async (s, e) => { var buffer = string.Format("Welcome to '{0}', {1}\n\n", e.Server, Mention.User(e.User)); buffer += _client.Commands().AllCommands.ToDiscordMessage(); await _client.SendPrivateMessage(e.User, buffer); await _client.SendMessage(e.Server.DefaultChannel, string.Format("A wild {0} appears!", Mention.User(e.User))); }; _client.UserLeft += async (s, e) => { await _client.SendMessage(e.Server.DefaultChannel, string.Format("See you soon, {0}!", Mention.User(e.User))); }; _client.ChannelUpdated += async (s, e) => { if (_botServices.Server.ChannelTopicUpdated(e.Channel)) { await _client.SendMessage(e.Channel, string.Format("**Topic Updated**\n'{0}'", e.Channel.Topic)); } }; /*_client.UserPresenceUpdated += async (s, e) => { if (_botServices.Server.UserHasReturned(e.Server, e.User)) { //await _client.SendMessage(e.Server.DefaultChannel, string.Format("Welcome back, {0}!", Mention.User(e.User))); } };*/ _client.ChannelCreated += async (sender, e) => { await _client.SendMessage(e.Server.DefaultChannel, string.Format("**New Channel Created**\n{0}", Mention.Channel(e.Channel))); }; _client.MessageReceived += async (s, e) => { if (e.Message.IsAuthor) return; var reply = _botServices.AI.GetReply(e.Message.Channel, e.Message); if(!string.IsNullOrEmpty(reply)) { await _client.SendMessage(e.Message.Channel, reply); } }; _botServices.Ticker.OnTicked += async (s, e) => { if (_botServices.Ticker.TicksElapsed(e.Ticks, 240)) { await Announce(e); } }; }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = manager.Client; _http = _client.Services.Get<HttpService>(); _settings = _client.Services.Get<SettingsService>() .AddModule<StatusModule, Settings>(manager); manager.CreateCommands("status", group => { group.MinPermissions((int)PermissionLevel.BotOwner); group.CreateCommand("enable") .Parameter("channel", ParameterType.Optional) .Do(async e => { var settings = _settings.Load(e.Server); Channel channel; if (e.Args[0] != "") channel = await _client.FindChannel(e, e.Args[0], ChannelType.Text); else channel = e.Channel; if (channel == null) return; settings.Channel = channel.Id; await _settings.Save(e.Server, settings); await _client.Reply(e, $"Enabled status reports in {channel.Name}"); }); group.CreateCommand("disable") .Do(async e => { var settings = _settings.Load(e.Server); settings.Channel = null; await _settings.Save(e.Server, settings); await _client.Reply(e, "Disabled status reports on this server."); }); }); _client.LoggedIn += (s, e) => { if (!_isRunning) { Task.Run(Run); _isRunning = true; } }; }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; manager.CreateCommands("", group => { //register skip command. group.CreateCommand("uwotm8"). Parameter("nothing", ParameterType.Unparsed). Description("TTS u wot m8."). Do(UWotM8Command); }); }
public void Install(ModuleManager manager) { _client = manager.Client; _client.MessageReceived += async (s, e) => { if (e.Message.IsAuthor) return; await _botServices.Defence.CheckUserSpamming(e.Message.Channel, e.User, e.Message.Timestamp); }; _botServices.Defence.OnUserSpamming += async (s, e) => { _botServices.Defence.AddWarning(e.Channel, e.User); _botServices.Defence.ClearMessages(e.User); await _client.SendMessage(e.Channel, string.Format("Please don't spam the channel, {0}!", Mention.User(e.User))); }; _botServices.Defence.OnUserWarned += async (s, e) => { await _botServices.Karma.AdjustKarma(-1, e.Channel, e.User); if (e.WarningCount >= 2) { await MuteUser(e.Channel.Server, e.Channel, e.User, DateTime.Now.AddMinutes(1)); } }; _botServices.Defence.OnUserPunished += async (s, e) => { switch (e.Punishment.PunishmentType) { case PunishmentType.Mute: await _client.SendMessage(e.Punishment.Channel, string.Format("{0} has been muted for {1} minutes!", Mention.User(e.Punishment.User), (e.Punishment.ExpiresOn - DateTime.Now).Minutes)); break; } }; _botServices.Ticker.OnTicked += async (s, e) => { var expiredPunishments = _botServices.Defence.GetExpiredPunishments(); if (expiredPunishments.Any()) { ReviewExpiredPunishments(expiredPunishments); } }; }
void IModule.Install(ModuleManager manager) { manager.CreateCommands("test", group => { group.MinPermissions((int) PermissionLevel.BotOwner); group.CreateCommand("callback") .Parameter("value", ParameterType.Unparsed) .Do(async e => { await e.Message.Delete(); await e.Channel.SafeSendMessage(e.GetArg("value")); }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance); commands.ForEach(com => com.Init(cgb)); cgb.CreateCommand("$raffle") .Description("Prints a name and ID of a random user from the online list from the (optional) role.") .Parameter("role", ParameterType.Optional) .Do(async e => { var arg = string.IsNullOrWhiteSpace(e.GetArg("role")) ? "@everyone" : e.GetArg("role"); var role = e.Server.FindRoles(arg).FirstOrDefault(); if (role == null) { await e.Channel.SendMessage("💢 Role not found."); return; } var members = role.Members.Where(u => u.Status == Discord.UserStatus.Online); // only online await e.Channel.SendMessage($"**Raffled user:** {members.ToArray()[new System.Random().Next(0, members.Count())].Name}"); }); /* cgb.CreateCommand("$$") .Description("Add moneyz") .Parameter("val", ParameterType.Required) .Do(e => { var arg = e.GetArg("val"); var num = int.Parse(arg); Classes.DBHandler.Instance.InsertData( new Classes._DataModels.CurrencyTransaction { Value = num, Reason = "Money plz", UserId = (long)e.User.Id, }); }); */ cgb.CreateCommand("$$$") .Description("Check how many NadekoFlowers you have.") .Do(async e => { var pts = Classes.DBHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0; string str = $"`You have {pts} NadekoFlowers".SnPl((int)pts)+"`\n"; for (int i = 0; i < pts; i++) { str += "🌸"; } await e.Channel.SendMessage(str); }); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; manager.CreateCommands("colors", group => { //group.SetAlias("colours"); //TODO: add group alias and absolute vs relative alias group.CreateCommand("list") .Description("Gives a list of all available username colors.") .Do(async e => { string text = $"{Format.Bold("Available Colors:")}\n" + string.Join(", ", _colors.Select(x => '`' + x.Name + '`')); await _client.Reply(e, text); }); group.CreateCommand("set") .Parameter("color") .Description("Sets your username to a custom color.") .Do(e => SetColor(e, e.User, e.Args[0])); group.CreateCommand("set") .Parameter("user") .Parameter("color") .MinPermissions((int)PermissionLevel.BotOwner) .Description("Sets another user's name to a custom color.") .Do(e => { User user = e.Server.FindUsers(e.Args[0]).FirstOrDefault(); if (user == null) return _client.ReplyError(e, "Unknown user"); return SetColor(e, user, e.Args[1]); }); group.CreateCommand("clear") .Description("Removes your username color, returning it to default.") .Do(async e => { if (!e.Server.CurrentUser.ServerPermissions.ManageRoles) { await _client.ReplyError(e, "This command requires the bot have Manage Roles permission."); return; } var otherRoles = GetOtherRoles(e.User); await e.User.Edit(roles: otherRoles); await _client.Reply(e, $"Reset username color."); }); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; // Initiate variables _client = manager.Client; manager.CreateCommands("", cmd => // Create commands with the manager { cmd.CreateCommand("say") // The command text `!say <text>` .Description("Make the bot say something") // The command's description .Alias("s") // An alternate trigger for this command `!s <text>` .MinPermissions((int)AccessLevel.ServerAdmin) // Limit this command to people who have administrator rights .Parameter("text", ParameterType.Unparsed) // The parameter for this command .Do(async (e) => // The code to be run when the command is executed { string text = e.Args[0]; // Copy the first paramter into a variable await e.Channel.SendMessage(text); // Send the text to the channel the command was executed in }); cmd.CreateGroup("set", (b) => // Create a group of sub-commands `!set` { b.CreateCommand("nick") // The command text `!set nick <name>` .Description("Change your nickname.") .Parameter("name", ParameterType.Unparsed) .Do(async (e) => { string name = e.Args[0]; // Copy the first parameter into a variable var user = e.User; // Get the object of the user that executed the command. await user.Edit(nickname: name); // Edit the user's nickname. await e.Channel.SendMessage( // Let the user know the command executed successfully. $"{user.Mention} I changed your name to **{name}**"); }); b.CreateCommand("botnick") // The command text `!set botnick <name>` .Description("Change the bot's nickname.") .MinPermissions((int)AccessLevel.ServerOwner) // Limit this command to server owner .Parameter("name", ParameterType.Unparsed) .Do(async (e) => { string name = e.Args[0]; // Copy the first parameter into a variable var bot = e.Server.CurrentUser; // Get the bot's user object for this server. await bot.Edit(nickname: name); // Edit the user's nickname. await e.Channel.SendMessage( // Let the user know the command executed successfully. $"I changed my name to **{name}**"); }); }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { cgb.AddCheck(PermissionChecker.Instance); commands.ForEach(com => com.Init(cgb)); cgb.CreateCommand(Prefix + "modules") .Alias(".modules") .Description("List all bot modules.") .Do(async e => { await e.Channel.SendMessage("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.Client.GetService<ModuleService>().Modules.Select(m => m.Name)) + $"\n`Type \"{Prefix}commands module_name\" to get a list of commands in that module.`") .ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "commands") .Alias(".commands") .Description("List all of the bot's commands from a certain module.") .Parameter("module", ParameterType.Unparsed) .Do(async e => { var module = e.GetArg("module")?.Trim().ToLower(); if (string.IsNullOrWhiteSpace(module)) return; var cmds = NadekoBot.Client.GetService<CommandService>().AllCommands .Where(c => c.Category.ToLower() == module); var cmdsArray = cmds as Command[] ?? cmds.ToArray(); if (!cmdsArray.Any()) { await e.Channel.SendMessage("That module does not exist.").ConfigureAwait(false); return; } var i = 0; if (module != "customreactions" && module != "conversations") await e.Channel.SendMessage("`List Of Commands:`\n```xl\n" + string.Join("\n", cmdsArray.GroupBy(item => (i++) / 3) .Select(ig => string.Join("", ig.Select(el => $"{el.Text,-15}" + $"{"[" + el.Aliases.FirstOrDefault() + "]",-8}")))) + $"\n```") .ConfigureAwait(false); else await e.Channel.SendMessage("`List Of Commands:`\n• " + string.Join("\n• ", cmdsArray.Select(c => $"{c.Text}"))); await e.Channel.SendMessage($"`You can type \"{Prefix}h command_name\" to see the help about that specific command.`").ConfigureAwait(false); }); }); }
public void Install(ModuleManager manager) { _manager = manager; _client = manager.Client; manager.CreateCommands("", group => { group.CreateCommand("radio") .Description("connects to a voice channel and plays random music") .Parameter("Channel name") .Do(async e => { var channel = _client.FindChannels(e.Server, e.Args[0], ChannelType.Voice).FirstOrDefault(); /*try { var voice = await _client.JoinVoiceServer(channel); await Task.Run(() => { var random = new Random(); var files = Directory.GetFiles(@"D:\Shared\Music", "*.mp3").OrderBy(x => random.Next()).ToArray(); var outFormat = new WaveFormat(48000, 16, 1); int blockSize = outFormat.AverageBytesPerSecond / 5; //200ms byte[] buffer = new byte[blockSize]; foreach (var file in files) { using (var mp3Reader = new MediaFoundationReader(file)) using (var resampler = new MediaFoundationResampler(mp3Reader, outFormat) { ResamplerQuality = 60 }) { int byteCount; while ((byteCount = resampler.Read(buffer, 0, blockSize)) > 0) voice.SendVoicePCM(buffer, byteCount); } } }); await voice.WaitVoice(); } catch (OperationCanceledException) { } finally { await _client.LeaveVoiceServer(channel.Server); }*/ }); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; _stream = null; manager.CreateCommands("radio", group => { //register radio start command. group.CreateCommand("start"). Description("Starts the radio."). Do(StartRadioCommand); //register radio stop command. group.CreateCommand("stop"). Description("Stops the radio."). Do(StopRadioCommand); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = manager.Client; manager.CreateCommands("", cmd => { cmd.CreateCommand("smug") .Description("Show a smug anime picture.") .MinPermissions((int)AccessLevel.User) .Do(async e => { Random rand = new Random(); await e.Channel.SendMessage($"{e.User.Mention} makes a smug face {SMUGS[rand.Next(SMUGS.Length)]}"); await e.Message.Delete(); }); }); }
void IModule.Install(ModuleManager manager) { manager.CreateDynCommands("verm", PermissionLevel.User, group => { group.CreateCommand("roulette") .Description( "Picks a random mission and a random difficulty. (Can be overriden with an optional param.)") .Parameter("difficulty", ParameterType.Optional) .Do(async e => { string diff = e.GetArg("difficulty"); if (string.IsNullOrEmpty(diff)) diff = _difficulties.PickRandom(); await e.Channel.SafeSendMessage($"{_missions.PickRandom()} on {diff}"); }); }); }
void IModule.Install(ModuleManager manager) { _client = manager.Client; _scriptOptions = _scriptOptions.AddReferences( typeof (object).Assembly, typeof (Enumerable).Assembly, _client.GetType().Assembly) .AddImports("System", "System.Linq", "System.Collections.Generic", "Discord"); manager.CreateCommands("exec", group => { group.MinPermissions((int) PermissionLevel.BotOwner); group.CreateCommand("") .Description("Compiles and runs a C# script.") .Parameter("query", ParameterType.Unparsed) .Do(async e => { if (e.User.Name != "SSStormy" || e.User.Id != Constants.UserOwner) return; // really have to make sure that it's me calling this tbh. try { object output = await CSharpScript.EvaluateAsync(e.GetArg("query"), _scriptOptions, new Globals(e, _client)); if (output == null || (output as Task) != null || (output as string) == string.Empty) await e.Channel.SafeSendMessage("Output was empty or null."); else await e.Channel.SafeSendMessage(output.ToString()); } catch (CompilationErrorException ex) { await e.Channel.SafeSendMessage($"Compilation failed: {Format.Code(ex.Message)}"); } GC.Collect(); }); }); }
public void Install(ModuleManager manager) { _client = manager.Client; manager.CreateCommands("", group => { group.CreateCommand("stats") .Description("shows some server statistics") .Do(async e => { await _client.SendMessage(e.Message.Channel, _botServices.Stats.GetStatistics(e.Server).ToDiscordMessage()); }); }); _client.Connected += (s, e) => { Task.Run(() => _botServices.Server.LoadServerUserData(_client.AllServers)); Task.Run(() => _botServices.Server.LoadServerChannelData(_client.AllServers)); }; }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { commands.ForEach(cmd => cmd.Init(cgb)); cgb.CreateCommand(">") .Description("Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'.\n**Usage**: > strike @User") .Parameter("attack_type",Discord.Commands.ParameterType.Required) .Parameter("target",Discord.Commands.ParameterType.Required) .Do(async e => { var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); var usrType = GetType(usr.Id); string response = ""; int dmg = GetDamage(usrType, e.GetArg("attack_type").ToLowerInvariant()); response = e.GetArg("attack_type") + (e.GetArg("attack_type")=="splash"?"es ":"s ") + usr.Mention + " for " + dmg+".\n"; if (dmg >= 65) { response += "It's super effective!"; } else if (dmg <= 35) { response += "Ineffective!"; } await e.Send(NadekoBot.botMention + " " + response); }); cgb.CreateCommand("poketype") .Parameter("target", Discord.Commands.ParameterType.Required) .Description("Gets the users element type. Use this to do more damage with strike") .Do(async e => { var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); if (usr == null) { await e.Send("No such person."); } await e.Send(usr.Name + "'s type is " + GetType(usr.Id)); }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { commands.ForEach(com => com.Init(cgb)); cgb.CreateCommand("$raffle") .Description("Prints a name and ID of a random user from the online list from the (optional) role.") .Parameter("role", ParameterType.Optional) .Do(async e => { var arg = string.IsNullOrWhiteSpace(e.GetArg("role")) ? "@everyone" : e.GetArg("role"); var role = e.Server.FindRoles(arg).FirstOrDefault(); if (role == null) { await e.Channel.SendMessage(":anger: Role not found."); return; } var members = role.Members.Where(u => u.Status == Discord.UserStatus.Online); // only online await e.Channel.SendMessage($"**Raffled user:** {members.ToArray()[new System.Random().Next(0, members.Count())].Name}"); }); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; manager.CreateCommands("admin", group => { //register radio start command. group.CreateCommand("acceptinvite"). Parameter("inviteCode", ParameterType.Required). Description("Accepts invite to a server.").Hide(). Do(AcceptCommand); //register radio start command. group.CreateCommand("leaveserver"). Parameter("none", ParameterType.Unparsed). Description("leaves the current server.").Hide(). Do(LeaveCommand); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = _manager.Client; //create our soundcloud API _soundCloud = new SoundCloudManager(DisConfig.Soundcloud.Token); //create our music queue _queue = new MusicQueue(); manager.CreateCommands("", group => { //register skip command. group.CreateCommand("skip"). Parameter("nothing", ParameterType.Unparsed). Description("Skips the current song in the music queue."). Do(SkipCommand); //register request command group.CreateCommand("request"). Parameter("url", ParameterType.Required). Description("Adds youtube or soundcloud video to DiscoBot queue."). Do(RequestCommand); //register join room command group.CreateCommand("joinroom"). Parameter("room", ParameterType.Unparsed). Description("Joins a voice channel that you specified."). Do(JoinVoiceCommand); //register join room command group.CreateCommand("leaveroom"). Parameter("room", ParameterType.Unparsed). Description("Leaves any voice channel the bot is connected to in this server."). Do(LeaveVoiceCommand); }); }
void IModule.Install(ModuleManager manager) { _manager = manager; _client = manager.Client; _service = manager.Client.Modules(true); manager.CreateCommands("modules", group => { group.MinPermissions((int)PermissionLevel.BotOwner); group.CreateCommand("list") .Description("Gives a list of all available modules.") .Do(async e => { string text = "Available Modules: " + string.Join(", ", _service.Modules.Select(x => x.Id)); await _client.Reply(e, text); }); group.CreateCommand("enable") .Description("Enables a module for this server.") .Parameter("module") .PublicOnly() .Do(e => { var module = GetModule(e.Args[0]); if (module == null) { _client.ReplyError(e, "Unknown module"); return; } if (module.FilterType == ModuleFilter.None || module.FilterType == ModuleFilter.AlwaysAllowPrivate) { _client.ReplyError(e, "This module is global and cannot be enabled/disabled."); return; } if (!module.FilterType.HasFlag(ModuleFilter.ServerWhitelist)) { _client.ReplyError(e, "This module doesn't support being enabled for servers."); return; } var server = e.Server; if (!module.EnableServer(server)) { _client.ReplyError(e, $"Module {module.Id} was already enabled for server {server.Name}."); return; } _client.Reply(e, $"Module {module.Id} was enabled for server {server.Name}."); }); group.CreateCommand("disable") .Description("Disables a module for this server.") .Parameter("module") .PublicOnly() .Do(e => { var module = GetModule(e.Args[0]); if (module == null) { _client.ReplyError(e, "Unknown module"); return; } if (module.FilterType == ModuleFilter.None || module.FilterType == ModuleFilter.AlwaysAllowPrivate) { _client.ReplyError(e, "This module is global and cannot be enabled/disabled."); return; } if (!module.FilterType.HasFlag(ModuleFilter.ServerWhitelist)) { _client.ReplyError(e, "This module doesn't support being enabled for servers."); return; } var server = e.Server; if (!module.DisableServer(server)) { _client.ReplyError(e, $"Module {module.Id} was not enabled for server {server.Name}."); return; } _client.Reply(e, $"Module {module.Id} was disabled for server {server.Name}."); }); }); }
public override void Install(ModuleManager manager) { manager.CreateCommands("", cgb => { cgb.CreateCommand(Prefix + "createwar") .Alias(Prefix + "cw") .Description( $"Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name.\n**Usage**:{Prefix}cw 15 The Enemy Clan") .Parameter("size") .Parameter("enemy_clan", ParameterType.Unparsed) .Do(async e => { if (!e.User.ServerPermissions.ManageChannels) return; List<ClashWar> wars; if (!ClashWars.TryGetValue(e.Server.Id, out wars)) { wars = new List<ClashWar>(); if (!ClashWars.TryAdd(e.Server.Id, wars)) return; } var enemyClan = e.GetArg("enemy_clan"); if (string.IsNullOrWhiteSpace(enemyClan)) { return; } int size; if (!int.TryParse(e.GetArg("size"), out size) || size < 10 || size > 50 || size % 5 != 0) { await e.Channel.SendMessage("💢🔰 Not a Valid war size").ConfigureAwait(false); return; } var cw = new ClashWar(enemyClan, size, e); //cw.Start(); wars.Add(cw); cw.OnUserTimeExpired += async (u) => { try { await e.Channel.SendMessage( $"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**") .ConfigureAwait(false); } catch { } }; cw.OnWarEnded += async () => { try { await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**").ConfigureAwait(false); } catch { } }; await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**").ConfigureAwait(false); //war with the index X started. }); cgb.CreateCommand(Prefix + "startwar") .Alias(Prefix + "sw") .Description("Starts a war with a given number.") .Parameter("number", ParameterType.Required) .Do(async e => { var warsInfo = GetInfo(e); if (warsInfo == null) { await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false); return; } var war = warsInfo.Item1[warsInfo.Item2]; try { var startTask = war.Start(); await e.Channel.SendMessage($"🔰**STARTED WAR AGAINST {war.ShortPrint()}**").ConfigureAwait(false); await startTask.ConfigureAwait(false); } catch { await e.Channel.SendMessage($"🔰**WAR AGAINST {war.ShortPrint()} IS ALREADY STARTED**").ConfigureAwait(false); } }); cgb.CreateCommand(Prefix + "listwar") .Alias(Prefix + "lw") .Description($"Shows the active war claims by a number. Shows all wars in a short way if no number is specified.\n**Usage**: {Prefix}lw [war_number] or {Prefix}lw") .Parameter("number", ParameterType.Optional) .Do(async e => { // if number is null, print all wars in a short way if (string.IsNullOrWhiteSpace(e.GetArg("number"))) { //check if there are any wars List<ClashWar> wars = null; ClashWars.TryGetValue(e.Server.Id, out wars); if (wars == null || wars.Count == 0) { await e.Channel.SendMessage("🔰 **No active wars.**").ConfigureAwait(false); return; } var sb = new StringBuilder(); sb.AppendLine("🔰 **LIST OF ACTIVE WARS**"); sb.AppendLine("**-------------------------**"); for (var i = 0; i < wars.Count; i++) { sb.AppendLine($"**#{i + 1}.** `Enemy:` **{wars[i].EnemyClan}**"); sb.AppendLine($"\t\t`Size:` **{wars[i].Size} v {wars[i].Size}**"); sb.AppendLine("**-------------------------**"); } await e.Channel.SendMessage(sb.ToString()).ConfigureAwait(false); return; } //if number is not null, print the war needed var warsInfo = GetInfo(e); if (warsInfo == null) { await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false); return; } await e.Channel.SendMessage(warsInfo.Item1[warsInfo.Item2].ToString()).ConfigureAwait(false); }); cgb.CreateCommand(Prefix + "claim") .Alias(Prefix + "call") .Alias(Prefix + "c") .Description($"Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place. \n**Usage**: {Prefix}call [war_number] [base_number] [optional_other_name]") .Parameter("number") .Parameter("baseNumber") .Parameter("other_name", ParameterType.Unparsed) .Do(async e => { var warsInfo = GetInfo(e); if (warsInfo == null || warsInfo.Item1.Count == 0) { await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false); return; } int baseNum; if (!int.TryParse(e.GetArg("baseNumber"), out baseNum)) { await e.Channel.SendMessage("💢🔰 **Invalid base number.**").ConfigureAwait(false); return; } var usr = string.IsNullOrWhiteSpace(e.GetArg("other_name")) ? e.User.Name : e.GetArg("other_name"); try { var war = warsInfo.Item1[warsInfo.Item2]; war.Call(usr, baseNum - 1); await e.Channel.SendMessage($"🔰**{usr}** claimed a base #{baseNum} for a war against {war.ShortPrint()}").ConfigureAwait(false); } catch (Exception ex) { await e.Channel.SendMessage($"💢🔰 {ex.Message}").ConfigureAwait(false); } }); cgb.CreateCommand(Prefix + "claimfinish") .Alias(Prefix + "cf") .Description($"Finish your claim if you destroyed a base. Optional second argument finishes for someone else.\n**Usage**: {Prefix}cf [war_number] [optional_other_name]") .Parameter("number", ParameterType.Required) .Parameter("other_name", ParameterType.Unparsed) .Do(async e => { var warInfo = GetInfo(e); if (warInfo == null || warInfo.Item1.Count == 0) { await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false); return; } var usr = string.IsNullOrWhiteSpace(e.GetArg("other_name")) ? e.User.Name : e.GetArg("other_name"); var war = warInfo.Item1[warInfo.Item2]; try { var baseNum = war.FinishClaim(usr); await e.Channel.SendMessage($"❗🔰{e.User.Mention} **DESTROYED** a base #{baseNum + 1} in a war against {war.ShortPrint()}").ConfigureAwait(false); } catch (Exception ex) { await e.Channel.SendMessage($"💢🔰 {ex.Message}").ConfigureAwait(false); } }); cgb.CreateCommand(Prefix + "unclaim") .Alias(Prefix + "uncall") .Alias(Prefix + "uc") .Description($"Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim\n**Usage**: {Prefix}uc [war_number] [optional_other_name]") .Parameter("number", ParameterType.Required) .Parameter("other_name", ParameterType.Unparsed) .Do(async e => { var warsInfo = GetInfo(e); if (warsInfo == null || warsInfo.Item1.Count == 0) { await e.Channel.SendMessage("💢🔰 **That war does not exist.**").ConfigureAwait(false); return; } var usr = string.IsNullOrWhiteSpace(e.GetArg("other_name")) ? e.User.Name : e.GetArg("other_name"); try { var war = warsInfo.Item1[warsInfo.Item2]; var baseNumber = war.Uncall(usr); await e.Channel.SendMessage($"🔰 @{usr} has **UNCLAIMED** a base #{baseNumber + 1} from a war against {war.ShortPrint()}").ConfigureAwait(false); } catch (Exception ex) { await e.Channel.SendMessage($"💢🔰 {ex.Message}").ConfigureAwait(false); } }); cgb.CreateCommand(Prefix + "endwar") .Alias(Prefix + "ew") .Description($"Ends the war with a given index.\n**Usage**:{Prefix}ew [war_number]") .Parameter("number") .Do(async e => { var warsInfo = GetInfo(e); if (warsInfo == null) { await e.Channel.SendMessage("💢🔰 That war does not exist.").ConfigureAwait(false); return; } warsInfo.Item1[warsInfo.Item2].End(); var size = warsInfo.Item1[warsInfo.Item2].Size; warsInfo.Item1.RemoveAt(warsInfo.Item2); }); }); }
internal ModuleChecker(ModuleManager manager) { _manager = manager; _filterType = manager.FilterType; }