public async Task CreatePasta(EventContext e) { if (e.Arguments.Pack.Length < 2) { await e.ErrorEmbed(e.Locale.GetString("createpasta_error_no_content")) .ToEmbed().QueueToChannelAsync(e.Channel); return; } e.Arguments.Take(out string id); string text = e.Arguments.Pack.TakeAll(); if (Regex.IsMatch(text, "(http[s]://)?((discord.gg)|(discordapp.com/invite))/([A-Za-z0-9]+)", RegexOptions.IgnoreCase)) { throw new PastaInviteException(); } using (var context = new MikiContext()) { await GlobalPasta.AddAsync(context, id, text, (long)e.Author.Id); await context.SaveChangesAsync(); } await e.SuccessEmbed(e.Locale.GetString("miki_module_pasta_create_success", id)) .QueueToChannelAsync(e.Channel); }
public async Task CreatePasta(EventContext e) { if (e.Arguments.Count < 2) { e.ErrorEmbed(e.GetResource("createpasta_error_no_content")) .ToEmbed().QueueToChannel(e.Channel); return; } ArgObject arg = e.Arguments.FirstOrDefault(); string id = arg.Argument; arg = arg.Next(); string text = arg.TakeUntilEnd().Argument; using (var context = new MikiContext()) { await GlobalPasta.AddAsync(context, id, text, (long)e.Author.Id); await context.SaveChangesAsync(); } Utils.SuccessEmbed(e.Channel.Id, e.GetResource("miki_module_pasta_create_success", id)) .QueueToChannel(e.Channel); }
public async Task CreatePasta(EventContext e) { if (e.Arguments.Count < 2) { e.ErrorEmbed(e.Locale.GetString("createpasta_error_no_content")) .ToEmbed().QueueToChannel(e.Channel); return; } ArgObject arg = e.Arguments.FirstOrDefault(); string id = arg.Argument; arg = arg.Next(); string text = arg.TakeUntilEnd().Argument; if (Regex.IsMatch(text, "(http[s]://)?((discord.gg)|(discordapp.com/invite))/([A-Za-z0-9]+)", RegexOptions.IgnoreCase)) { throw new Exception("You can't add discord invites!"); } using (var context = new MikiContext()) { await GlobalPasta.AddAsync(context, id, text, (long)e.Author.Id); await context.SaveChangesAsync(); } e.SuccessEmbed(e.Locale.GetString("miki_module_pasta_create_success", id)) .QueueToChannel(e.Channel); }