public override async Task <ResultCompletionData> ExecuteResultAsync(AbyssRequestContext context) { var message = await context.Channel.SendMessageAsync(null, false, new EmbedBuilder() .WithTitle("You've been telling me lies, hun.") .WithDescription(Reason) .WithColor(ErrorColor) .WithTimestamp(DateTimeOffset.Now) .WithFooter($"Requested by: {context.Invoker.Format()}", context.Invoker.GetEffectiveAvatarUrl()) .Build()); return(new ResultCompletionData(message)); }
public override async Task <ResultCompletionData> ExecuteResultAsync(AbyssRequestContext context) { if (!context.BotUser.GetPermissions(context.Channel).SendMessages) { return(new ResultCompletionData()); } if (Attachments.Length > 0 && !context.BotUser.GetPermissions(context.Channel).AttachFiles) { return(new ResultCompletionData()); } var messages = new List <RestUserMessage>(); if (Attachments.Length == 1) { var attach0 = Attachments.First(); messages.Add(await context.Channel.SendFileAsync(attach0.Stream, attach0.Filename, Message, false, Embed?.Build())); } else if (Attachments.Length > 0) { foreach (var attach in Attachments) { messages.Add(await context.Channel.SendFileAsync(attach.Stream, attach.Filename, null)); } if (Message != null || Embed != null) { messages.Add(await context.Channel.SendMessageAsync(Message, false, Embed?.Build())); } } else { messages.Add(await context.Channel.SendMessageAsync(Message, false, Embed?.Build())); } return(new ResultCompletionData(messages.ToArray())); }
public override Task <ResultCompletionData> ExecuteResultAsync(AbyssRequestContext context) { return(Task.FromResult(new ResultCompletionData())); }
public abstract Task <ResultCompletionData> ExecuteResultAsync(AbyssRequestContext context);
public EvaluationHelper(AbyssRequestContext context) { Context = context; }
public static EmbedBuilder WithRequesterFooter(this EmbedBuilder builder, AbyssRequestContext context) { return(builder.WithFooter($"Requested by {context.Invoker.Format()}", context.Invoker.GetEffectiveAvatarUrl())); }
public string GetDescription(AbyssRequestContext ctx) => $"{ctx.Services.GetRequiredService<AbyssConfig>().Emotes.StaffEmote} You have to be my current owner.";
public override async Task <ResultCompletionData> ExecuteResultAsync(AbyssRequestContext context) { var message = await context.ReplyAsync(":ok_hand:"); return(new ResultCompletionData(message)); }
public string GetDescription(AbyssRequestContext requestContext) => ChannelPermissions.Count > 0 ? $"You need these channel-level permissions: {string.Join(", ", ChannelPermissions.Select(a => a.Humanize()))}." : $"You need these server-level permissions: {string.Join(", ", GuildPermissions.Select(a => a.Humanize()))}.";
public string GetDescription(AbyssRequestContext requestContext) => "The provided user can't be you.";
public string GetDescription(AbyssRequestContext requestContext) => "We must be in one of the following servers: " + string.Join(", ", Ids) + ".";
public string GetDescription(AbyssRequestContext context) => "We must be in an NSFW channel.";
public async Task ReceiveMessageAsync(SocketMessage incomingMessage) { if (!(incomingMessage is SocketUserMessage message) || message.Author is SocketWebhookUser || message.Author.IsBot) { return; } if (!(message.Channel is SocketGuildChannel)) { await message.Channel.TrySendMessageAsync( "Sorry, but I can only respond to commands in servers. Please try using your command in any of the servers that I share with you!") .ConfigureAwait(false); _failedCommandsTracking.LogError(LoggingEventIds.UserDirectMessaged, $"Received direct message from {message.Author}, ignoring."); return; } var argPos = 0; if (!message.HasStringPrefix(_config.CommandPrefix, ref argPos) && !message.HasMentionPrefix(_discordClient.CurrentUser, ref argPos)) { return; } var context = new AbyssRequestContext(message, _services); var requestString = message.Content.Substring(argPos); try { var result = await _commandService.ExecuteAsync(requestString, context, context.Services).ConfigureAwait(false); if (result.IsSuccessful) { if (!(result is SuccessfulResult)) { CommandSuccesses++; // SuccessfulResult indicates a RunMode.Async } return; } switch (result) { case CommandResult _: return; case CommandNotFoundResult cnfr: _failedCommandsTracking.LogWarning(LoggingEventIds.UnknownCommand, $"No command found matching {requestString} (message {message.Id} - channel {message.Channel.Name}/{message.Channel.Id} - guild {context.Guild.Name}/{context.Guild.Id})"); await context.Message.AddReactionAsync(UnknownCommandReaction).ConfigureAwait(false); return; case ExecutionFailedResult _: return; case ChecksFailedResult cfr: _failedCommandsTracking.LogWarning(LoggingEventIds.ChecksFailed, $"{cfr.FailedChecks.Count} checks ({string.Join(", ", cfr.FailedChecks.Select(c => c.Check.GetType().Name))}) " + $"failed for command {cfr.Command.Name} (message {message.Id} - channel {message.Channel.Name}/{message.Channel.Id} - guild {context.Guild.Name}/{context.Guild.Id})"); if (cfr.FailedChecks.Count == 1 && cfr.FailedChecks.FirstOrDefault().Check.GetType() .CustomAttributes.Any(a => a.AttributeType == typeof(SilentCheckAttribute))) { break; } await context.Channel.SendMessageAsync(embed : new EmbedBuilder() .WithTitle( $"No can do.") .WithDescription("Can't do that, because: \n" + string.Join("\n", cfr.FailedChecks.Where(a => a.Check.GetType().CustomAttributes.All(b => b.AttributeType != typeof(SilentCheckAttribute))) .Select(a => $"- {a.Result.Reason}"))) .WithColor(Color.Red) .WithFooter( $"{(cfr.Command == null ? $"Module {cfr.Module.Name}" : $"Command {cfr.Command.Name} in module {cfr.Command.Module.Name}")}, " + $"executed by {context.Invoker.Format()}") .WithCurrentTimestamp() .Build()).ConfigureAwait(false); break;