/// <summary> /// Convert a list of notifications to a presentable string. /// </summary> /// <param name="jobs"></param> /// <returns></returns> string NotificationsToString(List <NotificationJob> jobs) { StringBuilder reply = new StringBuilder(); for (int i = 0; i < jobs.Count; i++) { NotificationJob job = jobs[i]; DateTime time = JobModule.GetNextCall(job); string shorthand = job.Message; if (shorthand.Length > 40) { shorthand = shorthand.Substring(0, 40) + "..."; } reply.Append($"{i}: {time} to {string.Join(',', GetChannels(job.Channels))} by {job.Creator} say {shorthand}\n"); } if (jobs.Count == 0) { reply.Append("No notifications."); } return(reply.ToString()); }
/// <summary> /// Say a servere notification to the correct channels /// </summary> /// <param name="job"></param> /// <param name="context"></param> /// <returns></returns> async Task SayNotificationJob(NotificationJob job, MethodContext context) { SetContext(context); foreach (string channel in job.Channels) { switch (channel) { case "pm": case "dm": case "me": IGuildUser user = GetUser(job.Creator, true); await user?.SendMessageAsync(job.Message); break; default: IMessageChannel messageChannel = GetChannel <SocketGuildChannel>(channel, false) as IMessageChannel; await messageChannel?.SendMessageAsync(job.Message); break; } } }