public async Task <RuntimeResult> CheckSummaryAsync(SocketUser user = null) { var targetUser = user ?? Context.User; var record = await UserRepository.GetOrCreateProfileAsync(targetUser).ConfigureAwait(false); return(CommandRuntimeResult.FromInfo($"Current Summary: {Format.Bold(record.Summary)}")); }
public Task <RuntimeResult> CheckFriendCodeAsync(SocketUser user = null) { var targetUser = user ?? Context.User; var record = UserRepository.GetGame(targetUser); return(Task.FromResult <RuntimeResult>(record?.NintendoFriendCode == null ? CommandRuntimeResult.FromError("User hasn't setup their Nintendo Friend Code yet!") : CommandRuntimeResult.FromInfo( $"{targetUser.Mention}'s Nintendo Friend Code: {Format.Bold(record.NintendoFriendCode)}"))); }
public Task <RuntimeResult> CheckRiotAsync(SocketUser user = null) { var targetUser = user ?? Context.User; var record = UserRepository.GetGame(targetUser); return(Task.FromResult <RuntimeResult>(record?.RiotId == null ? CommandRuntimeResult.FromError("User hasn't setup their Riot Id yet!") : CommandRuntimeResult.FromInfo( $"{targetUser.Mention}'s Riot Id: {Format.Bold(record.RiotId)}"))); }
public Task <RuntimeResult> ExpandMemeAsync([Remainder] string input) { var regexMatch = Regex.Match(Context.Message.Content, $@"\b({input})\b"); string parsedInput = Context.Message.Resolve(regexMatch.Success ? regexMatch.Index : Context.Message.Content.IndexOf(input, StringComparison.OrdinalIgnoreCase)); var sb = new StringBuilder(); foreach (char c in parsedInput) { if (c == ' ') { continue; } sb.Append(c); sb.Append(' '); } return(Task.FromResult <RuntimeResult>(CommandRuntimeResult.FromInfo(sb))); }
public async Task <RuntimeResult> SetLogChannelAsync(SocketTextChannel channel = null) { var record = await CoreRepository.GetOrCreateActivityAsync(Context.Guild).ConfigureAwait(false); if (channel == null) { var targetChannel = Context.Guild.GetTextChannel(record.LogChannel); return(targetChannel == null ? CommandRuntimeResult.FromError("You have not set up a valid log channel yet!") : CommandRuntimeResult.FromInfo($"The current log channel is: {Format.Bold(targetChannel.Name)}")); } if (record.LogChannel == channel.Id) { return(CommandRuntimeResult.FromInfo("The current log channel is already the specified channel!")); } record.LogChannel = channel.Id; await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false); return(CommandRuntimeResult.FromSuccess($"The current log channel has been set to {Format.Bold(channel.Name)}!")); }
public async Task <RuntimeResult> ReportIncidentAsync() { // #1, query guild from user. var guilds = Context.Client.Guilds.Where(guild => guild.Users.Any(user => user.Id == Context.User.Id)) .ToList(); var guildBuilder = new StringBuilder("Which guild would you like to report to? (Choose by number)\n\n"); int guildCount = 0; foreach (var guild in guilds) { guildBuilder.AppendLine($"{guildCount}. {guild.Name}"); guildCount++; } await ReplyAsync("", embed : EmbedHelper.FromInfo(EmbedTitle, guildBuilder.ToString().Truncate(2000)).Build()).ConfigureAwait(false); var selectionMessage = await InteractiveService.NextMessageAsync(Context, timeout : _responseTimeout).ConfigureAwait(false); if (selectionMessage == null) { return(CommandRuntimeResult.FromError($"You did not reply in {_responseTimeout.Humanize()}.")); } if (!int.TryParse(_numberRegex.Match(selectionMessage.Content)?.Value, out int selection) || selection > guilds.Count) { return(CommandRuntimeResult.FromError("You did not pick a valid selection.")); } // #2, query report from user. // TODO: Allow users to upload more than one image. await ReplyAsync("", embed : EmbedHelper.FromInfo(EmbedTitle, "Please describe the incident in details, preferably with evidence.").Build()).ConfigureAwait(false); var reportMessage = await InteractiveService.NextMessageAsync(Context, timeout : _responseTimeout).ConfigureAwait(false); if (reportMessage == null) { return(CommandRuntimeResult.FromError($"You did not reply in {_responseTimeout.Humanize()}.")); } string reportContent = reportMessage.Content; if (reportContent.Length > 2048) { return(CommandRuntimeResult.FromError("Your report was too long. Please start over.")); } // #2.1, confirm report from user. var reportEmbed = new EmbedBuilder { Author = new EmbedAuthorBuilder { Name = $"A new report has been filed by {Context.User}...", IconUrl = Context.User.GetAvatarUrlOrDefault() }, Description = reportContent, ThumbnailUrl = Config.Icons.Warning, Color = Color.Red }; if (reportMessage.Attachments.Any()) { reportEmbed.AddField("Attachments", string.Join(", ", reportMessage.Attachments.Select(x => x.Url))); } reportEmbed.AddField("Report time", DateTimeOffset.UtcNow); await ReplyAsync("Please review your report. Enter Y to confirm.", embed : reportEmbed.Build()).ConfigureAwait(false); var confirmMessage = await InteractiveService.NextMessageAsync(Context, timeout : _responseTimeout).ConfigureAwait(false); if (confirmMessage == null) { return(CommandRuntimeResult.FromError($"You did not reply in {_responseTimeout.Humanize()}.")); } if (!confirmMessage.Content.ToLower().Contains("y")) { return(CommandRuntimeResult.FromInfo("Dropping report...")); } // #3, send the report. var reportChannel = await GetReportChannelAsync(guilds[selection]).ConfigureAwait(false); var reportRoles = await GetModeratorRolesAsync(guilds[selection]).ConfigureAwait(false); await reportChannel.SendMessageAsync( string.Join(", ", reportRoles.Select(x => x.Mention)) ?? "New report has been filed.", embed : reportEmbed.Build()).ConfigureAwait(false); return(CommandRuntimeResult.FromSuccess("Your report has been sent.")); }