public async Task SetNewcomerChannel(IChannel channel, ulong messageId, string emoteText, IRole role) { // <:emotename:123123132132> var emote = _emoteRegex.Split(emoteText); if (emote.Length == 1) { await ReplyAsync("Please use only custom emotes."); return; } var guildChannel = await Context.Guild.GetMessageChannelOrDefaultAsync(channel); if (guildChannel == null) { await ReplyAsync("Invalid channel."); return; } var message = await guildChannel.GetMessageAsync(messageId); if (message == null) { await ReplyAsync("Message not found."); return; } var emoteId = ulong.Parse(emote[2]); if (_settingsRepo.Cache.Any(x => x.ChannelId == channel.Id && x.MessageId == messageId && x.EmoteId == emoteId)) { await ReplyAsync("This channel is already set as newcomer channel"); return; } var newcomerSetting = new NewcomerSetting() { ChannelId = channel.Id, EmoteId = emoteId, MessageId = messageId, RoleId = role.Id }; await _settingsRepo.AddAsync(newcomerSetting); await ReplyAsync($"{channel.Name}, {messageId}, {emoteText}"); }
public async Task <ActionResult> Post([FromForm] CachedCar value) { try { value.Id = 0; return(Ok(await _cachedRepo.AddAsync(value))); } catch (InvalidOperationException ioe) { return(BadRequest(ioe.Message)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }