Пример #1
0
        public async Task HealAsync(CommandContext ctx, [RemainingText, Description("Target")] string target)
        {
            var Chr = await ManageCharacter.GetChrByName(target);

            if (Chr == null)
            {
                await ctx.RespondAsync("Does not exist.");

                return;
            }
            if (Chr.HPC > 0 && await Helpers.Owners.CheckAsync(ctx.User.Id))
            {
                Chr.HPC = Chr.HPM;
                Chr.ENC = Chr.ENM;
                await ManageCharacter.UpdateAsync(Chr);

                await ctx.RespondAsync($"**{Chr.Name} has been healed**");

                return;
            }
            else if (Chr.HPC < 1 && await Helpers.Owners.CheckAsync(ctx.User.Id))
            {
                Chr.HPC = Chr.HPM;
                Chr.ENC = Chr.ENM;
                await ManageCharacter.UpdateAsync(Chr);

                await ctx.RespondAsync($"**{Chr.Name} has been healed**");

                return;
            }
            else
            {
                await ctx.RespondAsync("You can't use this cmd");
            }
        }
Пример #2
0
            public async Task Solve(CommandContext ctx, int ID)
            {
                var Issue = await ManageCharacter.GetAlls(new ManageCharacter.Suggestions()
                {
                    Entry = ID
                });

                if (Issue == null)
                {
                    await ctx.RespondAsync("ID not found...");

                    return;
                }
                Issue.Done = ManageCharacter.Done.yes;
                var Emmy = new DiscordEmbedBuilder()
                {
                    Description = $"`[Done]{Issue.Title}`\n\n{Issue.Desc}"
                };

                Emmy = Emmy.WithFooter("Suggestion #" + ID);
                await ctx.RespondAsync(embed : Emmy);

                await ManageCharacter.UpdateAsync(Suggest : Issue);

                await Task.Delay(1000 * 120);

                await ManageCharacter.RemoveAsync(Issue);
            }
Пример #3
0
 public static async Task Damage(int Value, Chr Chr)
 {
     Chr.HPC -= Value;
     if (Chr.HPC < 0)
     {
         Chr.HPC = Chr.HPM;
     }
     await ManageCharacter.UpdateAsync(Chr);
 }
Пример #4
0
 public static async Task Heal(int Value, Chr Chr)
 {
     Chr.HPC += Value;
     if (Chr.HPC > Chr.HPM)
     {
         Chr.HPC = Chr.HPM;
     }
     await ManageCharacter.UpdateAsync(Chr);
 }
Пример #5
0
        public async Task HealAsync(CommandContext ctx, [Description("Target")] DiscordUser target = null)
        {
            target = target ?? ctx.User;
            var Accg = new AccountGet()
            {
                UID = target.Id,
                GID = ctx.Guild.Id
            };
            var Check = await ManageCharacter.GetAll(Acc : Accg);

            if (Check == null)
            {
                await ctx.RespondAsync("Target has no characters.");

                return;
            }
            var OwnGet = new OwnerGet()
            {
                UID  = target.Id,
                GID  = ctx.Guild.Id,
                Slot = Check.Slot
            };
            var Own = await ManageCharacter.GetAll(OwnGet);

            var ChrGet = new ChrGet()
            {
                Entry = Own.CharEntry,
            };
            var Chr = await ManageCharacter.GetAll(ChrGet);

            if (Chr.HPC > 0 && await Helpers.Owners.CheckAsync(ctx.User.Id))
            {
                Chr.HPC = Chr.HPM;
                Chr.ENC = Chr.ENM;
                await ManageCharacter.UpdateAsync(Chr);

                await ctx.RespondAsync($"**{Chr.Name} has been healed**");

                return;
            }
            else if (Chr.HPC < 1)
            {
                Chr.HPC = Chr.HPM;
                Chr.ENC = Chr.ENM;
                await ManageCharacter.UpdateAsync(Chr);

                await ctx.RespondAsync($"**{Chr.Name} has been healed**");

                return;
            }
            else
            {
                await ctx.RespondAsync("You can't use this if you aren't dead. Ask an admin for help if needed.");
            }
        }
Пример #6
0
        public async Task HealAsync(CommandContext ctx)
        {
            var target = ctx.User;
            var Accg   = new AccountGet()
            {
                UID = target.Id,
                GID = ctx.Guild.Id
            };
            var Check = await ManageCharacter.GetAll(Acc : Accg);

            if (Check == null)
            {
                await ctx.RespondAsync("You have no characters.");

                return;
            }
            var OwnGet = new OwnerGet()
            {
                UID  = target.Id,
                GID  = ctx.Guild.Id,
                Slot = Check.Slot
            };
            var Own = await ManageCharacter.GetAll(OwnGet);

            var ChrGet = new ChrGet()
            {
                Entry = Own.CharEntry,
            };
            var Chr = await ManageCharacter.GetAll(ChrGet);

            var Cdr = await Helpers.TimerChr.GetCooldown(Chr.Entry, ctx.Command.Name);

            if (Cdr != null)
            {
                await ctx.RespondAsync($"This is on cooldown, please wait {(Cdr.RemainingTime / 60).ToString() + " m " + (Cdr.RemainingTime - Convert.ToInt32(Cdr.RemainingTime / 60) * 60)} seconds please!");

                return;
            }
            await Helpers.TimerChr.AddCooldown(Chr.Entry, ctx.Command.Name, 1200);

            Chr.HPC = Chr.HPM;
            Chr.ENC = Chr.ENM;
            await ManageCharacter.UpdateAsync(Chr);

            await ctx.RespondAsync($"**{Chr.Name} has been healed**");

            return;
        }
Пример #7
0
            public async Task AddSnap(CommandContext ctx, DiscordUser user)
            {
                var Accg = new AccountGet()
                {
                    UID = user.Id,
                    GID = ctx.Guild.Id
                };
                var Check = await ManageCharacter.GetAll(Acc : Accg);

                if (Check == null)
                {
                    await ctx.RespondAsync("That person doesn't have an Account here.");

                    return;
                }
                Check.Snaps += 1;
                await ManageCharacter.UpdateAsync(Account : Check);

                await ctx.RespondAsync($"`{user.Username}` has broken the bot, a <:snap:713788866687139913> has been added to their account.");
            }
Пример #8
0
            public async Task Solve(CommandContext ctx, int ID)
            {
                var count = await ManageCharacter.GetCountAsync(Tables.Issues);

                if (ID > count)
                {
                    await ctx.RespondAsync("I don't have that many errors asshole-");

                    return;
                }
                var Issue = await ManageCharacter.GetAll(new ManageCharacter.Issues()
                {
                    Entry = ID
                });

                if (Issue == null)
                {
                    await ctx.RespondAsync("ID not found...");

                    return;
                }
                Issue.Solved = ManageCharacter.Solved.yes;
                var Emmy = new DiscordEmbedBuilder()
                {
                    Description = $"`[Solved]{Issue.Title}`\n\n{Issue.Desc}"
                };

                Emmy = Emmy.WithFooter("Issue #" + ID);
                await ctx.RespondAsync(embed : Emmy);

                await ManageCharacter.UpdateAsync(Issue : Issue);

                await Task.Delay(1000 * 120);

                await ManageCharacter.RemoveAsync(Issue);
            }
Пример #9
0
        public async Task WorkAsync(CommandContext ctx)
        {
            var Target = ctx.User;
            var Accg   = new AccountGet()
            {
                UID = Target.Id,
                GID = ctx.Guild.Id
            };
            var Check = await ManageCharacter.GetAll(Acc : Accg);

            if (Check == null)
            {
                await ctx.RespondAsync($"{Target.Mention} has no characters.");

                return;
            }
            var OwnGet = new OwnerGet()
            {
                UID  = Target.Id,
                GID  = ctx.Guild.Id,
                Slot = Check.Slot
            };
            var Own = await ManageCharacter.GetAll(OwnGet);

            var ChrGet = new ChrGet()
            {
                Entry = Own.CharEntry,
            };
            var Chr = await ManageCharacter.GetAll(ChrGet);

            var Cdr = await Helpers.TimerChr.GetCooldown(Chr.Entry, "work");

            if (Cdr != null)
            {
                await ctx.RespondAsync($"You have already worked, wait for {(Cdr.RemainingTime/60).ToString() + " m " + (Cdr.RemainingTime - Convert.ToInt32(Cdr.RemainingTime/60)*60)} seconds please!");

                return;
            }

            var Amount = Helpers.Tools.RNG.Next(300);

            Chr.Balance += Amount;
            if (Amount < 1)
            {
                await ctx.RespondAsync("Sadly there where no jobs available- try again next time!");
            }
            else if (Amount > 125)
            {
                var Embed = new DiscordEmbedBuilder();
                Embed = Embed.WithAuthor($"{Chr.Name} worked hard and got a magnificent amount of money!");
                Embed = Embed.WithDescription($"{Amount} Enzea");
                await ctx.RespondAsync(embed : Embed);
            }
            else
            {
                var Embed = new DiscordEmbedBuilder();
                Embed = Embed.WithAuthor($"{Chr.Name} worked and got some money!");
                Embed = Embed.WithDescription($"{Amount} Enzea");
                await ctx.RespondAsync(embed : Embed);
            }
            await ManageCharacter.UpdateAsync(Chr);

            await Helpers.TimerChr.AddCooldown(Chr.Entry, "work", 120);
        }
Пример #10
0
        public static async Task <DiscordEmbed> RollAsync(Chr Author, Chr Target, FightOptions Option)
        {
            //Modifiers + Predefining.
            int  Attribute = 0;
            bool Magic     = false;
            int  Dodge     = Target.Dodge;

            switch (Option)
            {
            case FightOptions.Melee:
                Attribute += Author.Sleight;
                break;

            case FightOptions.Ranged:
                Attribute += Author.Marksman;
                break;

            case FightOptions.Magic:
                Attribute += Author.Magic;
                Magic      = true;
                break;
            }
            //RNG Innit
            var AuthorRoll = Helpers.Tools.RNG.Next(12) + 1;
            var TargetRoll = Helpers.Tools.RNG.Next(12) + 1;
            //Roll Msg #1
            string Roll     = $"{Author.Name} rolls ({Option}) against {Target.Name}";
            string RollInit = $"`({AuthorRoll} + {Attribute})` **vs** `({TargetRoll} + {Dodge})`";
            //Switch Win/Loss
            var AuthorFull = AuthorRoll + Attribute;
            var TargetFull = TargetRoll + Dodge;

            string Situation = "";
            int    Visual    = 0;

            int Damage = Author.Strenght + Helpers.Tools.RNG.Next(20) + 1;

            if (Magic == true)
            {
                Damage = Author.MagicEff + Helpers.Tools.RNG.Next(15) + 1;
            }

            if (Author.EffectPath != 0)
            {
                if (Author.EffectPath == EffectPath.boost)
                {
                    Damage += Author.EffectAtribute;
                }
                if (Author.EffectPath == EffectPath.weaken)
                {
                    Damage -= Author.EffectAtribute;
                }
                if (Damage < 0)
                {
                    Damage = 0;
                }
                Author.EffectAtribute = 0;
                Author.EffectPath     = 0;
                await ManageCharacter.UpdateAsync(Author);
            }
            if (AuthorFull == 0)
            {
                Situation = $"{Author.Name} didn't even get near {Target.Name}";
                Visual   += 10;
                Damage    = 0;
            }
            else if (AuthorFull > TargetFull)
            {
                if (AuthorRoll == 12)
                {
                    Damage += 5;
                }
                Situation = $"`{Author.Name}` **succesfully hitted** `{Target.Name}` **for** `{Damage}` **damage**";
                Visual   += 2;
                if (Magic == true)
                {
                    if (Author.ENC < 10)
                    {
                        Situation = "You do not have enough stamina to use Magic Attacks.";
                        Visual   += 10;
                        Damage    = 0;
                    }
                }
            }
            else if (AuthorFull == TargetFull)
            {
                Situation = $"{Author.Name} went on even grounds as {Target.Name}";
                Visual   += 10;
                Damage    = 0;
            }
            else
            {
                Situation = $"{Author.Name} couldn't hit {Target.Name}";
                Visual   += 10;
                Damage    = 0;
            }
            //Create Msg
            var Embed = new DiscordEmbedBuilder();

            Embed = Embed.WithAuthor(Roll);
            Embed = Embed.WithDescription(RollInit + "\n\n" + Situation + "\n" + $"**{Target.Name}** has `{Target.HPC - Damage + "|" + Target.HPM} HP` left");
            //CheckIfDamage
            if (Visual == 2)
            {
                Target.HPC -= Damage;

                if (Target.HPC < 1)
                {
                    Target.HPC = 0;
                    Embed      = Embed.WithFooter($"{Target.Name} died.");
                }

                await ManageCharacter.UpdateAsync(Target);

                if (Magic == true)
                {
                    Author.ENC -= 10;
                    await ManageCharacter.UpdateAsync(Author);
                }
            }
            //End Return
            return(Embed);
        }
Пример #11
0
        public async Task SummonCard(CommandContext ctx)
        {
            var CharEntry = Helpers.Tools.RNG.Next(await ManageCharacter.GetCountAsync(Tables.Character));
            var ChrGet    = new ChrGet()
            {
                Entry = CharEntry,
            };

            var Chr = await ManageCharacter.GetAll(ChrGet);

            var Embed = new DiscordEmbedBuilder();

            Embed = Embed.WithDescription($"[`.Claim`] → [__{Chr.Class} - {Chr.Name} - {Chr.Race}__]");
            Embed = Embed.WithImageUrl(Chr.Image);
            Embed = Embed.WithFooter(Chr.Desc);
            await ctx.RespondAsync(embed : Embed);

ReAsk:
            var r = await Interactivity.WaitForStealAsync(ctx, channel : ctx.Channel);

            if (r == null)
            {
                goto ReAsk;
            }

            var User = r;

            var Accg = new AccountGet()
            {
                UID = User.Id,
                GID = ctx.Guild.Id
            };

            var Check = await ManageCharacter.GetAll(Acc : Accg);

            if (Check == null)
            {
                await ctx.RespondAsync($"You don't own a character.");

                goto ReAsk;
            }

            var OwnGet = new OwnerGet()
            {
                UID  = User.Id,
                GID  = ctx.Guild.Id,
                Slot = Check.Slot
            };

            var Own = await ManageCharacter.GetAll(OwnGet);

            var ChrGets = new ChrGet()
            {
                Entry = Own.CharEntry,
            };

            var Chrs = await ManageCharacter.GetAll(ChrGets);

            var Card = new ManageCharacter.Card()
            {
                ChrCode   = Chr.Entry,
                ChrEntry  = Chrs.Entry,
                ChrName   = Chr.Name,
                ChrDesc   = Chr.Desc,
                ChrRace   = Chr.Race,
                ChrClass  = Chr.Class,
                ChrAmount = 1,
                ChrImage  = Chr.Image
            };

            var Rs = await ManageCharacter.GetAll(Card);

            if (Rs == null)
            {
                await ctx.RespondAsync("You claimed this card for the first time!");

                await ManageCharacter.InsertAsync(Card : Card);

                return;
            }

            Card.ChrAmount += Rs.ChrAmount;

            await ManageCharacter.UpdateAsync(Card : Card);

            await ctx.RespondAsync("You claimed this card!");
        }
Пример #12
0
        private void PostInitialize()
        {
            this.Client.Ready += (e) =>
            {
                this.Client.DebugLogger.LogMessage(LogLevel.Info, nameof(this.Client), "Ready", DateTime.Now);
                return(Task.CompletedTask);
            };

            this.CancellationTokenSource = new CancellationTokenSource();

            AppDomain.CurrentDomain.ProcessExit += (s, e)
                                                   => this.CancellationTokenSource.Cancel();

            Console.CancelKeyPress += (s, e)
                                      => this.CancellationTokenSource.Cancel();

            /* This way you can access the Bot object without globals */
            var deps = new ServiceCollection()
                       .AddSingleton <Bot>(f => this)
                       .BuildServiceProvider();
            var cnext = this.Client.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes       = this.Config.Prefixes,
                CaseSensitive        = false,
                IgnoreExtraArguments = true,
                Services             = deps
            });

            /* Basic command handling */
            cnext.CommandErrored += async(e) =>
            {
                var et = e.Exception.GetType();
                if (et == typeof(CommandNotFoundException))
                {
                    return;
                }
                if (et == typeof(UserException))
                {
                    await e.Context.RespondAsync(e.Exception.Message);
                }
                else
                {
                    if (et == typeof(ArgumentException) &&
                        e.Exception.Message == "Could not find a suitable overload for the command.")
                    {
                        await e.Context.RespondAsync($"Invalid syntax for `{e.Command.QualifiedName}`. See `{e.Context.Prefix}help {e.Command.QualifiedName}` for info on that.");

                        return;
                    }
                    if (e.Exception.Message == "No matching subcommands were found, and this group is not executable.")
                    {
                        await e.Context.RespondAsync($"You either spelled the command wrong or it doesn't exist in specified group.");

                        return;
                    }
                    if (e.Exception.GetType() == typeof(ChecksFailedException))
                    {
                        var ce = (ChecksFailedException)e.Exception;
                        foreach (var failed in ce.FailedChecks)
                        {
                            if (failed.GetType() == typeof(RequirePermissionsAttribute))
                            {
                                // permission failed
                                await e.Context.RespondAsync("You do not have permission to use this command.");

                                return;
                            }
                            else if (failed.GetType() == typeof(CooldownAttribute))
                            {
                                if (e.Exception.Message == "One or more pre-execution checks failed.")
                                {
                                    var time = e.Command.GetType().GetCustomAttributes(typeof(CooldownAttribute), true);
                                    if (time != null)
                                    {
                                        await e.Context.RespondAsync($"The command is on cooldown. {((e.Command.ExecutionChecks[0] as CooldownAttribute).GetBucket(e.Context).ResetsAt - DateTimeOffset.UtcNow).TotalSeconds.ToString("N0")} seconds left");
                                    }
                                    return;
                                }
                            }
                        }
                    }
                    await e.Context.RespondAsync($"error: ```{e.Exception}```");
                }
            };
            cnext.RegisterCommands(System.Reflection.Assembly.GetExecutingAssembly());

            this.Client.UseInteractivity(new InteractivityConfiguration()
            {
                Timeout = TimeSpan.FromHours(2)
            });

            /* Put Db initialization code here */
            this.Db = new Database("./Resources/database.db");
            ManageCharacter.Initialize(this.Db);
            Helpers.Owners.InitCache();
            Helpers.TimerChr.Init(this.Db);


            /*XP System*/
            this.Client.MessageCreated += async(e) =>
            {
                if (e.Guild == null)
                {
                    return;
                }
                if (e.Author.IsBot)
                {
                    return;
                }

                Console.WriteLine($"${e.Guild.Name} | #{e.Channel.Name} | @{e.Author.Username + "#" + e.Author.Discriminator} → {e.Message.Content}");
                if (e.Channel.Name.StartsWith("darii"))
                {
                    if (Helpers.Tools.RNG.Next(5) != 0)
                    {
                        return;
                    }
                    await e.Message.CreateReactionAsync(DiscordEmoji.FromUnicode(client2, "😢"));

                    return;
                }
                var CH = await ManageCharacter.GetChannel(e.Channel.Id);

                if (CH == null)
                {
                    return;
                }
                if (CH.Category != ChannelCategory.Rp)
                {
                    return;
                }
                int XP = e.Message.Content.Count() / 100 + CH.XP;
                if (XP > 5)
                {
                    var Accg = new AccountGet()
                    {
                        UID = e.Author.Id,
                        GID = e.Guild.Id
                    };
                    var Check = await ManageCharacter.GetAll(Acc : Accg);

                    if (Check == null)
                    {
                        return;
                    }
                    var OwnGet = new OwnerGet()
                    {
                        UID  = e.Author.Id,
                        GID  = e.Guild.Id,
                        Slot = Check.Slot
                    };
                    var Own = await ManageCharacter.GetAll(OwnGet);

                    var ChrGet = new ChrGet()
                    {
                        Entry = Own.CharEntry,
                    };
                    var Chr = await ManageCharacter.GetAll(ChrGet);

                    var Cdr = await Helpers.TimerChr.GetCooldown(Chr.Entry, "xp");

                    if (Cdr != null)
                    {
                        return;
                    }
                    XP     += Helpers.Tools.RNG.Next(20) * Chr.Level;
                    XP      = XP * 2;
                    Chr.XP += XP;
                    DiscordMember mem = await e.Guild.GetMemberAsync(e.Author.Id);

                    if (Chr.XP >= Convert.ToInt32(Chr.Level * 100.57 / 4.2 * Chr.Level))
                    {
                        var olvl = Chr.Level;
begin:
                        Chr.XP    -= Convert.ToInt32(Chr.Level * 100.57 / 4.2 * Chr.Level);
                        Chr.Level += 1;
                        if (Chr.Level > 10 && Chr.Level < 15)
                        {
                            Chr.SP += 4;
                        }
                        else if (Chr.Level > 15 && Chr.Level < 20)
                        {
                            Chr.SP += 3;
                        }
                        else if (Chr.Level > 20)
                        {
                            Chr.SP += 2;
                        }
                        else
                        {
                            Chr.SP += 5;
                        }
                        if (Chr.Level > 10)
                        {
                            Chr.UPoints += 1;
                        }
                        Chr.Balance += 60;
                        if (Chr.XP >= Convert.ToInt32(Chr.Level * 100.57 / 4.2 * Chr.Level))
                        {
                            goto begin;
                        }
                        await ManageCharacter.UpdateAsync(Chr);

                        await mem.SendMessageAsync($"**{Chr.Name}** Leveled! `{olvl}` → `{Chr.Level}`");
                    }
                    else
                    {
                        await ManageCharacter.UpdateAsync(Chr);
                    }
                    await mem.SendMessageAsync($"**{Chr.Name}** earned `{XP}` **XP**");

                    await Helpers.TimerChr.AddCooldown(Chr.Entry, "xp", 120);
                }
            };
        }