예제 #1
0
 public string GetPrefix(OrikivoCommandContext ctx)
 {
     if (!UsePrefixes)
     {
         return(ctx.Client.CurrentUser.Mention + " ");
     }
     return(Prefix);
 }
예제 #2
0
 public async Task NotifyCompleteReportAsync(OldAccount a, OrikivoCommandContext Context, Report report, Changelog changelog)
 {
     ulong  reward = 100;
     string b      = $"The report that was accepted ({report.Id}) has been built on {changelog.Name} ({changelog.Id}). Thank you for your input!\nYou have been awarded {EmojiIndex.Balance}{reward.ToPlaceValue().MarkdownBold()} for your time. Keep up the good work.";
     //CompactMessage msg = new CompactMessage(b);
     //OldMail m = new OldMail("Orikivo", $"({report.Id}) has been built!", msg);
     //await m.SendAsync(a, Context.Client);
 }
예제 #3
0
        public void Use(ActionItem item, OrikivoCommandContext Context)
        {
            //if (!Inventory.HasItem(item))
            //return;

            item.Invoke(this, Context);
            //Inventory.Delete(item);
        }
예제 #4
0
 private void DoAction(OldAccount a, OrikivoCommandContext Context)
 {
     switch (Action)
     {
     case ActionType.ClearDebt:
         ClearDebt(a, Context);
         break;
     }
 }
예제 #5
0
 private void ClearDebt(OldAccount a, OrikivoCommandContext Context)
 {
     Console.WriteLine("I AM A POCKET LAWYER AND IM HERE TO HELP");
     //OldMail m = new OldMail("Mr. Pocket", "I'm Here to Help", new CompactMessage("I have contacted ORS, and they have agreed to let me clear your debt. I hope that you'll do better next time."));
     //m.SendAsync(a, Context.Client);
     Context.Data.Update(a);
     a.ClearDebt();
     a.Save();
 }
예제 #6
0
        // make a proper way to get data without having to instantiate or pass the datacontainer...
        // as of now, it seems to be the only way...
        public OldAccount GetBlockedContact(OrikivoCommandContext Context, ulong id)
        {
            if (HasBlocked(id))
            {
                return(Context.Data.GetOrAddAccount(Context.Client.GetUser(id)));
            }

            return(null);
        }
예제 #7
0
        public static bool TryGetGuild(this OrikivoCommandContext ctx, ulong u, out SocketGuild g)
        {
            g = ctx.Client.GetGuild(u);
            if (!g.Exists())
            {
                return(false);
            }

            return(true);
        }
예제 #8
0
        public async Task DeclineReport(OldAccount a, OrikivoCommandContext Context, ulong id, string reason = null)
        {
            if (TryGetReport(id, out Report r))
            {
                DeleteReport(r);
                await NotifyDeclinedReportAsync(a, Context, r, reason);

                return;
            }

            await Context.Channel.SendMessageAsync("The id used does not exist in the list of reports.");
        }
예제 #9
0
        public static bool TryGetGuildPermission(this OrikivoCommandContext ctx, string s, out GuildPermission gp)
        {
            gp = GuildPermission.CreateInstantInvite;
            GuildPermissions perms = GuildPermissions.All;

            if (!perms.HasPermission(s, out gp))
            {
                return(false);
            }

            return(true);
        }
예제 #10
0
        public async Task AcceptReport(OldAccount a, OrikivoCommandContext Context, ulong id)
        {
            if (TryGetReport(id, out Report report))
            {
                DeleteReport(report);
                AcceptedReports.Add(report);
                await NotifyAcceptedReportAsync(a, Context, report);

                return;
            }

            await Context.Channel.SendMessageAsync("The id used does not exist in the list of reports.");
        }
예제 #11
0
        public static bool TryGetGuild(this OrikivoCommandContext ctx, string s, out SocketGuild g)
        {
            g = null;
            if (!s.Exists())
            {
                return(false);
            }
            g = ctx.Client.GetGuild(s);
            if (!g.Exists())
            {
                return(false);
            }

            return(true);
        }
예제 #12
0
        public static bool TryGetPrimaryChatChannel(this OrikivoCommandContext ctx, SocketGuild guild, out SocketTextChannel channel)
        {
            channel = null;
            List <SocketTextChannel> channels = guild.TextChannels.ToList();

            foreach (SocketTextChannel c in channels)
            {
                if (ctx.GetClientChannelPermissions(guild, c).SendMessages)
                {
                    channel = c;
                    return(true);
                }
            }
            return(false);
        }
예제 #13
0
        public async Task CompleteReport(OldAccount a, OrikivoCommandContext Context, ulong id, ulong changelogId)
        {
            if (!TryGetChangelog(changelogId, out Changelog changelog))
            {
                await Context.Channel.SendMessageAsync("You need to specify a changelog ID to complete a report.");

                return;
            }

            if (TryGetAcceptedReport(id, out Report report))
            {
                AcceptedReports.Remove(report);
                await NotifyCompleteReportAsync(a, Context, report, changelog);

                return;
            }

            await Context.Channel.SendMessageAsync("The id used does not exist in the list of reports.");
        }
예제 #14
0
 public static ChannelPermissions GetClientChannelPermissions(this OrikivoCommandContext ctx, SocketGuild guild, SocketTextChannel channel)
 {
     return(guild.GetUser(ctx.Client.CurrentUser.Id).GetPermissions(channel));
 }
예제 #15
0
 public async Task NotifyDeclinedReportAsync(OldAccount a, OrikivoCommandContext Context, Report report, string reason)
 {
     //CompactMessage msg = new CompactMessage($"The report you submitted ({report.Id}) has been declined. Here's what the director of the motion stated:```{reason ?? "It failed to meet the criteria of an report."}```");
     //OldMail m = new OldMail("Orikivo", "Your report has been declined.", msg);
     //await m.SendAsync(a, Context.Client);
 }
예제 #16
0
 public async Task NotifyAcceptedReportAsync(OldAccount a, OrikivoCommandContext Context, Report report)
 {
     //CompactMessage msg = new CompactMessage($"The report you submitted ({report.Id}) has been accepted!\nYou will be notified upon the completion of your input.\nThank you for your time!");
     //OldMail m = new OldMail("Orikivo", "Your report has been accepted!", msg);
     //await m.SendAsync(a, Context.Client);
 }
예제 #17
0
        public Report(OrikivoCommandContext ctx, RestUserMessage message)
        {
            List <Embed> embeds = message.Embeds.ToList();

            if (embeds.Count > 0)
            {
                EmbedBuilder e = embeds.FirstOrDefault().ToEmbedBuilder();

                string sbj = "Subject: ";
                string bid = "BugID: ";

                string[] title = e.Title.Split('\n');

                string.Join("\n", title).Debug();


                string[] top = title[0].Split(" | ");
                string.Join(" | ", top).Debug();


                string emoji = top[0];

                string fullname = top[1];
                fullname.Debug("fullname length");

                string username = fullname.Substring(0, fullname.Length - 5);

                Debugger.Write("i passed this 5");
                // force ignore hashtag.
                string discriminator = top[1].Substring(username.Length + 1);

                Debugger.Write("i passed this 6");
                string sid = e.Footer.Text.Substring(bid.Length);

                Debugger.Write("i passed this 7");
                string command = top[2];
                Debugger.Write("i passed this 8");

                Emoji      flag = new Emoji(emoji.Unescape());
                SocketUser u    = ctx.Client.GetUser(username, discriminator);

                if (!u.Exists())
                {
                    ctx.Channel.SendMessageAsync($"user not found ({username}, {discriminator})");
                    throw new Exception("Invalid User: No User Fits the Statement.");
                }

                string subject = title[1].Substring(sbj.Length).TryUnwrap("**");
                string content = e.Description;
                ulong  id      = ulong.Parse(sid);

                Id      = id;
                Author  = new Author(u);
                Type    = flag.GetFlagType();
                Command = command;
                Subject = subject;
                Content = content;
                return;
            }

            throw new Exception("Invalid Message: No Embeds in Container.");
        }
예제 #18
0
 public static SocketGuild FirstOrDefaultGuild(this OrikivoCommandContext context, string s) =>
 s.Exists() ? context.Client.GetGuild(s) : context.Guild;
예제 #19
0
 public static SocketGuildUser GetGuildUser(this OrikivoCommandContext ctx)
 {
     return(ctx.Guild.GetUser(ctx.User.Id));
 }
예제 #20
0
 public static ChannelPermissions GetClientPermissions(this OrikivoCommandContext ctx)
 => ctx.Guild.CurrentUser.GetPermissions((IGuildChannel)ctx.Channel);
예제 #21
0
 public static bool HasPermission(this OrikivoCommandContext ctx, ChannelPermission p)
 => ctx.GetClientPermissions().Has(p);
예제 #22
0
 public static async Task Send(this EmbedBuilder e, OrikivoCommandContext c) =>
 await c.Channel.SendMessageAsync(embed : e.Build());
예제 #23
0
 public void Invoke(OldAccount a, OrikivoCommandContext Context)
 {
     DoAction(a, Context);
 }