コード例 #1
0
        public async Task HandleCommand(SocketMessage messageParam)
        {
            var message = messageParam as SocketUserMessage;

            if (message == null)
            {
                return;
            }
            int argPos = 0;

            if (!Constants.Channels.BLOCKED_CHANNELS.Contains(message.Channel.Id))
            {
                DBUser user = DBFuncs.FindDBUser(message.Author);
                user.Location = message.Channel.Id;
                DBFuncs.SetAttribute("LOCATION", message.Author, Convert.ToString(message.Channel.Id));
            }

            //changed prefix to db! because even though bot is called shenron, its more DB in general.
            if (message.HasStringPrefix("db!", ref argPos))
            {
                if (DBFuncs.PlayerRegistered(message.Author) || message.Content.StartsWith("db!register") || message.Content.StartsWith("db!help"))
                {
                    var context = new CommandContext(client, message);
                    var result  = await commands.ExecuteAsync(context, argPos);

                    if (!result.IsSuccess)
                    {
                        Console.WriteLine(result.ErrorReason);
                    }
                }
                else
                {
                    await message.Channel.SendMessageAsync($"{message.Author.Mention}, you must register with `db!register` before using commands.");
                }
            }
            else
            {
                return;
            }
        }
コード例 #2
0
        public async Task Power(string direction, int amount)
        {
            if (direction == "up")
            {
                string race  = DBFuncs.GetAttribute("RACE", Context.User);
                IGuild guild = Bot.client.GetGuild(Constants.Guilds.DBZ_EARTH);
                var    user  = await guild.GetUserAsync(Context.User.Id);

                ulong[] role = new ulong[3];

                for (int i = 0; i < amount; i++)
                {
                    if ((user.RoleIds.Contains(Constants.Roles.KAIOKEN[0]) || role == Constants.Roles.KAIOKEN) && DBFuncs.HasSkill("Super Saiyan", Context.User))
                    {
                        await Power("down");

                        role = Constants.Roles.SUPER;
                    }
                    else if ((user.RoleIds.Contains(Constants.Roles.SUPER[0]) || role == Constants.Roles.SUPER) && DBFuncs.HasSkill("SSGSS", Context.User))
                    {
                        await Power("down");

                        role = Constants.Roles.SSGSS;
                    }
                    else if (DBFuncs.HasSkill("Kaioken", Context.User) && !user.RoleIds.Contains(Constants.Roles.SSGSS[0]))
                    {
                        role = Constants.Roles.KAIOKEN;
                    }
                }

                if (role[0] != 0)
                {
                    Funcs.GiveRole(role, Context.User);
                    DBSkill skill = DBFuncs.GetSkill(guild.GetRole(role[0]).Name);
                    DBFuncs.SetAttribute("MULTIPLIER", Context.User, Convert.ToString(skill.Power));
                }
                else
                {
                    await Context.Channel.SendMessageAsync("You attempt to power up further, but fail.");
                }
            }
            else if (direction == "down")
            {
                var guilds = Constants.Guilds.PLANETS;
                for (int i = 0; i < 3; i++)
                {
                    var guildID = guilds.ElementAt(i);
                    var guild   = Bot.client.GetGuild(guildID);
                    if (await Funcs.InGuild(guild, Context.User))
                    {
                        var user = guild.GetUser(Context.User.Id);
                        if (user.Roles.Contains(guild.GetRole(Constants.Roles.KAIOKEN[i])))
                        {
                            await user.RemoveRoleAsync(guild.GetRole(Constants.Roles.KAIOKEN[i]));
                        }
                        else if (user.Roles.Contains(guild.GetRole(Constants.Roles.SUPER[i])))
                        {
                            await user.RemoveRoleAsync(guild.GetRole(Constants.Roles.SUPER[i]));
                        }
                        else if (user.Roles.Contains(guild.GetRole(Constants.Roles.SSGSS[i])))
                        {
                            await user.RemoveRoleAsync(guild.GetRole(Constants.Roles.SSGSS[i]));
                        }
                    }
                    DBFuncs.SetAttribute("FORM", Context.User, "1");
                }
                DBFuncs.SetAttribute("MULTIPLIER", Context.User, "1");
            }
        }
コード例 #3
0
        public async Task Wish(string wish, IUser user)
        {
            if (DBFuncs.FindDBUser(user).BallCount() == 7)
            {
                if (wish == "list")
                {
                    JEmbed jemb = new JEmbed();
                    jemb.Author.Name    = "Wish List";
                    jemb.Author.IconUrl = Bot.client.CurrentUser.GetAvatarUrl();
                    jemb.ColorStripe    = Constants.Colours.SHENRON_GREEN;

                    int counter = 1;
                    foreach (string item in File.ReadAllLines(@"Files\wishes.txt"))
                    {
                        jemb.Fields.Add(new JEmbedField(x =>
                        {
                            x.Header = $"[{counter}]";
                            x.Text   = item;
                        }));
                        counter++;
                    }

                    await Context.Channel.SendMessageAsync("", embed : jemb.Build());
                }
                else if (wish == "1")
                {
                    int currentLVL = Convert.ToInt32(DBFuncs.GetAttribute("LEVEL", user));
                    int newLVL     = currentLVL + 10;
                    DBFuncs.SetAttribute("LEVEL", user, Convert.ToString(newLVL));

                    await Context.Channel.SendMessageAsync($"Your wish has been granted... {user.Username}! You are now level {newLVL}.");
                }
                else if (wish == "2")
                {
                }                        //increase currency
                else if (wish == "3")
                {
                }                        //give skill
                else if (wish == "4")
                {
                }                        //custom
                else
                {
                    await Context.Channel.SendMessageAsync($"Wish '{wish}' does not exist. Refer to the wish by it's ID number."); return;
                }

                for (int i = 0; i < 7; i++)
                {
                    if (Bot.sess.Balls[i].Location == null && Bot.sess.Balls[i].Held == false)
                    {
                        var dbUser = DBFuncs.FindDBUser(Context.User);
                        dbUser.heldBalls.Clear();
                        Bot.sess.Balls[i].Holder = null;
                        Bot.sess.Balls[i].Held   = false;
                        Bot.sess.End();
                    }
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync("Shenron cannot be summoned without all seven **Dragon Balls**!");
            }
        }