public async Task channel(CommandContext ctx, [Description("Operação (add/del)")] string action, [Description("O Canal (ID/Menção)")] DiscordChannel channel) { switch (action) { case "add": var channels = new ReactChannel().Find(x => x.DiscordID == channel.Id); if (channels != null) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse canal já foi adicionado anteriormente.")); } else { ReactChannelModel ch = new ReactChannelModel { DiscordID = channel.Id, }; new ReactChannel().Insert(ch); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Canal adicionado com sucesso!")); } break; case "del": channels = new ReactChannel().Find(x => x.DiscordID == channel.Id); if (channels == null) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse canal não foi adicionado.")); } else { new ReactChannel().Delete(channels); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Canal removido com sucesso!")); } break; } }
private async Task ReactionAdded(MessageReactionAddEventArgs e) { try { if (e.User != e.Client.CurrentUser && Program.pairs.Any(x => x.InputPair == e.Channel.Id)) { Pair p = Program.pairs.Find(x => x.InputPair == e.Channel.Id); if ((e.Channel.Guild.GetMemberAsync(e.User.Id).Result).Roles.Any(x => x.Permissions.HasPermission(Permissions.ManageRoles)) && e.User != e.Client.CurrentUser) { var msg = await e.Channel.GetMessageAsync(e.Message.Id); Suggestion sg = new Suggestion(msg); var RetChn = e.Channel.Guild.GetChannel(p.OutputPair); if (sg.Image.HasValue) { await RetChn.SendFileAsync(sg.Image.Value, null, false, EmbedBase.SuggestionEmbed(sg)); await e.Message.DeleteAsync(); } } } } catch (Exception ex) { StringBuilder data = new StringBuilder(); Console.WriteLine($"[EX <{ex.Message}> @ Sug.cs : ReactionAdded] \n\t{ex}"); } }
public async Task DelCommand(CommandContext ctx) { var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("# of Pair to delete")); var list = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(Program.pairs, "Pairs")); var inpt = await ctx.Message.GetNextMessageAsync(); Regex d = new Regex(@"\d+"); var numbers = d.Split(inpt.Result.Content).ToList(); var i = int.Parse(numbers[0]); var pair = Program.pairs[i]; await list.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.InputEmbed($"Do you want to delete {pair.Name}? [y/n]")); var ipt2 = await inpt.Result.GetNextMessageAsync(); if (ipt2.Result.Content.ToLowerInvariant().Contains("y")) { Program.pairs.Remove(pair); File.WriteAllText(Directory.GetCurrentDirectory() + "/Pairs.json", JsonConvert.SerializeObject(Program.pairs, Formatting.Indented)); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"{pair.Name} Removed with sucess.")); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Command Cancelled.")); } }
public async Task Remove(CommandContext ctx, [Description("Membro (ID/Menção)")] DiscordMember membro) { var infras = new Infracao().FindAll(x => x.IdInfrator == membro.Id); if (infras.Count == 0) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed($"O Membro {membro.Mention} possui uma ficha limpa!")); } else { var briefing = await ctx.RespondAsync(embed : await EmbedExtended.MemberBriefing(infras)); var message = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("# da infração que será apagada")); var input = await ctx.Message.GetNextMessageAsync(); var num = int.Parse(input.Result.Content.Split(" ")[0]); if (infras.Any(x => x.Id == num)) { var infra = infras.Find(x => x.Id == num); new Infracao().Delete(infra); await briefing.ModifyAsync(embed : EmbedBase.OutputEmbed($"Infração Apagada com sucesso.\n Dados :")); await message.ModifyAsync(embed : EmbedExtended.AsyncInfracaoEmbed(infra)); } else { await briefing.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed($"Numero inválido, Comando cancelado.")); } } }
public async Task RemoveCommand(CommandContext ctx, [Description("The emoji")] DiscordEmoji emoji) { var categories = System.categoryCache.Query().Where(_ => true).ToList(); var msg = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(categories.Select(x => $"<#{x.ChannelId}> - {x.Name}").ToList(), "Categories").Mutate(x => x.WithTitle("Select the category [#]"))); var response = await ctx.Message.GetNextMessageAsync(); if (response.TimedOut) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Command canceled.")); return; } int index = Math.Clamp(response.Result.FirstInt(), 0, categories.Count - 1); var category = categories[index]; var ch = ctx.Guild.GetChannel(category.ChannelId); var catmsg = await ch.GetMessageAsync(category.MessageId); if (!category.Data.ContainsKey(emoji.Id)) { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Pair with emoji {emoji} doesn't exist on {category.Name} @ <#{category.ChannelId}>")); return; } category.Data.Remove(emoji.Id); System.categoryCache.Update(category); System.Execute(); await catmsg.ModifyAsync(embed : await category.ToEmbedAsync(ctx)); await catmsg.DeleteAllReactionsAsync(emoji); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Emoji : {emoji} removed from category {category.Name} @ <#{category.ChannelId}>")); }
public async Task soltar(CommandContext ctx, [Description("O membro que será solto")] DiscordMember member) { var infras = new Infracao().FindAll(x => x.IdInfrator == member.Id); if (infras.Count != 0) { var prisoes = new List <PrisaoModel>(); infras.ForEach(x => prisoes.Add(new Prisao().Find(y => y.InfraId == x.Id))); var active = prisoes.Find(x => x.Elapsed == false); if (active == null) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse membro não está preso.")); } else { await Soltar(active); active.Elapsed = true; new Prisao().Update(x => x.Id == active.Id, active); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Membro solto da prisão com sucesso!")); } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse membro possui uma ficha limpa.")); } }
public async Task List(CommandContext ctx) { var allSystems = new List <string>(); Program.systems.ForEach(x => allSystems.Add(x.Name)); var embed = EmbedBase.ListEmbed(allSystems, "Systems"); await ctx.RespondAsync(embed : embed); }
public async Task Modify(CensoModel censo, int value, DiscordMessage message, InteractivityResult <DiscordMessage> responce) { switch (value) { case 0: Regex check = new Regex(@"[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*"); var email = check.Match(responce.Result.Content).ToString(); if (!string.IsNullOrWhiteSpace(email)) { censo.Email = email; } new Logic.Censo().Update(x => x.Id == censo.Id, censo); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Email modificado com sucesso!")); break; case 1: int idade = 0; responce.Result.Content.Split(" ").ToList().ForEach(x => int.TryParse(x, out idade)); if (idade != 0) { censo.Idade = idade; } int.TryParse(responce.Result.Content, out idade); if (idade != 0) { censo.Idade = idade; } new Logic.Censo().Update(x => x.Id == censo.Id, censo); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Idade modificada com sucesso!")); break; case 2: censo.Idiomas = responce.Result.Content; new Logic.Censo().Update(x => x.Id == censo.Id, censo); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Idiomas modificados com sucesso!")); break; case 3: censo.Jogos = responce.Result.Content; new Logic.Censo().Update(x => x.Id == censo.Id, censo); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Jogos modificados com sucesso!")); break; case 4: censo.Origem = responce.Result.Content; new Logic.Censo().Update(x => x.Id == censo.Id, censo); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Origem modificada com sucesso!")); break; default: break; } }
public async Task MoveCommand(CommandContext ctx, DiscordChannel dst, bool soft = false) { if (dst == ctx.Channel) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("what are you? a FOOL? you really called me to move things to the same place?")); return; } var(startMsg, endMsg) = (await GetMessage(ctx, ">>move start"), await GetMessage(ctx, ">>move end")); var err = GetErrorMessage(startMsg, endMsg); if (!string.IsNullOrWhiteSpace(err)) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed($"The following messages could not be found: \n{err}")); return; } await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Found both starting and ending messages.")); var messagesBetween = await GetMessagesBetween(ctx, startMsg.Id, endMsg.Id); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Got all messages. Moving will begin shortly.")); var allMessages = new List <DiscordMessage>(); allMessages.Add(startMsg); allMessages.AddRange(messagesBetween); allMessages.Add(endMsg); var participants = allMessages.Select(x => $"- {x.Author.Username}").Distinct().ToList(); var embeds = await allMessages.ToEmbeds(ctx); foreach (var embed in embeds) { await dst.SendMessageAsync(embed : embed); await Task.Delay(1000); } var stats = EmbedBase.OutputEmbed("Finished moving messages") .Mutate(x => x .AddField("Total Message Count:", $"{allMessages.Count()} messages", true) .AddField("Participants", $"{string.Join("\n", participants)}", true) ); if (!soft) { var msgs = allMessages.Where(x => !x.Attachments.Any()); await ctx.Channel.DeleteMessagesAsync(msgs); stats = stats.Mutate(x => x.AddField("Deleted", $"{msgs.Count()} messages", true)); } await ctx.RespondAsync(embed : stats); }
public async Task PrefixSuccess(CommandContext ctx, [DSharpPlus.CommandsNext.Attributes.Description("The operation to be executed [add/list/del] ")] string operation) { switch (operation.ToLowerInvariant()) { case "add": var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Prefix to be added")); InteractivityResult <DiscordMessage> response = await ctx.Message.GetNextMessageAsync(); var prefix = response.Result.Content; if (Program.Config.Prefixes.Contains(prefix.ToLowerInvariant())) { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"This prefix is already added.")); } else { Program.Config.Prefixes.Add(prefix.ToLowerInvariant()); File.WriteAllText(Directory.GetCurrentDirectory() + "/Config.json", JsonConvert.SerializeObject(Program.Config, Formatting.Indented)); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Prefix added without errors.")); } break; case "del": var msg2 = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Prefix to be removed")); InteractivityResult <DiscordMessage> response2 = await ctx.Message.GetNextMessageAsync(); var prefix2 = response2.Result.Content; if (!Program.Config.Prefixes.Contains(prefix2.ToLowerInvariant())) { await msg2.ModifyAsync(embed : EmbedBase.OutputEmbed($"This prefix doesn't exists.")); } else { Program.Config.Prefixes.Remove(prefix2.ToLowerInvariant()); File.WriteAllText(Directory.GetCurrentDirectory() + "/Config.json", JsonConvert.SerializeObject(Program.Config, Formatting.Indented)); await msg2.ModifyAsync(embed : EmbedBase.OutputEmbed($"Prefix removed without errors.")); } break; case "list": await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(Program.Config.Prefixes, "Prefixes")); break; default: var embed = EmbedBase.CommandHelpEmbed(ctx.Command); await ctx.RespondAsync(embed : embed); break; } }
public async Task create(CommandContext ctx, [Description("Nome do time"), RemainingText] String nome) { List <EventoModel> eventos = new Evento().FindAll(_ => true); if (eventos.Count > 0) { TimeModel time = new TimeModel { Nome = nome, LiderId = ctx.Member.Id, Jogadores = new[] { ctx.Member.Id }.ToList() }; List <Page> pages = new List <Page>(); eventos.ForEach(async e => pages.Add(new Page($"", new DiscordEmbedBuilder(await EmbedExtended.AsyncEventoEmbed(e))))); PaginationEmojis emojis = new PaginationEmojis { Left = DiscordEmoji.FromName(ctx.Client, ":arrow_left:"), Stop = DiscordEmoji.FromName(ctx.Client, ":stop_button:"), Right = DiscordEmoji.FromName(ctx.Client, ":arrow_right:"), SkipLeft = null, SkipRight = null }; var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed($"Selecione o evento que deseja participar. Depois clique em {emojis.Stop.ToString()} para confirmar.")); await ctx.Channel.SendPaginatedMessageAsync(ctx.User, pages.ToArray(), emojis, PaginationBehaviour.WrapAround, PaginationDeletion.Default, TimeSpan.FromMinutes(30)); var lastMsg = (await ctx.Channel.GetMessagesAfterAsync(msg.Id)).ToList().FirstOrDefault(x => x.Author == msg.Author && msg.Embeds.Count > 0); var id = int.Parse(lastMsg.Embeds[0].Fields.ToList().Find(x => x.Name == "Id").Value); var evento = eventos.Find(x => x.Id == id); if (new Time().Find(x => x.EventoId == id && x.LiderId == ctx.Member.Id) != null) { await lastMsg.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Você já possui um time nesse evento.")); } else { time.EventoId = id; await lastMsg.DeleteAsync(); if (evento.LimiteTimes == 0 || evento.Times == null || evento.Times.Count < evento.LimiteTimes) { new Time().Insert(time); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Selecionado : {evento.Nome}. Time criado.")); } else { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Inscrições para esse evento foram fechadas. Peça uma vaga aos organizadores do evento.")); } } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há eventos ativos no momento. Inscrição de times foi desativada.")); } }
public static async Task <DiscordEmbed> ToEmbedAsync(this Category category, CommandContext ctx) { var dict = new Dictionary <DiscordEmoji, DiscordRole>(); foreach (var entry in category.Data) { dict.Add(await ctx.Guild.GetEmojiAsync(entry.Key), ctx.Guild.GetRole(entry.Value)); } var embed = EmbedBase.OutputEmbed("").Mutate(x => x.WithAuthor(category.Name) .WithDescription("Click on a reaction to get a role, Click again to remove it") .AddField("Available Roles", $"{(dict.Count == 0 ? "None" : string.Join("\n", dict.Select(x => $"{x.Key} - {x.Value.Mention}")))}")
public async Task censoShow(CommandContext ctx, [Description("O Membro (ID/Menção)")] DiscordMember membro) { CensoModel dados = new Logic.Censo().Find(x => x.DiscordId == membro.Id); if (dados == null) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("O Membro não possui um censo nos registros.")); } else { await ctx.RespondAsync(embed : await EmbedExtended.Censo(dados)); } }
public async Task checkCommand(CommandContext ctx, [Description("Membro que será checado (Id/Menção)")] DiscordMember membro) { MembroModel perfil = new Membro().Find(x => x.DiscordId == membro.Id); if (perfil != null) { await ctx.RespondAsync(embed : await EmbedExtended.MemberProfile(perfil)); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse membro não possui um perfil")); } }
public async Task info(CommandContext ctx, [Description("O Canal (ID/Menção)")] DiscordChannel channel) { var info = new ReactChannel().Find(x => x.DiscordID == channel.Id); if (info != null) { await ctx.RespondAsync(embed : await EmbedExtended.ChannelInfo(info)); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse canal não foi adicionado.")); } }
public async Task apagar(CommandContext ctx) { List <EventoModel> eventos = new Evento().FindAll(_ => true); if (eventos.Count > 0) { List <Page> pages = new List <Page>(); eventos.ForEach(async e => pages.Add(new Page($"", new DiscordEmbedBuilder(await EmbedExtended.AsyncEventoEmbed(e))))); PaginationEmojis emojis = new PaginationEmojis { Left = DiscordEmoji.FromName(ctx.Client, ":arrow_left:"), Stop = DiscordEmoji.FromName(ctx.Client, ":stop_button:"), Right = DiscordEmoji.FromName(ctx.Client, ":arrow_right:"), SkipLeft = null, SkipRight = null }; var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed($"Selecione o evento a ser apagado, Depois clique em {emojis.Stop.ToString()} para confirmar.")); await ctx.Channel.SendPaginatedMessageAsync(ctx.User, pages.ToArray(), emojis, PaginationBehaviour.WrapAround, PaginationDeletion.Default, TimeSpan.FromMinutes(30)); var lastMsg = (await ctx.Channel.GetMessagesAfterAsync(msg.Id)).ToList().FirstOrDefault(x => x.Author == msg.Author && msg.Embeds.Count > 0); var id = int.Parse(lastMsg.Embeds[0].Fields.ToList().Find(x => x.Name == "Id").Value); var evento = eventos.Find(x => x.Id == id); await lastMsg.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.InputEmbed($"Selecionado : {evento.Nome}, Deseja apagar? [s/n]")); var input = await ctx.Message.GetNextMessageAsync(); switch (input.Result.Content.ToLowerInvariant()[0]) { case 's': case 'y': new Evento().Delete(evento); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Evento apagado com sucesso!")); break; case 'n': await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Comando cancelado.")); break; } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há eventos cadastrados no sistema. Considere criar alguns!")); } }
public async Task List(CommandContext ctx, [Description("Membro (Menção/ID)")] DiscordMember membro) { var infracoes = new Infracao().FindAll(x => x.IdInfrator == membro.Id); if (infracoes.Count == 0) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed($"{membro.Mention} possui ficha limpa!")); } else { foreach (InfracaoModel infra in infracoes) { await ctx.RespondAsync(embed : EmbedExtended.AsyncInfracaoEmbed(infra)); } } }
public async Task AddCommand(CommandContext ctx) { Pair p = new Pair(); var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Input Channel")); var inpt = await ctx.Message.GetNextMessageAsync(); var channel = ctx.Guild.Channels.ToList().Find(x => inpt.Result.Content.Contains(x.Value.Mention)); if (channel.Value != null) { p.InputPair = channel.Key; await msg.ModifyAsync(embed : EmbedBase.InputEmbed("Output Channel")); var outp = await inpt.Result.GetNextMessageAsync(); var ch = ctx.Guild.Channels.ToList().Find(x => outp.Result.Content.Contains(x.Value.Mention)); if (ch.Value != null) { p.OutputPair = ch.Key; await msg.ModifyAsync(embed : EmbedBase.InputEmbed("Name")); var namaeha = await outp.Result.GetNextMessageAsync(); p.Name = namaeha.Result.Content; if (Program.pairs.Any(x => x.InputPair == p.InputPair && x.OutputPair == p.OutputPair)) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed($"Command Failed.\n**A Pair is already configured with** <#{p.InputPair}> *->* <#{p.OutputPair}>.\n\nName : {p.Name}")); } else { Program.pairs.Add(p); File.WriteAllText(Directory.GetCurrentDirectory() + "/Pairs.json", JsonConvert.SerializeObject(Program.pairs, Formatting.Indented)); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Pair {p.Name} added sucessefully.")); } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed($"Command Failed.\n**Output Channel Not recognized.**\n\nMake sure the cannel is mentioned like in <#{ctx.Channel.Id}>")); } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed($"Command Failed.\n**Input Channel Not recognized.**\n\nMake sure the cannel is mentioned like in <#{ctx.Channel.Id}>")); } }
public async Task edit(CommandContext ctx, [Description("O novo nome"), RemainingText] string nome) { List <EventoModel> eventos = new Evento().FindAll(_ => true); if (eventos.Count > 0) { List <Page> pages = new List <Page>(); eventos.ForEach(async x => pages.Add(new Page("", new DiscordEmbedBuilder(await EmbedExtended.AsyncEventoEmbed(x))))); PaginationEmojis emojis = new PaginationEmojis { Left = DiscordEmoji.FromName(ctx.Client, ":arrow_left:"), Stop = DiscordEmoji.FromName(ctx.Client, ":stop_button:"), Right = DiscordEmoji.FromName(ctx.Client, ":arrow_right:"), SkipLeft = null, SkipRight = null }; var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed($"Selecione o evento que deseja adicionar o membro. Depois clique em {emojis.Stop.ToString()} para confirmar.")); await ctx.Channel.SendPaginatedMessageAsync(ctx.User, pages.ToArray(), emojis, PaginationBehaviour.WrapAround, PaginationDeletion.Default, TimeSpan.FromMinutes(30)); var lastMsg = (await ctx.Channel.GetMessagesAfterAsync(msg.Id)).ToList().FirstOrDefault(x => x.Author == msg.Author && msg.Embeds.Count > 0); var id = int.Parse(lastMsg.Embeds[0].Fields.ToList().Find(x => x.Name == "Id").Value); var evento = eventos.Find(x => x.Id == id); await lastMsg.DeleteAsync(); List <TimeModel> times = new Time().FindAll(x => x.EventoId == id && x.LiderId == ctx.Member.Id); if (times.Count > 0) { var time = times[0]; time.Nome = nome; new Time().Update(x => x.Id == time.Id, time); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Nome alterado para {time.Nome} com sucesso!")); } else { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Você não é lider de nenhum time neste evento.")); } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há eventos ativos no momento. Inscrição de times foi desativada.")); } }
public async Task criar(CommandContext ctx, [Description("O Líder do time (Id/Menção)")] DiscordMember lider, [Description("O Nome do time."), RemainingText] string nome) { List <EventoModel> eventos = new Evento().FindAll(_ => true); if (eventos.Count > 0) { List <Page> pages = new List <Page>(); eventos.ForEach(async e => pages.Add(new Page($"", new DiscordEmbedBuilder(await EmbedExtended.AsyncEventoEmbed(e))))); PaginationEmojis emojis = new PaginationEmojis { Left = DiscordEmoji.FromName(ctx.Client, ":arrow_left:"), Stop = DiscordEmoji.FromName(ctx.Client, ":stop_button:"), Right = DiscordEmoji.FromName(ctx.Client, ":arrow_right:"), SkipLeft = null, SkipRight = null }; var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed($"Selecione o evento. Depois clique em {emojis.Stop.ToString()} para confirmar.")); await ctx.Channel.SendPaginatedMessageAsync(ctx.User, pages.ToArray(), emojis, PaginationBehaviour.WrapAround, PaginationDeletion.Default, TimeSpan.FromMinutes(30)); var lastMsg = (await ctx.Channel.GetMessagesAfterAsync(msg.Id)).ToList().FirstOrDefault(x => x.Author == msg.Author && msg.Embeds.Count > 0); var id = int.Parse(lastMsg.Embeds[0].Fields.ToList().Find(x => x.Name == "Id").Value); var evento = eventos.Find(x => x.Id == id); await lastMsg.DeleteAsync(); TimeModel time = new TimeModel(); time.EventoId = evento.Id; time.Jogadores = new List <ulong> { lider.Id }; time.LiderId = lider.Id; time.Nome = nome; new Time().Insert(time); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Time criado com sucesso!")); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há nenhum evento ativo no momento. Considere criar um!")); } }
public async Task FakeDNDCommand(CommandContext ctx) { var role = ctx.Guild?.Roles.FirstOrDefault(x => x.Value.Name.ToLowerInvariant().Contains("fakednd")).Value; if (role == null) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("No FakeDND role was found.")); return; } if (ctx.Member.Roles.Contains(role)) { await ctx.Member.RevokeRoleAsync(role); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("FakeDND toggled off.")); return; } await ctx.Member.GrantRoleAsync(role); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("FakeDND toggled on.")); }
public async Task listar(CommandContext ctx) { List <EventoModel> eventos = new Evento().FindAll(_ => true); if (eventos.Count > 0) { List <Page> pages = new List <Page>(); eventos.ForEach(async e => pages.Add(new Page($"Lista de eventos ativos", new DiscordEmbedBuilder(await EmbedExtended.AsyncEventoEmbed(e))))); PaginationEmojis emojis = new PaginationEmojis { Left = DiscordEmoji.FromName(ctx.Client, ":arrow_left:"), Stop = DiscordEmoji.FromName(ctx.Client, ":stop_button:"), Right = DiscordEmoji.FromName(ctx.Client, ":arrow_right:"), SkipLeft = null, SkipRight = null }; await ctx.Channel.SendPaginatedMessageAsync(ctx.User, pages.ToArray(), emojis, PaginationBehaviour.WrapAround, PaginationDeletion.Default, TimeSpan.FromMinutes(30)); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não existem eventos ativos no momento.")); } }
public async Task DelCommand(CommandContext ctx) { var categories = System.categoryCache.Query().Where(_ => true).ToList(); var msg = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(categories.Select(x => $"<#{x.ChannelId}> - {x.Name}").ToList(), "Categories").Mutate(x => x.WithTitle("Select the category [#]"))); var response = await ctx.Message.GetNextMessageAsync(); if (response.TimedOut) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Command canceled.")); return; } int index = Math.Clamp(response.Result.FirstInt(), 0, categories.Count - 1); var category = categories[index]; var ch = ctx.Guild.GetChannel(category.ChannelId); var catmsg = await ch.GetMessageAsync(category.MessageId); await catmsg.DeleteAsync(); System.categoryCache.Delete(category.Id); System.Execute(); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Category : {category.Name} @ <#{category.ChannelId}> deleted.")); }
public async Task InitCommand(CommandContext ctx, [Description("The discord channel")] DiscordChannel channel, [RemainingText, Description("Name of the category")] string categoryName) { var Category = new Category { ChannelId = channel.Id, Name = categoryName.Trim() }; var categories = System.categoryCache.Query().Where(x => x.ChannelId == Category.ChannelId && x.Name == Category.Name).ToList(); if (categories.Any()) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("This category already exists on said channel.")); return; } var msg = await channel.SendMessageAsync(embed : await Category.ToEmbedAsync(ctx)); Category.MessageId = msg.Id; System.categoryCache.Insert(Category); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Category initialized.")); System.Execute(); }
public async Task Add(CommandContext ctx, [Description("Membro que será punido (Menção / ID)")] DiscordMember membro) { InfracaoModel infra = new InfracaoModel { IdInfrator = membro.Id, IdStaff = ctx.Member.Id, }; var info = await ctx.RespondAsync(embed : EmbedExtended.AsyncInfracaoEmbed(infra)); var botMsg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Motivo")); var result = await ctx.Message.GetNextMessageAsync(); infra.MotivoInfracao = result.Result.Content; await info.ModifyAsync(embed : EmbedExtended.AsyncInfracaoEmbed(infra)); await botMsg.ModifyAsync(embed : EmbedBase.InputEmbed("Será Preso? [s/n]")); result = await result.Result.GetNextMessageAsync(); infra.Preso = result.Result.Content.ToLowerInvariant()[0] == 'y' || result.Result.Content.ToLowerInvariant()[0] == 's'; await info.ModifyAsync(embed : EmbedExtended.AsyncInfracaoEmbed(infra)); PrisaoModel prisao = new PrisaoModel(); if (infra.Preso) { await botMsg.ModifyAsync(embed : EmbedBase.InputEmbed("Tempo [xM, xH]")); result = await result.Result.GetNextMessageAsync(); prisao = new PrisaoModel { Data = DateTime.Now.ToUniversalTime(), Cargos = membro.Roles.Select(x => x.Id).ToList(), }; if (result.Result.Content.ToLowerInvariant().Contains("h")) { Regex getUlong = new Regex(@"([0-9])+"); int i = 0; if (getUlong.IsMatch(result.Result.Content)) { i = int.Parse(getUlong.Match(result.Result.Content).ToString()); } TimeSpan s = TimeSpan.FromHours(i); prisao.Duracao = s; prisao.GuildId = ctx.Guild.Id; await Prender(membro, ctx.Guild); prisao.Elapsed = false; } else if (result.Result.Content.ToLowerInvariant().Contains("m")) { Regex getUlong = new Regex(@"([0-9])+"); int i = 0; if (getUlong.IsMatch(result.Result.Content)) { i = int.Parse(getUlong.Match(result.Result.Content).ToString()); } TimeSpan s = TimeSpan.FromMinutes(i); prisao.Duracao = s; prisao.GuildId = ctx.Guild.Id; await Prender(membro, ctx.Guild); prisao.Elapsed = false; } } await info.ModifyAsync(embed : EmbedExtended.AsyncInfracaoEmbed(infra)); await botMsg.DeleteAsync(); new Infracao().Insert(infra); prisao.InfraId = new Infracao().FindAll(x => x.IdInfrator == membro.Id).Last().Id; new Prisao().Insert(prisao); await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Infração Adicionada com Sucesso.")); }
public async Task soltarFailed(CommandContext ctx) => await ctx.RespondAsync(embed : EmbedBase.CommandHelpEmbed(ctx.Command));
public async Task AddFail(CommandContext ctx) { await ctx.RespondAsync(embed : EmbedBase.CommandHelpEmbed(ctx.Command)); }
public async Task PrefixError(CommandContext ctx) { var embed = EmbedBase.CommandHelpEmbed(ctx.Command); await ctx.RespondAsync(embed : embed); }
public async Task Command(CommandContext ctx) { var embed = EmbedBase.GroupHelpEmbed(ctx.Command); await ctx.RespondAsync(embed : embed); }
public async Task groupCommand(CommandContext ctx) => await ctx.RespondAsync(embed : EmbedBase.GroupHelpEmbed(ctx.Command, ctx));