public async Task StopMonitoringMessageAsync([Summary("Optional message ID to stop monitoring")] int id = 0) { if (MonitorList.GetMonitoredMessage() == null) { await ReplyAsync("There is no message currently being monitored."); return; } string emoji = ReactionUtilities.emojiToCheck; var msg = await Context.Channel.GetMessageAsync(MonitorList.GetMonitoredMessage().Id) as RestUserMessage; //If the monitored message got deleted before !unmonitor was used, clear the message and reset. if (msg == null) { MonitorList.DeleteMonitoredMessage(); //Grab the member list from the server and unassign the role from anyone who has it. return; } var users = await msg.GetReactionUsersAsync(emoji); if (!users.Any()) { return; } foreach (RestUser user in users) { await ReactionUtilities.RemoveRoleFromUserAsync(user, Context.Guild); } MonitorList.DeleteMonitoredMessage(); await ReplyAsync("Message is no longer monitored and all reacted users have had their role unassigned."); }
public async Task MonitorMessageAsync([Summary("Optional message ID to monitor")] int id = 0) { var messages = await Context.Channel.GetMessagesAsync(Context.Message.Id, Direction.Before, 1).Flatten(); RestUserMessage msgToMonitor = (RestUserMessage)messages.FirstOrDefault(); await ReplyAsync(MonitorList.AddMonitoredMessage(msgToMonitor)); }
public static MonitorListViewModel Get(MonitorList sourceList) { MonitorListViewModel list = new MonitorListViewModel(); foreach (MonitorInfo item in sourceList) { list.Add(MonitorViewModel.New(item)); } return(list); }
private async Task ReactionRemoved(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { RestUserMessage msg = MonitorList.GetMonitoredMessage(); if (msg != null) { try { await ReactionUtilities.RemoveRoleFromUserAsync(channel, reaction); } catch (Exception e) { Console.WriteLine(e.Message); } } }
private async Task ReactionAdded(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { RestUserMessage msg = MonitorList.GetMonitoredMessage(); if (msg != null) { try { await ReactionUtilities.AddRoleToUserAsync(channel, reaction); } catch (Exception e) { Console.WriteLine(e.Message); await channel.SendMessageAsync("Something bad happened. Consult this bot's administrator."); } } }
private void UpdateMonitorList() { MonitorList.Clear(); foreach (Screen screen in Screen.AllScreens) { DisplayConfiguration.PHYSICAL_MONITOR mon = DisplayConfiguration.GetPhysicalMonitors(DisplayConfiguration.GetMonitorByBounds(screen.Bounds))[0]; string Name = screen.DeviceFriendlyName(); if (String.IsNullOrEmpty(Name)) { Name = "Generic Monitor"; } DisplayConfiguration.MonitorExtremums MonExtrs; try { MonExtrs = DisplayConfiguration.GetMonitorExtremums(mon); } catch { MonExtrs = new DisplayConfiguration.MonitorExtremums() { Min = 0, Max = 0 }; } MonitorList.Add(new MONITOR(Name, mon, MonExtrs.Min, MonExtrs.Max)); } Monitor_List_Combobox.ItemsSource = MonitorList; Monitor_List_Combobox.SelectedItem = MonitorList[0]; CurrentMonitor = MonitorList[0]; }