public async Task SubmitAction(string title, string description) { var discordUser = _stewardContext.DiscordUsers.SingleOrDefault(du => du.DiscordId == Context.User.Id.ToString()); if (title.Length > 200) { await ReplyAsync("Title must be shorter than 200 characters."); return; } if (description.Length > 1000) { await ReplyAsync("Description must be shorter than 1800 characters."); return; } StaffAction action = new StaffAction() { ActionTitle = title, ActionDescription = description, Status = StaffActionStatus.TODO, SubmitterId = discordUser.DiscordId, Submitter = discordUser }; _stewardContext.StaffActions.Add(action); await _stewardContext.SaveChangesAsync(); var StaffChannels = _stewardContext.StaffActionChannels.ToList(); var embedBuilder = _staffActionService.BuildStaffActionMessage(action); foreach (var staffChannel in StaffChannels.Select(staffchannel => _client.GetChannel(ulong.Parse(staffchannel.ChannelId)) as SocketTextChannel)) { try { var message = await staffChannel.SendMessageAsync("", false, embedBuilder.Build()); action.MessageId = message.Id.ToString(); } catch (NullReferenceException e) { Console.WriteLine(e.StackTrace); //nothing, I just don't want it to crash the command } } _stewardContext.StaffActions.Update(action); await _stewardContext.SaveChangesAsync(); await ReplyAsync("Action submitted."); }
public EmbedBuilder BuildStaffActionMessage(StaffAction staffAction) { var submitter = _client.GetUser(ulong.Parse(staffAction.SubmitterId)); var embedBuilder = new EmbedBuilder { Color = Color.Purple, Title = staffAction.ActionTitle + " - " + staffAction.StaffActionId.ToString() + " - " + submitter.Username, }; EmbedFieldBuilder embedFieldBuilder; if (staffAction.AssignedToId == null) { embedFieldBuilder = new EmbedFieldBuilder { Value = staffAction.ActionDescription, Name = staffAction.Status.ToString(), IsInline = false }; } else { var assignedStaff = _client.GetUser(ulong.Parse(staffAction.AssignedToId)); embedFieldBuilder = new EmbedFieldBuilder { Value = staffAction.ActionDescription, Name = staffAction.Status.ToString() + " : " + assignedStaff.Username, IsInline = false }; } embedBuilder.AddField(embedFieldBuilder); embedBuilder.AddField(new EmbedFieldBuilder { Name = "Response", Value = staffAction.ActionResponse == null ? "None." : staffAction.ActionResponse }); return(embedBuilder); }
public void ChangeStatus(StaffAction newStatus) { if (newStatus == StaffAction.performingJobAction) { carriedOutAction = true; } else { carriedOutAction = false; } if (newStatus == StaffAction.leavingStore) { if (outside) { GeneratePathToSidewalkEnd(); return; } } currentAction = newStatus; }
/// <summary> /// 绘制一个标尺 /// </summary> /// <param name="penColor"></param> /// <param name="lineWidth"></param> /// <param name="fillColor"></param> public StaffAction StaffAction(Color?penColor = null, int lineWidth = 1, Color?fillColor = null, dynamic Element = null) { if (penColor == null) { penColor = Colors.Black; } var a = new StaffAction(); a.Geometry.Element = Element; a.Geometry.PenColor = penColor.Value; a.Geometry.LineWidth = lineWidth; if (fillColor != null) { a.Geometry.FillColor = fillColor.Value; } DrawingControl.SetAction(a); LastAction = a; return(a); }
public async Task NotifyUser(StaffAction staffAction) { var submitter = _client.GetUser(ulong.Parse(staffAction.SubmitterId)); var embedBuilder = new EmbedBuilder { Color = Color.Purple, Title = "Your Action has been updated to the following:", }; embedBuilder.AddField(new EmbedFieldBuilder { Name = staffAction.ActionTitle + " - " + staffAction.StaffActionId.ToString(), Value = staffAction.ActionDescription, IsInline = false }); embedBuilder.AddField(new EmbedFieldBuilder { Name = staffAction.Status.ToString() + " - Response:", Value = staffAction.ActionResponse == null ? "None" : staffAction.ActionResponse }); embedBuilder.AddField(new EmbedFieldBuilder { Name = "Assigned to Staff: ", Value = staffAction.AssignedToId == null ? "No Staff Assigned" : _client.GetUser(ulong.Parse(staffAction.AssignedToId)).Username }); try { await submitter.SendMessageAsync("", false, embedBuilder.Build()); } catch (NullReferenceException e) { Console.WriteLine(e.StackTrace); //nothing, I just don't want it to crash the command } }