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; } }
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 sair(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 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.Jogadores.Any(y => y == ctx.Member.Id) || x.Reservas.Any(y => y == ctx.Member.Id))) != null) { var time = new Time().Find(x => x.EventoId == id && (x.Jogadores.Any(y => y == ctx.Member.Id) || x.Reservas.Any(y => y == ctx.Member.Id))); await lastMsg.DeleteAsync(); if (time.LiderId != ctx.Member.Id) { await msg.ModifyAsync(embed : EmbedBase.InputEmbed($"Você deseja sair de {time.Nome}?.[s/n]")); var input = await ctx.Message.GetNextMessageAsync(); switch (input.Result.Content.ToLowerInvariant().Trim()[0]) { case 'y': case 's': if (time.Jogadores.Contains(ctx.Member.Id)) { time.Jogadores.Remove(ctx.Member.Id); } if (time.Reservas.Contains(ctx.Member.Id)) { time.Reservas.Remove(ctx.Member.Id); } new Time().Update(x => x.Id == time.Id, time); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Você saiu do time com sucesso!")); break; default: await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Comando cancelado.")); break; } } else { await msg.ModifyAsync(embed : EmbedBase.InputEmbed($"Você deseja **apagar** {time.Nome}?.[s/n]")); var input = await ctx.Message.GetNextMessageAsync(); switch (input.Result.Content.ToLowerInvariant().Trim()[0]) { case 'y': case 's': new Time().Delete(time); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Time apagado com sucesso!")); break; default: await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Comando cancelado.")); break; } } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Você não participa 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 add(CommandContext ctx, [Description("O Membro que será adicionado (Menção/ID) ")] DiscordMember membro) { 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 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(); if (new Time().Find(x => x.EventoId == id && (x.Jogadores.Any(y => y == membro.Id) || (x.Reservas != null && x.Reservas.Any(y => y == membro.Id)))) != null) { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Esse membro já foi adicionado à um time.")); } else { if (new Time().Find(x => x.LiderId == ctx.Member.Id) != null) { var time = new Time().Find(x => x.LiderId == ctx.Member.Id && x.EventoId == evento.Id); if (evento.LimiteJogadores == 0 || time.Jogadores.Count < evento.LimiteJogadores) { time.Jogadores.Add(membro.Id); new Time().Update(x => x.Id == time.Id, time); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Membro adicionado com sucesso!")); } else if (evento.LimiteJogadores != 0 && time.Reservas != null && time.Reservas.Count < evento.LimiteReservas || time.Reservas == null && evento.LimiteReservas == 0 || time.Reservas == null) { if (!time.Jogadores.Any(x => x == membro.Id)) { if (time.Reservas == null) { time.Reservas = new List <ulong>(); } time.Reservas.Add(membro.Id); new Time().Update(x => x.Id == time.Id, time); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Reserva adicionado com sucesso!")); } } else { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Limite de membros atingido.")); } } else { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Você não é lider de nenhum time.")); } } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há eventos ativos no momento. Inscrição de times foi desativada.")); } }
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 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. 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(); if (evento.Times == null) { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há nenhum time neste evento.")); } else { List <TimeModel> times = new List <TimeModel>(); List <string> nomes = new List <string>(); Regex getUlong = new Regex(@"(?<!\.)\d+(?!\.)"); evento.Times.ForEach(x => times.Add(new Time().Find(y => y.Id == x))); times.ForEach(x => nomes.Add($"{x.Id} - {x.Nome}")); await msg.ModifyAsync(embed : EmbedBase.InputEmbed("Time q será apagado [Número]")); var list = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(nomes, $"Times em {evento.Nome}:")); var responce = await ctx.Message.GetNextMessageAsync(); if (getUlong.IsMatch(responce.Result.Content)) { int i = int.Parse(getUlong.Match(responce.Result.Content).ToString()); if (times.Any(x => x.Id == i)) { new Time().Delete(x => x.Id == i); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Time apagado com sucesso.")); } else { await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Número inválido. Comando Cancelado.")); } } } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há nenhum evento ativo no momento. Considere criar um!")); } }
public async Task role(CommandContext ctx, [Description("Operação (add/del)")] string operation) { switch (operation) { case "add": var message = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Canal do discord (ID/Menção)")); var responce = await ctx.Message.GetNextMessageAsync(); Regex getUlong = new Regex(@"(?<!\.)\d+(?!\.)"); var match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { ulong id = ulong.Parse(match); if (new ReactChannel().Find(x => x.DiscordID == id) != null) { DiscordChannel ch = ctx.Guild.GetChannel(id); var cat = new ReactCategory().FindAll(_ => true); List <string> names = new List <string>(); cat.ForEach(x => names.Add(x.Name)); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Numero da categoria que você quer apagar")); var list = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(names, "Categorias")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { var i = int.Parse(match); if (i <= names.Count) { var category = cat[i]; await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Emoji (Id/Menção)")); responce = await responce.Result.GetNextMessageAsync(); var getEmoji = new Regex(@"(\:\w*\:)"); match = getEmoji.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { var emoji = DiscordEmoji.FromName(ctx.Client, match); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Cargo (Id/Menção)")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { id = ulong.Parse(match); var role = ctx.Guild.GetRole(id); ReactRoleModel roleModel = new ReactRoleModel { RoleId = role.Id, EmojiId = emoji.Id, CategoryId = category.Id }; new ReactRole().Insert(roleModel); var catmsg = await ch.GetMessageAsync(category.MessageId); await catmsg.CreateReactionAsync(emoji); category = new ReactCategory().Find(x => x.Id == category.Id); await catmsg.ModifyAsync(embed : await EmbedExtended.ReactCategory(category)); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Cargo adicionado com sucesso!")); } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } } } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Número inválido. Comando Cancelado")); } } } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } break; case "del": message = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Canal do discord (ID/Menção)")); responce = await ctx.Message.GetNextMessageAsync(); getUlong = new Regex(@"(?<!\.)\d+(?!\.)"); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { ulong id = ulong.Parse(match); if (new ReactChannel().Find(x => x.DiscordID == id) != null) { DiscordChannel ch = ctx.Guild.GetChannel(id); var cat = new ReactCategory().FindAll(_ => true); List <string> names = new List <string>(); cat.ForEach(x => names.Add(x.Name)); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Numero da categoria que você quer apagar")); var list = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(names, "Categorias")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { var i = int.Parse(match); if (i <= names.Count) { var category = cat[i]; List <ReactRoleModel> roles = new List <ReactRoleModel>(); if (category.Roles != null) { category.Roles.ForEach(x => roles.Add(new ReactRole().Find(y => y.Id == x))); } if (roles.Count > 0) { List <string> role_string = new List <string>(); foreach (var r in roles) { var role = ctx.Guild.GetRole(r.RoleId); var emoji = DiscordEmoji.FromGuildEmote(ctx.Client, r.EmojiId); role_string.Add($"{emoji} - {role.Name}"); } await list.ModifyAsync(embed : EmbedBase.OrderedListEmbed(role_string, "Cargos")); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Numero do cargo à ser deletado")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { i = int.Parse(match); if (roles.Count >= i) { var rr = roles[i]; await list.DeleteAsync(); var emoji = DiscordEmoji.FromGuildEmote(ctx.Client, rr.EmojiId); new ReactRole().Delete(rr); category = new ReactCategory().Find(x => x.Id == category.Id); var catmsg = await ch.GetMessageAsync(category.MessageId); var members = await catmsg.GetReactionsAsync(emoji); members.ToList().ForEach(async x => await catmsg.DeleteReactionAsync(emoji, x)); await catmsg.ModifyAsync(embed : await EmbedExtended.ReactCategory(category)); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Cargo apagado com sucesso!")); } } } else { await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Essa categoria não possui cargos.")); } } } } } break; } }
public async Task edit(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); List <string> options = new List <string> { "Nome", "Limite de Jogadores/time", "Limite de reservas/time", "Quantidade max. de times" }; await msg.ModifyAsync(embed : EmbedBase.InputEmbed($"Selecionado : {evento.Nome}")); await lastMsg.ModifyAsync(embed : EmbedBase.OrderedListEmbed(options, " Selecione o que deseja editar [Número]")); var input = await ctx.Message.GetNextMessageAsync(); switch (input.Result.Content.ToLowerInvariant()[0]) { case '0': await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O novo nome:")); input = await input.Result.GetNextMessageAsync(); evento.Nome = input.Result.Content; new Evento().Update(x => x.Id == evento.Id, evento); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Nome modificado com sucesso!")); break; case '1': await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O novo limite (0 para remover):")); input = await input.Result.GetNextMessageAsync(); evento.LimiteJogadores = int.Parse(input.Result.Content); new Evento().Update(x => x.Id == evento.Id, evento); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Limite de jogadores modificado com sucesso!")); break; case '2': await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O novo limite (0 para remover):")); input = await input.Result.GetNextMessageAsync(); evento.LimiteReservas = int.Parse(input.Result.Content); new Evento().Update(x => x.Id == evento.Id, evento); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Limite de reservas modificado com sucesso!")); break; case '3': await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O novo limite (0 para remover):")); input = await input.Result.GetNextMessageAsync(); evento.LimiteTimes = int.Parse(input.Result.Content); new Evento().Update(x => x.Id == evento.Id, evento); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Limite de times modificado com sucesso!")); break; default: await lastMsg.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Comando cancelado. Valor inválido.")); break; } await lastMsg.ModifyAsync(embed : await EmbedExtended.AsyncEventoEmbed(evento)); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Não há eventos cadastrados no sistema. Considere criar alguns!")); } }
public async Task categoria(CommandContext ctx, [Description("Operação (add/del/edit)")] string operation) { switch (operation) { case "add": var message = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Canal do discord (ID/Menção)")); var responce = await ctx.Message.GetNextMessageAsync(); Regex getUlong = new Regex(@"(?<!\.)\d+(?!\.)"); var match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { ulong id = ulong.Parse(match); if (new ReactChannel().Find(x => x.DiscordID == id) != null) { DiscordChannel ch = ctx.Guild.GetChannel(id); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Nome da Categoria")); responce = await responce.Result.GetNextMessageAsync(); string nome = responce.Result.Content; string mensagem = ""; await message.ModifyAsync(embed : EmbedBase.InputEmbed("Gostaria de adicionar uma mensagem na categoria? [s/n]")); responce = await responce.Result.GetNextMessageAsync(); if (responce.Result.Content.ToLowerInvariant()[0] == 's') { await message.ModifyAsync(embed : EmbedBase.InputEmbed("Mensagem (Sobre :)")); responce = await responce.Result.GetNextMessageAsync(); mensagem = responce.Result.Content; } ReactCategoryModel cat = new ReactCategoryModel { ChannelId = ch.Id, Name = nome, Description = mensagem, }; var msg = await ch.SendMessageAsync(embed : await EmbedExtended.ReactCategory(cat)); cat.MessageId = msg.Id; new ReactCategory().Insert(cat); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Categoria adicionada com sucesso!")); } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse canal não foi configurado.")); } } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } break; case "del": message = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Canal do discord (ID/Menção)")); responce = await ctx.Message.GetNextMessageAsync(); getUlong = new Regex(@"(?<!\.)\d+(?!\.)"); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { ulong id = ulong.Parse(match); if (new ReactChannel().Find(x => x.DiscordID == id) != null) { DiscordChannel ch = ctx.Guild.GetChannel(id); var cat = new ReactCategory().FindAll(_ => true); List <string> names = new List <string>(); cat.ForEach(x => names.Add(x.Name)); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Numero da categoria que você quer apagar")); var list = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(names, "Categorias")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { var i = int.Parse(match); if (i <= names.Count) { var category = cat[i]; var catmsg = await ch.GetMessageAsync(category.MessageId); await message.ModifyAsync(embed : EmbedBase.InputEmbed($"Gostaria de apagar a categoria {category.Name}? [s/n]")); await list.ModifyAsync(embed : await EmbedExtended.ReactCategory(category)); responce = await ctx.Message.GetNextMessageAsync(); if (responce.Result.Content.ToLowerInvariant()[0] == 's') { new ReactCategory().Delete(category); await list.DeleteAsync(); await catmsg.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed($"Categoria {category.Name} apagada com sucesso!")); } } else { await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Número maior que o maximo da lista. Comando Cancelado.")); } } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse canal não foi configurado.")); } } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } break; case "edit": message = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Canal do discord (ID/Menção)")); responce = await ctx.Message.GetNextMessageAsync(); getUlong = new Regex(@"(?<!\.)\d+(?!\.)"); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { ulong id = ulong.Parse(match); if (new ReactChannel().Find(x => x.DiscordID == id) != null) { DiscordChannel ch = ctx.Guild.GetChannel(id); var cat = new ReactCategory().FindAll(_ => true); List <string> names = new List <string>(); cat.ForEach(x => names.Add(x.Name)); await message.ModifyAsync(embed : EmbedBase.InputEmbed("Numero da categoria que você quer editar")); var list = await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(names, "Categorias")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { var i = int.Parse(match); if (i <= names.Count) { var category = cat[i]; List <string> options = new List <string> { "nome", "mensagem" }; await message.ModifyAsync(embed : EmbedBase.InputEmbed("Numero da opção a ser editada")); await list.ModifyAsync(embed : EmbedBase.OrderedListEmbed(options, "Opções")); responce = await responce.Result.GetNextMessageAsync(); match = getUlong.Match(responce.Result.Content).ToString(); if (!String.IsNullOrWhiteSpace(match)) { i = int.Parse(match); if (i <= options.Count) { switch (i) { case 0: await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.InputEmbed("O novo nome da categoria")); responce = await responce.Result.GetNextMessageAsync(); category.Name = responce.Result.Content; var catmsg = await ch.GetMessageAsync(category.MessageId); await catmsg.ModifyAsync(embed : await EmbedExtended.ReactCategory(category)); new ReactCategory().Update(x => x.Id == category.Id, category); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Categoria modificada com sucesso!")); break; case 1: await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.InputEmbed("A nova mensagem da categoria")); responce = await responce.Result.GetNextMessageAsync(); category.Description = responce.Result.Content; catmsg = await ch.GetMessageAsync(category.MessageId); await catmsg.ModifyAsync(embed : await EmbedExtended.ReactCategory(category)); new ReactCategory().Update(x => x.Id == category.Id, category); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Categoria modificada com sucesso!")); break; } } else { await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Número maior que o maximo da lista. Comando Cancelado.")); } } else { await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } } else { await list.DeleteAsync(); await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Número maior que o maximo da lista. Comando Cancelado.")); } } } else { await ctx.RespondAsync(embed : EmbedBase.OutputEmbed("Esse canal não foi configurado.")); } } else { await message.ModifyAsync(embed : EmbedBase.OutputEmbed("Mensagem inválida. Comando Cancelado")); } break; default: break; } }
public async Task criar(CommandContext ctx, [Description("Nome do evento"), RemainingText] string nome) { EventoModel evento = new EventoModel { Nome = nome }; var dados = await ctx.RespondAsync(embed : await EmbedExtended.AsyncEventoEmbed(evento)); var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Número max. de times [(s/n), número]")); var input = await ctx.Message.GetNextMessageAsync(); if (char.IsNumber(input.Result.Content.ToLowerInvariant()[0])) { Regex getUlong = new Regex(@"([0-9])+"); Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteTimes = i; } else { //TODO: Add an yes/no question to the Utils. switch (input.Result.Content.ToLowerInvariant()[0]) { case 's': case 'y': Regex getUlong = new Regex(@"([0-9])+"); if (getUlong.IsMatch(input.Result.Content.ToLowerInvariant())) { Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteTimes = i; } else { await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O Número do limite.")); input = await input.Result.GetNextMessageAsync(); if (getUlong.IsMatch(input.Result.Content.ToLowerInvariant())) { Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteTimes = i; } else { await dados.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Número inválido. Comando cancelado.")); } } break; case 'n': evento.LimiteTimes = 0; break; } } await dados.ModifyAsync(embed : await EmbedExtended.AsyncEventoEmbed(evento)); await msg.ModifyAsync(embed : EmbedBase.InputEmbed("Número max. de jogadores [(s/n), número]")); input = await input.Result.GetNextMessageAsync(); if (char.IsNumber(input.Result.Content.ToLowerInvariant()[0])) { Regex getUlong = new Regex(@"([0-9])+"); Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteJogadores = i; } else { switch (input.Result.Content.ToLowerInvariant()[0]) { case 's': case 'y': Regex getUlong = new Regex(@"([0-9])+"); if (getUlong.IsMatch(input.Result.Content.ToLowerInvariant())) { Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteJogadores = i; } else { await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O Número do limite.")); input = await input.Result.GetNextMessageAsync(); if (getUlong.IsMatch(input.Result.Content.ToLowerInvariant())) { Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteJogadores = i; } else { await dados.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Número inválido. Comando cancelado.")); } } break; case 'n': evento.LimiteJogadores = 0; break; } } await dados.ModifyAsync(embed : await EmbedExtended.AsyncEventoEmbed(evento)); await msg.ModifyAsync(embed : EmbedBase.InputEmbed("Número max. de reservas [(s/n), número]")); input = await input.Result.GetNextMessageAsync(); if (char.IsNumber(input.Result.Content.ToLowerInvariant()[0])) { Regex getUlong = new Regex(@"([0-9])+"); Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteReservas = i; } else { switch (input.Result.Content.ToLowerInvariant()[0]) { case 's': case 'y': Regex getUlong = new Regex(@"([0-9])+"); if (getUlong.IsMatch(input.Result.Content.ToLowerInvariant())) { Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteReservas = i; } else { await msg.ModifyAsync(embed : EmbedBase.InputEmbed("O Número do limite.")); input = await input.Result.GetNextMessageAsync(); if (getUlong.IsMatch(input.Result.Content.ToLowerInvariant())) { Match match = getUlong.Match(input.Result.Content.ToLowerInvariant()); int i = int.Parse(match.ToString()); evento.LimiteReservas = i; } else { await dados.DeleteAsync(); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Número inválido. Comando cancelado.")); } } break; case 'n': evento.LimiteReservas = 0; break; } } await dados.ModifyAsync(embed : await EmbedExtended.AsyncEventoEmbed(evento)); new Evento().Insert(evento); await msg.ModifyAsync(embed : EmbedBase.OutputEmbed("Evento adicionado com sucesso!")); }