Skip to content

Commit 8040f63

Browse files
committed
improve display of edit paste fallback
1 parent dfe3498 commit 8040f63

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Helpers/DiscordHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ public static async Task<DiscordMessageBuilder> GenerateMessageRelay(Models.Cach
291291
embed.AddField("Message Link", $"{MessageLink(message)}");
292292
if (oldMessage is not null)
293293
{
294-
embed.AddField("Old content", await StringHelpers.CodeOrHasteBinAsync(oldMessage.Content, plain: true, noCode: true));
294+
embed.AddField("Old content", await StringHelpers.CodeOrHasteBinAsync(oldMessage.Content, noCode: true, messageWrapper: true));
295295
}
296-
embed.AddField("New content", await StringHelpers.CodeOrHasteBinAsync(message.Content, plain: true, noCode: true));
296+
embed.AddField("New content", await StringHelpers.CodeOrHasteBinAsync(message.Content, noCode: true, messageWrapper: true));
297297
embed.Color = DiscordColor.Yellow;
298298

299299
}

Helpers/HasteBinClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ public async Task<HasteBinResult> PostTclipAsync(string content, string language
8383
fullUrl += "/";
8484
}
8585
string postUrl = $"{fullUrl}api/post";
86-
if (language == default)
86+
if (language == default || language == "")
8787
language = "txt";
8888

8989
var formdata = new MultipartFormDataContent
9090
{
9191
{ new StringContent(content), "content"},
92-
{ new StringContent(Program.discord.CurrentUser.Username + "." + (language)), "filename" }
92+
{ new StringContent(Program.discord.CurrentUser.Username + "." + language), "filename" }
9393
};
9494

9595
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri(postUrl))

Helpers/StringHelpers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static string WarningContextString(DiscordUser user, string reason, bool
2929
return $"{Program.cfgjson.Emoji.Warning} {user.Mention} was warned: **{reason.Replace("`", "\\`").Replace("*", "\\*")}**";
3030
}
3131

32-
public static async Task<string> CodeOrHasteBinAsync(string input, string language = "", int charLimit = 1930, bool plain = false, bool noCode = false)
32+
public static async Task<string> CodeOrHasteBinAsync(string input, string language = "", int charLimit = 1930, bool plain = false, bool noCode = false, bool messageWrapper = false)
3333
{
3434
bool inputHasCodeBlock = input.Contains("```");
3535
if (input.Length > charLimit || inputHasCodeBlock)
@@ -41,6 +41,8 @@ public static async Task<string> CodeOrHasteBinAsync(string input, string langua
4141

4242
if (plain)
4343
return hasteUrl;
44+
else if (messageWrapper)
45+
return $"[`📄 View online`]({hasteResult.RawUrl})";
4446
else if (inputHasCodeBlock)
4547
return $"{Program.cfgjson.Emoji.Warning} Output contained a code block, so it was uploaded to Hastebin to avoid formatting issues: {hasteUrl}";
4648
else

0 commit comments

Comments
 (0)