Exemple #1
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "leave")
     .Description("Makes Nadeko leave the server. Either name or id required.\n**Usage**: `.leave 123123123331`")
     .Parameter("arg", ParameterType.Required)
     .AddCheck(SimpleCheckers.OwnerOnly())
     .Do(async e =>
     {
         var arg    = e.GetArg("arg").Trim();
         var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
                      NadekoBot.Client.FindServers(arg).FirstOrDefault();
         if (server == null)
         {
             await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false);
             return;
         }
         if (!server.IsOwner)
         {
             await server.Leave().ConfigureAwait(false);
         }
         else
         {
             await server.Delete().ConfigureAwait(false);
         }
         await NadekoBot.SendMessageToOwner("Left server " + server.Name).ConfigureAwait(false);
     });
 }
Exemple #2
0
        public override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(".logserver")
            .Description("Toggles logging in this channel. Logs every message sent/deleted/edited on the server. BOT OWNER ONLY. SERVER OWNER ONLY.")
            .Do(DoFunc());

            cgb.CreateCommand(".userpresence")
            .Description("Starts logging to this channel when someone from the server goes online/offline/idle. BOT OWNER ONLY. SERVER OWNER ONLY.")
            .Do(async e => {
                if (e.User.Id != NadekoBot.OwnerID ||
                    !e.User.ServerPermissions.ManageServer)
                {
                    return;
                }
                Channel ch;
                if (!loggingPresences.TryRemove(e.Server, out ch))
                {
                    loggingPresences.TryAdd(e.Server, e.Channel);
                    await e.Channel.SendMessage($"**User presence notifications enabled.**");
                    return;
                }

                await e.Channel.SendMessage($"**User presence notifications disabled.**");
            });
        }
Exemple #3
0
 public override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand("-h")
     .Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h" })
     .Description("Help command")
     .Do(DoFunc());
 }
Exemple #4
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "slowmode")
     .Description("Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds.")
     .Parameter("minutes", ParameterType.Optional)
     .AddCheck(SimpleCheckers.ManageMessages())
     .Do(async e =>
     {
         //var minutesStr = e.GetArg("minutes");
         //if (string.IsNullOrWhiteSpace(minutesStr)) {
         //    RatelimitingChannels.Remove(e.Channel.Id);
         //    return;
         //}
         ConcurrentDictionary <ulong, DateTime> throwaway;
         if (RatelimitingChannels.TryRemove(e.Channel.Id, out throwaway))
         {
             await e.Channel.SendMessage("Slow mode disabled.").ConfigureAwait(false);
             return;
         }
         if (RatelimitingChannels.TryAdd(e.Channel.Id, new ConcurrentDictionary <ulong, DateTime>()))
         {
             await e.Channel.SendMessage("Slow mode initiated. " +
                                         "Users can't send more than 1 message every 5 seconds.")
             .ConfigureAwait(false);
         }
     });
 }
Exemple #5
0
        public override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand("-h")
            .Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h", "~h" })
            .Description("Help command")
            .Do(DoFunc());
            cgb.CreateCommand("-hgit")
            .Description("Help command stylized for github readme")
            .Do(DoGitFunc());
            cgb.CreateCommand("-readme")
            .Alias("-guide")
            .Description("Sends a readme and a guide links to the channel.")
            .Do(async e =>
                await e.Send("**FULL README**: <https://github.com/Kwoth/NadekoBot/blob/master/readme.md>\n\n**GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md>"));
            cgb.CreateCommand("-donate")
            .Description("Instructions for helping the project!")
            .Do(async e => {
                await e.Send(
                    @"I've created a **paypal** email for nadeko, so if you wish to support the project, you can send your donations to `[email protected]`
Don't forget to leave your discord name or id in the message, so that I can reward people who help out.
You can join nadekobot server by simply private messaging NadekoBot, and you will get an invite.

*If you want to support in some other way or on a different platform, please message me there*"
                    );
            });
        }
Exemple #6
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "flip")
     .Description("Flips coin(s) - heads or tails, and shows an image.\n**Usage**: `$flip` or `$flip 3`")
     .Parameter("count", ParameterType.Optional)
     .Do(DoFunc());
 }
Exemple #7
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand("rip")
     .Description("Shows a grave image of someone with a start year\n**Usage**: @NadekoBot rip @Someone 2000")
     .Parameter("user", ParameterType.Required)
     .Parameter("year", ParameterType.Optional)
     .Do(async e =>
     {
         if (string.IsNullOrWhiteSpace(e.GetArg("user")))
         {
             return;
         }
         var usr  = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
         var text = "";
         Stream file;
         if (usr == null)
         {
             text = e.GetArg("user");
             file = RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year"))
                             ? null
                             : e.GetArg("year"));
         }
         else
         {
             var avatar = await GetAvatar(usr.AvatarUrl);
             text       = usr.Name;
             file       = RipUser(text, avatar, string.IsNullOrWhiteSpace(e.GetArg("year"))
                             ? null
                             : e.GetArg("year"));
         }
         await e.Channel.SendFile("ripzor_m8.png",
                                  file);
     });
 }
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "voicenotif")
     .Description("Enables notifications on who joined/left the voice channel.\n**Usage**:.voicenotif Karaoke club")
     .Parameter("voice_name", ParameterType.Unparsed)
     .Do(DoFunc());
 }
Exemple #9
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "leave")
     .Description($"Lässt {BotName} den Server verlassen. Entweder Name, oder ID benötigt. | `{Prefix}leave 123123123331`")
     .Parameter("arg", ParameterType.Required)
     .AddCheck(SimpleCheckers.OwnerOnly())
     .Do(async e =>
     {
         var arg    = e.GetArg("arg").Trim();
         var server = MidnightBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
                      MidnightBot.Client.FindServers(arg).FirstOrDefault();
         if (server == null)
         {
             await e.Channel.SendMessage("Kann Server nicht finden.").ConfigureAwait(false);
             return;
         }
         if (!server.IsOwner)
         {
             await server.Leave().ConfigureAwait(false);
         }
         else
         {
             await server.Delete().ConfigureAwait(false);
         }
         await MidnightBot.SendMessageToOwner($"Server {server.Name} verlassen.").ConfigureAwait(false);
     });
 }
Exemple #10
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "t")
            .Description("Starts a game of trivia.")
            .Do(DoFunc());

            cgb.CreateCommand(Module.Prefix + "tl")
            .Description("Shows a current trivia leaderboard.")
            .Do(async e => {
                TriviaGame trivia;
                if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
                {
                    await e.Channel.SendMessage(trivia.GetLeaderboard());
                }
                else
                {
                    await e.Channel.SendMessage("No trivia is running on this server.");
                }
            });

            cgb.CreateCommand(Module.Prefix + "tq")
            .Description("Quits current trivia after current question.")
            .Do(async e => {
                TriviaGame trivia;
                if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
                {
                    await trivia.StopGame();
                }
                else
                {
                    await e.Channel.SendMessage("No trivia is running on this server.");
                }
            });
        }
Exemple #11
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Prefix + "memelist")
            .Description($"Pulls a list of memes you can use with `~memegen` from http://memegen.link/templates/ | `{Prefix}memelist`")
            .Do(async e =>
            {
                int i = 0;
                await e.Channel.SendMessage("`List Of Commands:`\n```xl\n" +
                                            string.Join("\n", JsonConvert.DeserializeObject <Dictionary <string, string> >(await SearchHelper.GetResponseStringAsync("http://memegen.link/templates/"))
                                                        .Select(kvp => Path.GetFileName(kvp.Value))
                                                        .GroupBy(item => (i++) / 4)
                                                        .Select(ig => string.Concat(ig.Select(el => $"{el,-17}"))))
                                            + $"\n```").ConfigureAwait(false);
            });

            cgb.CreateCommand(Prefix + "memegen")
            .Description($"Generates a meme from memelist with top and bottom text. | `{Prefix}memegen biw \"gets iced coffee\" \"in the winter\"`")
            .Parameter("meme", ParameterType.Required)
            .Parameter("toptext", ParameterType.Required)
            .Parameter("bottext", ParameterType.Required)
            .Do(async e =>
            {
                var meme = e.GetArg("meme");
                var top  = Uri.EscapeDataString(e.GetArg("toptext").Replace(' ', '-'));
                var bot  = Uri.EscapeDataString(e.GetArg("bottext").Replace(' ', '-'));
                await e.Channel.SendMessage($"http://memegen.link/{meme}/{top}/{bot}.jpg");
            });
        }
Exemple #12
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand("rip")
     .Description($"Zeigt ein Grab von jemanden mit einem Startjahr | @{BotName} rip @Someone 2000")
     .Parameter("user", ParameterType.Required)
     .Parameter("year", ParameterType.Optional)
     .Do(async e =>
     {
         if (string.IsNullOrWhiteSpace(e.GetArg("user")))
         {
             return;
         }
         var usr  = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
         var text = "";
         Stream file;
         if (usr == null)
         {
             text = e.GetArg("user");
             file = RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year"))
                             ? null
                             : e.GetArg("year"));
         }
         else
         {
             var avatar = await GetAvatar(usr.AvatarUrl);
             text       = usr.Name;
             file       = RipUser(text, avatar, string.IsNullOrWhiteSpace(e.GetArg("year"))
                             ? null
                             : e.GetArg("year"));
         }
         await e.Channel.SendFile("ripzor_m8.png",
                                  file);
     });
 }
Exemple #13
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "typestart")
            .Description($"Starts a typing contest. | `{Prefix}typestart`")
            .Do(DoFunc());

            cgb.CreateCommand(Module.Prefix + "typestop")
            .Description($"Stops a typing contest on the current channel. | `{Prefix}typestop`")
            .Do(QuitFunc());

            cgb.CreateCommand(Module.Prefix + "typeadd")
            .Description($"Adds a new article to the typing contest. Owner only. | `{Prefix}typeadd wordswords`")
            .Parameter("text", ParameterType.Unparsed)
            .Do(async e =>
            {
                if (!WizBot.IsOwner(e.User.Id) || string.IsNullOrWhiteSpace(e.GetArg("text")))
                {
                    return;
                }

                DbHandler.Instance.Connection.Insert(new TypingArticle
                {
                    Text      = e.GetArg("text"),
                    DateAdded = DateTime.Now
                });

                await e.Channel.SendMessage("Added new article for typing game.").ConfigureAwait(false);
            });
        }
Exemple #14
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "listincidents")
            .Alias(Prefix + "lin")
            .Description($"Listet alle UNGELESENEN Vorfälle und markiert sie als gelesen. | `{Prefix}lin`")
            .AddCheck(SimpleCheckers.ManageServer())
            .Do(async e =>
            {
                var sid  = (long)e.Server.Id;
                var incs = DbHandler.Instance.FindAll <Incident>(i => i.ServerId == sid && i.Read == false);
                DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return(i); }));

                await e.User.SendMessage(string.Join("\n----------------------", incs.Select(i => i.Text)));
            });

            cgb.CreateCommand(Module.Prefix + "listallincidents")
            .Alias(Prefix + "lain")
            .Description($"Sendet dir eine Datei mit allen Vorfällen und markiert sie als gelesen. | `{Prefix}lain`")
            .AddCheck(SimpleCheckers.ManageServer())
            .Do(async e =>
            {
                var sid  = (long)e.Server.Id;
                var incs = DbHandler.Instance.FindAll <Incident>(i => i.ServerId == sid);
                DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return(i); }));
                var data        = string.Join("\n----------------------\n", incs.Select(i => i.Text));
                MemoryStream ms = new MemoryStream();
                var sw          = new StreamWriter(ms);
                sw.WriteLine(data);
                sw.Flush();
                sw.BaseStream.Position = 0;
                await e.User.SendFile("incidents.txt", sw.BaseStream);
            });
        }
Exemple #15
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "h")
            .Alias(Module.Prefix + "help", WizBot.BotMention + " help", WizBot.BotMention + " h", "~h")
            .Description("Either shows a help for a single command, or PMs you help link if no arguments are specified.\n**Usage**: '-h !m q' or just '-h' ")
            .Parameter("command", ParameterType.Unparsed)
            .Do(HelpFunc());
            cgb.CreateCommand(Module.Prefix + "hgit")
            .Description("Generates the commandlist.md file. **Owner Only!**")
            .AddCheck(SimpleCheckers.OwnerOnly())
            .Do(DoGitFunc());
            cgb.CreateCommand(Module.Prefix + "readme")
            .Alias(Module.Prefix + "guide")
            .Description("Sends a readme and a guide links to the channel.")
            .Do(async e =>
                await e.Channel.SendMessage(
                    @"**FULL README**: <None>
**GUIDE ONLY**: <None>
**WINDOWS SETUP GUIDE**: <None>
**LINUX SETUP GUIDE**: <None>
**LIST OF COMMANDS**: <http://wizkiller96network.com/wizbot-cmds.html>").ConfigureAwait(false));

            cgb.CreateCommand(Module.Prefix + "donate")
            .Alias("~donate")
            .Description("Instructions for helping the project!")
            .Do(async e =>
            {
                await e.Channel.SendMessage(
                    $@"I've created a **paypal** email for WizBot, so if you wish to support the project, you can send your donations to `[email protected]`
Don't forget to leave your discord name or id in the message, so that I can reward people who help out.
You can join WizBot server by typing {Module.Prefix}h and you will get an invite in a private message.
*If you want to support in some other way or on a different platform, please message me*"
                    ).ConfigureAwait(false);
            });
        }
Exemple #16
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "h")
            .Alias(Module.Prefix + "help", NadekoBot.BotMention + " help", NadekoBot.BotMention + " h", "~h")
            .Description("Either shows a help for a single command, or PMs you help link if no arguments are specified.\n**Usage**: '-h !m q' or just '-h' ")
            .Parameter("command", ParameterType.Unparsed)
            .Do(DoFunc());
            cgb.CreateCommand(Module.Prefix + "hgit")
            .Description("Generates the commandlist.md file. **Owner Only!**")
            .AddCheck(Classes.Permissions.SimpleCheckers.OwnerOnly())
            .Do(DoGitFunc());
            cgb.CreateCommand(Module.Prefix + "readme")
            .Alias(Module.Prefix + "guide")
            .Description("Sends a readme and a guide links to the channel.")
            .Do(async e =>
                await e.Channel.SendMessage(
                    @"**FULL README**: <https://github.com/Kwoth/NadekoBot/blob/master/README.md>

**GUIDE ONLY**: <https://github.com/Kwoth/NadekoBot/blob/master/ComprehensiveGuide.md>

**LIST OF COMMANDS**: <https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>"));

            cgb.CreateCommand(Module.Prefix + "donate")
            .Alias("~donate")
            .Description("Instructions for helping the project!")
            .Do(async e => {
                await e.Channel.SendMessage(
                    @"I've created a **paypal** email for nadeko, so if you wish to support the project, you can send your donations to `[email protected]`
Don't forget to leave your discord name or id in the message, so that I can reward people who help out.
You can join nadekobot server by simply private messaging NadekoBot, and you will get an invite.

*If you want to support in some other way or on a different platform, please message me there*"
                    );
            });
        }
Exemple #17
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "chnlfilterinv")
            .Alias(Module.Prefix + "cfi")
            .Description("Aktiviert, oder deaktiviert automatische Löschung von Einladungen in diesem Channel." +
                         "Falls kein Channel gewählt, derzeitige Channel. Benutze ALL um alle derzeitig existierenden Channel zu wählen." +
                         $" | `{Prefix}cfi enable #general-chat`")
            .Parameter("bool")
            .Parameter("channel", ParameterType.Optional)
            .Do(async e =>
            {
                try
                {
                    var state   = PermissionHelper.ValidateBool(e.GetArg("bool"));
                    var chanStr = e.GetArg("channel");

                    if (chanStr?.ToLowerInvariant().Trim() != "all")
                    {
                        var chan = string.IsNullOrWhiteSpace(chanStr)
                                ? e.Channel
                                : PermissionHelper.ValidateChannel(e.Server, chanStr);
                        await PermissionsHandler.SetChannelFilterInvitesPermission(chan, state).ConfigureAwait(false);
                        await e.Channel.SendMessage($"Invite Filter wurde **{(state ? "aktiviert" : "deaktiviert")}** für Channel **{chan.Name}**.")
                        .ConfigureAwait(false);
                        return;
                    }
                    //all channels

                    foreach (var curChannel in e.Server.TextChannels)
                    {
                        await PermissionsHandler.SetChannelFilterInvitesPermission(curChannel, state).ConfigureAwait(false);
                    }
                    await e.Channel.SendMessage($"Invite Filter wurde **{(state ? "aktiviert" : "deaktiviert")}** für **ALL** Channel.")
                    .ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    await e.Channel.SendMessage($"💢 Fehler: {ex.Message}").ConfigureAwait(false);
                }
            });

            cgb.CreateCommand(Module.Prefix + "srvrfilterinv")
            .Alias(Module.Prefix + "sfi")
            .Description($"Aktiviert, oder deaktiviert automatische Löschung von Einladungenauf diesem Server. | `{Prefix}sfi disable`")
            .Parameter("bool")
            .Do(async e =>
            {
                try
                {
                    var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
                    await PermissionsHandler.SetServerFilterInvitesPermission(e.Server, state).ConfigureAwait(false);
                    await e.Channel.SendMessage($"Invite Filter wurde **{(state ? "aktiviert" : "deaktiviert")}** für diesen Server.")
                    .ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    await e.Channel.SendMessage($"💢 Fehler: {ex.Message}").ConfigureAwait(false);
                }
            });
        }
Exemple #18
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "listincidents")
            .Alias(Prefix + "lin")
            .Description($"List all UNREAD incidents and flags them as read. **Needs Manage Server Permissions.**| `{Prefix}lin`")
            .AddCheck(SimpleCheckers.ManageServer())
            .Do(async e =>
            {
                var sid  = (long)e.Server.Id;
                var incs = DbHandler.Instance.FindAll <Incident>(i => i.ServerId == sid && i.Read == false);
                DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return(i); }));

                await e.User.SendMessage(string.Join("\n----------------------", incs.Select(i => i.Text)));
            });

            cgb.CreateCommand(Module.Prefix + "listallincidents")
            .Alias(Prefix + "lain")
            .Description($"Sends you a file containing all incidents and flags them as read. **Needs Manage Server Permissions.**| `{Prefix}lain`")
            .AddCheck(SimpleCheckers.ManageServer())
            .Do(async e =>
            {
                var sid  = (long)e.Server.Id;
                var incs = DbHandler.Instance.FindAll <Incident>(i => i.ServerId == sid);
                DbHandler.Instance.Connection.UpdateAll(incs.Select(i => { i.Read = true; return(i); }));
                var data        = string.Join("\n----------------------\n", incs.Select(i => i.Text));
                MemoryStream ms = new MemoryStream();
                var sw          = new StreamWriter(ms);
                sw.WriteLine(data);
                sw.Flush();
                sw.BaseStream.Position = 0;
                await e.User.SendFile("incidents.txt", sw.BaseStream);
            });
        }
Exemple #19
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "typestart")
            .Description($"Startet einen Tipp-Wettbewerb. | `{Prefix}typestart`")
            .Do(DoFunc());

            cgb.CreateCommand(Module.Prefix + "typestop")
            .Description($"Stoppt einen Tipp-Wettbewerb auf dem derzeitigen Channel. | `{Prefix}typestop`")
            .Do(QuitFunc());

            cgb.CreateCommand(Module.Prefix + "typeadd")
            .Description($"Fügt einen neuen Text hinzu. Owner only. | `{Prefix}typeadd wordswords`")
            .Parameter("text", ParameterType.Unparsed)
            .Do(async e =>
            {
                if (!MidnightBot.IsOwner(e.User.Id) || string.IsNullOrWhiteSpace(e.GetArg("text")))
                {
                    return;
                }

                DbHandler.Instance.Connection.Insert(new TypingArticle
                {
                    Text      = e.GetArg("text"),
                    DateAdded = DateTime.Now
                });

                await e.Channel.SendMessage("Neuer Text hinzugefügt.").ConfigureAwait(false);
            });
        }
Exemple #20
0
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "translangs")
     .Description($"Listet die verfügbaren Sprachen zur Übersetzung. | `{Prefix}translangs` oder `{Prefix}translangs language`")
     .Parameter("search", ParameterType.Optional)
     .Do(ListLanguagesFunc());
 }
Exemple #21
0
 public override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand("$roll")
     .Description("Rolls 2 dice from 0-10. If you supply a number [x] it rolls up to 30 normal dice.\n**Usage**: $roll [x]")
     .Parameter("num", ParameterType.Optional)
     .Do(DoFunc());
 }
Exemple #22
0
 public override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand("$draw")
     .Description("Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck.\n**Usage**: $draw [x]")
     .Parameter("count", ParameterType.Optional)
     .Do(DoFunc());
 }
Exemple #23
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "h")
            .Alias(Module.Prefix + "help", NadekoBot.BotMention + " help", NadekoBot.BotMention + " h", "~h")
            .Description($"Either shows a help for a single command, or PMs you help link if no arguments are specified. | `{Prefix}h !m q` or just `{Prefix}h` ")
            .Parameter("command", ParameterType.Unparsed)
            .Do(HelpFunc());
            cgb.CreateCommand(Module.Prefix + "hgit")
            .Description($"Generates the commandlist.md file. **Bot Owner Only!** | `{Prefix}hgit`")
            .AddCheck(SimpleCheckers.OwnerOnly())
            .Do(DoGitFunc());
            cgb.CreateCommand(Module.Prefix + "readme")
            .Alias(Module.Prefix + "guide")
            .Description($"Sends a readme and a guide links to the channel. | `{Prefix}readme` or `{Prefix}guide`")
            .Do(async e =>
                await e.Channel.SendMessage(
                    @"**LIST OF COMMANDS**: Type -modules
**Hosting Guides and docs can be found here**: <http://nadekobot.rtfd.io>").ConfigureAwait(false));

            cgb.CreateCommand(Module.Prefix + "donate")
            .Alias("~donate")
            .Description($"Instructions for helping the project! | `{Prefix}donate` or `~donate`")
            .Do(async e =>
            {
                await e.Channel.SendMessage(
                    $@"You can support the project that YoumuBot was built on using patreon. <https://patreon.com/nadekobot> or
You can send donations to `[email protected]`
Don't forget to leave your discord name or id in the message.

**Thank you** ♥️").ConfigureAwait(false);
            });
        }
Exemple #24
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "cleanv+t")
            .Description("Deletes all text channels ending in `-voice` for which voicechannels are not found. **Use at your own risk.**")
            .AddCheck(SimpleCheckers.CanManageRoles)
            .AddCheck(SimpleCheckers.ManageChannels())
            .Do(async e =>
            {
                var allTxtChannels       = e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice"));
                var validTxtChannelNames = e.Server.VoiceChannels.Select(c => GetChannelName(c.Name));

                var invalidTxtChannels = allTxtChannels.Where(c => !validTxtChannelNames.Contains(c.Name));

                invalidTxtChannels.ForEach(async c => await c.Delete());

                await e.Channel.SendMessage("`Done.`");
            });

            cgb.CreateCommand(Module.Prefix + "v+t")
            .Alias(Module.Prefix + "voice+text")
            .Description("Creates a text channel for each voice channel only users in that voice channel can see." +
                         "If you are server owner, keep in mind you will see them all the time regardless.")
            .AddCheck(SimpleCheckers.ManageChannels())
            .AddCheck(SimpleCheckers.CanManageRoles)
            .Do(async e =>
            {
                try
                {
                    var config = SpecificConfigurations.Default.Of(e.Server.Id);
                    if (config.VoicePlusTextEnabled == true)
                    {
                        config.VoicePlusTextEnabled = false;
                        foreach (var textChannel in e.Server.TextChannels.Where(c => c.Name.EndsWith("-voice")))
                        {
                            try
                            {
                                await textChannel.Delete().ConfigureAwait(false);
                            }
                            catch
                            {
                                await e.Channel.SendMessage(
                                    ":anger: Error: Most likely i don't have permissions to do this.")
                                .ConfigureAwait(false);
                                return;
                            }
                        }
                        await e.Channel.SendMessage("Successfuly removed voice + text feature.").ConfigureAwait(false);
                        return;
                    }
                    config.VoicePlusTextEnabled = true;
                    await e.Channel.SendMessage("Successfuly enabled voice + text feature. " +
                                                "**Make sure the bot has manage roles and manage channels permissions**")
                    .ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    await e.Channel.SendMessage(ex.ToString()).ConfigureAwait(false);
                }
            });
        }
Exemple #25
0
 public override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand("!code")
     .Description("Turns your code snippet into a textblock")
     .Parameter("code")
     .Do(DoFunc());
 }
Exemple #26
0
        internal static void AddCommands(CommandGroupBuilder group)
        {
            if (!RolesToken.HasValues)
            {
                return;
            }
            group.CreateCommand("listroles")
            .Description("I'll list the roles you can use with `giverole` and `removerole`")
            .AddCheck(Check)
            .Do(args => ListRolesAsync(args));

            Action <CommandBuilder, string, string, Func <SocketGuildUser, IEnumerable <IRole>, Task> > AddRemove = (cmd, verb, verbed, perform) =>
                                                                                                                    cmd.Parameter("role (or roles, comma separated)", ParameterType.Unparsed)
                                                                                                                    .AddCheck(Check)
                                                                                                                    .Description($"I'll {verb} you the roles you request (see `listroles`)")
                                                                                                                    .Do(async args =>
            {
                var keys  = args.Args[0].Split(',').Select(k => k.Trim().ToLower());
                var roles = new List <IRole>();
                IterateRolesDo(args, role =>
                {
                    if (keys.Any(key => key.Equals(role.Key.ToLower())))
                    {
                        roles.Add(args.Server.GetRole(role.Value["id"].ToObject <ulong>()));
                    }
                });
                await PerformNotifyRemove(args, perform, roles, verbed);
            });

            AddRemove(group.CreateCommand("giverole")
                      .Alias("addrole"), "grant", "Granted", (user, roles) => user.AddRolesAsync(roles));

            AddRemove(group.CreateCommand("removerole"), "remove", "Removed", (user, roles) => user.RemoveRolesAsync(roles));
        }
Exemple #27
0
        internal static void AddCommands(CommandGroupBuilder group)
        {
            var secret_file = "calendar_client_secret.json";

            if (File.Exists(secret_file))
            {
                UserCredential credential;
                using (var stream = new FileStream(secret_file, FileMode.Open, FileAccess.Read))
                {
                    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets, new[] { CalendarService.Scope.CalendarReadonly }, Program.AppName, CancellationToken.None).Result;
                }
                Func <string> timezone = () =>
                {
                    var offset = TimeZoneInfo.Local.BaseUtcOffset.ToString();
                    return($"(UTC{offset.Substring(0, offset.LastIndexOf(':'))})");
                };
                foreach (var calendar_cmd in (JObject)Program.config["GoogleCalendar"])
                {
                    Helpers.CreateJsonCommand(group, calendar_cmd, (cmd, val) =>
                    {
                        var hide_desc = Helpers.FieldExistsSafe <bool>(val, "hideDescription");
                        cmd.Parameter("count or event id", ParameterType.Optional)
                        .Do(async e =>
                        {
                            var service = new CalendarService(new BaseClientService.Initializer()
                            {
                                HttpClientInitializer = credential,
                                ApplicationName       = Program.AppName
                            });
                            Func <Event, string> desc = item => item.Start.DateTime == null ? $"All day {(item.Start.Date.Equals(DateTime.Now.ToString("yyyy-MM-dd")) ? "today" : $"on {item.Start.Date}")}" : $"{(DateTime.Now > item.Start.DateTime ? $"Happening until" : $"Will happen {item.Start.DateTime} and end at")} {item.End.DateTime} {timezone()}.{((hide_desc || string.IsNullOrEmpty(item.Description)) ? "" : $"\n{item.Description}")}";
Exemple #28
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "typestart")
            .Description("Starts a typing contest.")
            .Do(DoFunc());

            cgb.CreateCommand(Module.Prefix + "typestop")
            .Description("Stops a typing contest on the current channel.")
            .Do(QuitFunc());

            cgb.CreateCommand(Module.Prefix + "typeadd")
            .Description("Adds a new article to the typing contest. Owner only.")
            .Parameter("text", ParameterType.Unparsed)
            .Do(async e => {
                if (!NadekoBot.IsOwner(e.User.Id) || string.IsNullOrWhiteSpace(e.GetArg("text")))
                {
                    return;
                }

                DbHandler.Instance.InsertData(new TypingArticle {
                    Text      = e.GetArg("text"),
                    DateAdded = DateTime.Now
                });

                await e.Channel.SendMessage("Added new article for typing game.");
            });

            //todo add user submissions
        }
 internal override void Init(CommandGroupBuilder cgb)
 {
     cgb.CreateCommand(Module.Prefix + "translangs")
     .Description("List the valid languages for translation.")
     .Parameter("search", ParameterType.Optional)
     .Do(ListLanguagesFunc());
 }
Exemple #30
0
        internal override void Init(CommandGroupBuilder cgb)
        {
            cgb.CreateCommand(Module.Prefix + "t")
            .Description($"Starts a game of trivia. You can add nohint to prevent hints." +
                         "First player to get to 10 points wins. 30 seconds per question." +
                         $"\n**Usage**:`{Module.Prefix}t nohint`")
            .Parameter("args", ParameterType.Multiple)
            .Do(async e =>
            {
                TriviaGame trivia;
                if (!RunningTrivias.TryGetValue(e.Server.Id, out trivia))
                {
                    var showHints  = !e.Args.Contains("nohint");
                    var triviaGame = new TriviaGame(e, showHints);
                    if (RunningTrivias.TryAdd(e.Server.Id, triviaGame))
                    {
                        await e.Channel.SendMessage("**Trivia game started!**").ConfigureAwait(false);
                    }
                    else
                    {
                        await triviaGame.StopGame().ConfigureAwait(false);
                    }
                }
                else
                {
                    await e.Channel.SendMessage("Trivia game is already running on this server.\n" + trivia.CurrentQuestion).ConfigureAwait(false);
                }
            });

            cgb.CreateCommand(Module.Prefix + "tl")
            .Description("Shows a current trivia leaderboard.")
            .Do(async e =>
            {
                TriviaGame trivia;
                if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
                {
                    await e.Channel.SendMessage(trivia.GetLeaderboard()).ConfigureAwait(false);
                }
                else
                {
                    await e.Channel.SendMessage("No trivia is running on this server.").ConfigureAwait(false);
                }
            });

            cgb.CreateCommand(Module.Prefix + "tq")
            .Description("Quits current trivia after current question.")
            .Do(async e =>
            {
                TriviaGame trivia;
                if (RunningTrivias.TryGetValue(e.Server.Id, out trivia))
                {
                    await trivia.StopGame().ConfigureAwait(false);
                }
                else
                {
                    await e.Channel.SendMessage("No trivia is running on this server.").ConfigureAwait(false);
                }
            });
        }