/// <summary> /// Initializes a new instance of the <see cref="NoteCommands"/> class. /// </summary> /// <param name="notes">The moderation service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public NoteCommands ( NoteService notes, UserFeedbackService feedback, InteractivityService interactivity, ChannelLoggingService logging ) { _notes = notes; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="NoteCommands"/> class. /// </summary> /// <param name="notes">The moderation service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public NoteCommands ( [NotNull] NoteService notes, [NotNull] UserFeedbackService feedback, [NotNull] InteractivityService interactivity, [NotNull] ChannelLoggingService logging ) { _notes = notes; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
private async Task <OperationResult> RescindBanIfExpiredAsync ( ChannelLoggingService loggingService, BanService bans, SocketGuild guild, UserBan ban, CancellationToken ct ) { if (ct.IsCancellationRequested) { return(OperationResult.FromError("Operation was cancelled.")); } if (!(ban.ExpiresOn <= DateTime.UtcNow)) { // No rescinding is needed, so we'll just bail out return(OperationResult.FromSuccess()); } var rescinder = guild.GetUser(this.Client.CurrentUser.Id); var notifyResult = await loggingService.NotifyUserUnbannedAsync(ban, rescinder); if (!notifyResult.IsSuccess) { return(OperationResult.FromError(notifyResult)); } var deleteResult = await bans.DeleteBanAsync(ban, ct); if (!deleteResult.IsSuccess) { return(OperationResult.FromError(deleteResult)); } try { await guild.RemoveBanAsync((ulong)ban.User.DiscordID); } catch (HttpException hex) when(hex.HttpCode == HttpStatusCode.NotFound) { // Already unbanned return(OperationResult.FromSuccess()); } catch (Exception ex) { return(OperationResult.FromError(ex)); } return(OperationResult.FromSuccess()); }
/// <summary> /// Initializes a new instance of the <see cref="NoteCommands"/> class. /// </summary> /// <param name="notes">The moderation service.</param> /// <param name="logging">The logging service.</param> /// <param name="context">The command context.</param> /// <param name="userAPI">The user API.</param> /// <param name="feedback">The feedback service.</param> public NoteCommands ( NoteService notes, ChannelLoggingService logging, ICommandContext context, IDiscordRestUserAPI userAPI, FeedbackService feedback ) { _notes = notes; _logging = logging; _context = context; _userAPI = userAPI; _feedback = feedback; }
/// <summary> /// Initializes a new instance of the <see cref="BanCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="bans">The ban service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public BanCommands ( [NotNull] ModerationService moderation, [NotNull] BanService bans, [NotNull] UserFeedbackService feedback, [NotNull] InteractivityService interactivity, [NotNull] ChannelLoggingService logging ) { _moderation = moderation; _bans = bans; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="WarningCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="warnings">The warning service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public WarningCommands ( [NotNull] ModerationService moderation, [NotNull] WarningService warnings, [NotNull] UserFeedbackService feedback, [NotNull] InteractivityService interactivity, [NotNull] ChannelLoggingService logging ) { _moderation = moderation; _warnings = warnings; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="BanCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="bans">The ban service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public BanCommands ( ModerationService moderation, BanService bans, UserFeedbackService feedback, InteractivityService interactivity, ChannelLoggingService logging ) { _moderation = moderation; _bans = bans; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="WarningCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="warnings">The warning service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="interactivity">The interactivity service.</param> /// <param name="logging">The logging service.</param> public WarningCommands ( ModerationService moderation, WarningService warnings, UserFeedbackService feedback, InteractivityService interactivity, ChannelLoggingService logging ) { _moderation = moderation; _warnings = warnings; _feedback = feedback; _interactivity = interactivity; _logging = logging; }
/// <summary> /// Initializes a new instance of the <see cref="WarningCommands"/> class. /// </summary> /// <param name="moderation">The moderation service.</param> /// <param name="warnings">The warning service.</param> /// <param name="feedback">The feedback service.</param> /// <param name="logging">The logging service.</param> /// <param name="userAPI">The user API.</param> /// <param name="context">The command context.</param> public WarningCommands ( ModerationService moderation, WarningService warnings, FeedbackService feedback, ChannelLoggingService logging, IDiscordRestUserAPI userAPI, ICommandContext context ) { _moderation = moderation; _warnings = warnings; _feedback = feedback; _logging = logging; _userAPI = userAPI; _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="BanCommands"/> class. /// </summary> /// <param name="bans">The ban service.</param> /// <param name="logging">The logging service.</param> /// <param name="context">The command context.</param> /// <param name="guildAPI">The guild API.</param> /// <param name="feedback">The feedback service.</param> /// <param name="userAPI">The user API.</param> public BanCommands ( BanService bans, ChannelLoggingService logging, ICommandContext context, IDiscordRestGuildAPI guildAPI, FeedbackService feedback, IDiscordRestUserAPI userAPI ) { _bans = bans; _logging = logging; _context = context; _guildAPI = guildAPI; _feedback = feedback; _userAPI = userAPI; }
private async Task <OperationResult> RescindWarningIfExpiredAsync ( ChannelLoggingService loggingService, WarningService warnings, SocketGuild guild, UserWarning warning, CancellationToken ct ) { if (ct.IsCancellationRequested) { return(OperationResult.FromError("Operation was cancelled.")); } if (!(warning.ExpiresOn <= DateTime.UtcNow)) { // No rescinding is needed, so we'll just bail out return(OperationResult.FromSuccess()); } var rescinder = guild.GetUser(this.Client.CurrentUser.Id); var notifyResult = await loggingService.NotifyUserWarningRemovedAsync(warning, rescinder); if (!notifyResult.IsSuccess) { return(OperationResult.FromError(notifyResult)); } var deleteResult = await warnings.DeleteWarningAsync(warning, ct); if (!deleteResult.IsSuccess) { return(OperationResult.FromError(deleteResult)); } return(OperationResult.FromSuccess()); }
/// <summary> /// Initializes a new instance of the <see cref="EventLoggingResponder"/> class. /// </summary> /// <param name="channelLogging">The channel logging service.</param> /// <param name="cache">The cache.</param> public EventLoggingResponder(ChannelLoggingService channelLogging, IMemoryCache cache) { _channelLogging = channelLogging; _cache = cache; }
/// <summary> /// Initializes a new instance of the <see cref="EventLoggingBehaviour"/> class. /// </summary> /// <param name="client">The Discord client in use.</param> /// <param name="logging">The logging service.</param> public EventLoggingBehaviour([NotNull] DiscordSocketClient client, [NotNull] ChannelLoggingService logging) : base(client) { _logging = logging; }