From 5139a0d4edcab9cda59c9f8db6016594f1d152e4 Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sat, 8 Sep 2018 18:04:29 +0500 Subject: [PATCH] only use #compatbot when not in DM --- CompatBot/Commands/CompatList.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CompatBot/Commands/CompatList.cs b/CompatBot/Commands/CompatList.cs index 2aca900a..9b813cb0 100644 --- a/CompatBot/Commands/CompatList.cs +++ b/CompatBot/Commands/CompatList.cs @@ -118,7 +118,6 @@ Example usage: private async Task DoRequestAndRespond(CommandContext ctx, RequestBuilder requestBuilder) { - var botChannelTask = ctx.Client.GetChannelAsync(Config.BotChannelId); Console.WriteLine(requestBuilder.Build()); CompatResult result; try @@ -131,9 +130,9 @@ Example usage: return; } - var botChannel = await botChannelTask.ConfigureAwait(false); + var channel = ctx.Channel.IsPrivate ? ctx.Channel : await ctx.Client.GetChannelAsync(Config.BotChannelId).ConfigureAwait(false); foreach (var msg in FormatSearchResults(ctx, result)) - await botChannel.SendAutosplitMessageAsync(msg).ConfigureAwait(false); + await channel.SendAutosplitMessageAsync(msg).ConfigureAwait(false); } private IEnumerable FormatSearchResults(CommandContext ctx, CompatResult compatResult) @@ -145,16 +144,17 @@ Example usage: yield return string.Format(returnCode.info, ctx.Message.Author.Mention); else { + var authorMention = ctx.Channel.IsPrivate ? "You" : ctx.Message.Author.Mention; var result = new StringBuilder(); if (string.IsNullOrEmpty(request.customHeader)) { - result.AppendLine($"{ctx.Message.Author.Mention} searched for: ***{request.search.Sanitize()}***"); + result.AppendLine($"{authorMention} searched for: ***{request.search.Sanitize()}***"); if (request.search.Contains("persona", StringComparison.InvariantCultureIgnoreCase)) result.AppendLine("Did you try searching for ***Unnamed*** instead?"); } else { - var formattedHeader = string.Format(request.customHeader, ctx.Message.Author.Mention, request.amountRequested, null, null); + var formattedHeader = string.Format(request.customHeader, authorMention, request.amountRequested, null, null); result.AppendLine(formattedHeader.Replace(" ", " ").Replace(" ", " ")); } result.AppendFormat(returnCode.info, compatResult.SearchTerm);