示例#1
0
        public static void RemoveAllQuotes(DiscordClient discord)
        {
            //spirit removeallquote
            discord.MessageCreated += async e =>
            {
                if (e.Message.Content.ToLower().StartsWith("spirit removeallquotes") == true)
                {
                    DiscordMember myMember = await e.Guild.GetMemberAsync(e.Message.Author.Id);

                    IEnumerable <DiscordRole> adminRoles = myMember.Roles;
                    int executePermission = 0; //if 1 execute demote
                    foreach (var item in adminRoles)
                    {
                        if (item.Name == "Manager" || item.Name == "Admin" || item.Name == "Moderator" || item.Name == "Owner")
                        {
                            executePermission = 1;
                            if (executePermission == 1)
                            {
                                break;
                            }
                        }
                    }
                    string responseString = "";

                    if (executePermission == 1)
                    {
                        List <CommandsExecuted> myCommandExecutedList = new List <CommandsExecuted>();
                        myCommandExecutedList = SQLCode.getSpiritQuotesToBeAdded();

                        if (myCommandExecutedList.Count == 0)
                        {
                            await e.Message.RespondAsync("There are no quotes to be removed from our to be added list, currently. Try to use: spirit getquotes :first!");
                        }
                        else
                        {
                            try
                            {
                                SQLCode.deleteAllQuoteToBeAdded();
                                await e.Message.RespondAsync("All quotes to be added have been removed. Use: spirit getquotes: to get some new ones :heart: ");
                            }
                            catch
                            {
                                await e.Message.RespondAsync("Whoops something may have gone wrong removing all the quotes");
                            }
                        }
                    }
                    else
                    {
                        await e.Message.RespondAsync("I'm afraid I can't do that " + e.Author.Username);
                    }
                }
            };
        }
示例#2
0
        public static void ExecuteQuotes(DiscordClient discord)
        {
            //spirit executequote
            discord.MessageCreated += async e =>
            {
                if (e.Message.Content.ToLower().StartsWith("spirit executequote") == true)
                {
                    DiscordMember myMember = await e.Guild.GetMemberAsync(e.Message.Author.Id);

                    IEnumerable <DiscordRole> adminRoles = myMember.Roles;
                    int executePermission = 0; //if 1 execute demote
                    foreach (var item in adminRoles)
                    {
                        if (item.Name == "Manager" || item.Name == "Admin" || item.Name == "Moderator" || item.Name == "Owner")
                        {
                            executePermission = 1;
                            if (executePermission == 1)
                            {
                                break;
                            }
                        }
                    }

                    if (executePermission == 1)
                    {
                        SQLCode.insertQuoteToBeAddedExecute();
                        SQLCode.deleteAllQuoteToBeAdded();
                        await e.Message.RespondAsync("Quotes have been added! Hooray :sun_with_face: ");
                    }
                    else
                    {
                        await e.Message.RespondAsync("I'm afraid I can't do that " + e.Author.Username);
                    }
                }
            };
        }