diff --git a/ModularAssistentForDiscordServer/Commands/Slash/MessageSnipe.cs b/ModularAssistentForDiscordServer/Commands/Slash/MessageSnipe.cs
index 54b54ee..be9754e 100644
--- a/ModularAssistentForDiscordServer/Commands/Slash/MessageSnipe.cs
+++ b/ModularAssistentForDiscordServer/Commands/Slash/MessageSnipe.cs
@@ -43,12 +43,16 @@ private async Task DoSnipeAsync(InteractionContext ctx, bool edit)
{
await ctx.DeferAsync(true);
DiscordMessage message;
-
- var result = edit switch
+ bool result;
+
+ if (!edit)
+ {
+ result = MessageSnipeService.TryGetMessage(ctx.Channel.Id, out message);
+ }
+ else
{
- true => MessageSnipeService.TryGetEditedMessage(ctx.Channel.Id, out message),
- false => MessageSnipeService.TryGetMessage(ctx.Channel.Id, out message)
- };
+ result = MessageSnipeService.TryGetEditedMessage(ctx.Channel.Id, out message);
+ }
if (!result)
{
@@ -58,14 +62,15 @@ await ctx.EditResponseAsync(
}
var content = message.Content;
- if (content.Length > 500) content = content.Substring(0, 500) + "...";
+ if (content.Length > 500) content = content.Substring(0, 497) + "...";
+ var member = await ctx.Guild.GetMemberAsync(message.Author.Id);
var embed = new DiscordEmbedBuilder()
.WithAuthor(
- $"{message.Author.Username}#{message.Author.Discriminator}" + (edit ? " (Edited)" : ""),
+ $"{member.DisplayName}" + (edit ? " (Edited)" : ""),
iconUrl: message.Author.GetAvatarUrl(ImageFormat.Png))
.WithFooter(
- $"{(edit ? "Edit" : "Deletion")} sniped by {ctx.User.Username}#{ctx.User.Discriminator}",
+ $"{(edit ? "Edit" : "Deletion")} sniped by {ctx.Member.DisplayName}",
ctx.User.AvatarUrl);
if (!string.IsNullOrEmpty(content)) embed.WithDescription(content);
diff --git a/ModularAssistentForDiscordServer/Commands/Slash/RoleSelection.cs b/ModularAssistentForDiscordServer/Commands/Slash/RoleSelection.cs
index 3306adb..dc3d432 100644
--- a/ModularAssistentForDiscordServer/Commands/Slash/RoleSelection.cs
+++ b/ModularAssistentForDiscordServer/Commands/Slash/RoleSelection.cs
@@ -74,14 +74,14 @@ await ctx.EditResponseAsync(
//Get the initial response an wait for a component interaction
var response = await ctx.GetOriginalResponseAsync();
var selectResponse = await response.WaitForSelectAsync(ctx.Member, "roleSelectionStart-" + ctx.Channel.Id,
- TimeSpan.FromSeconds(60));
+ TimeSpan.FromSeconds(60 * 3));
//Notify the user when the interaction times out and abort
if (selectResponse.TimedOut)
{
await ctx.EditResponseAsync(new DiscordWebhookBuilder
{
- Content = "Timed out (60 seconds)"
+ Content = "Timed out (180 seconds)"
});
return;
}
diff --git a/ModularAssistentForDiscordServer/ModularAssistentForDiscordServer.csproj b/ModularAssistentForDiscordServer/ModularAssistentForDiscordServer.csproj
index 5da542d..0ac823a 100644
--- a/ModularAssistentForDiscordServer/ModularAssistentForDiscordServer.csproj
+++ b/ModularAssistentForDiscordServer/ModularAssistentForDiscordServer.csproj
@@ -42,11 +42,11 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/ModularAssistentForDiscordServer/Services/MessageSnipeService.cs b/ModularAssistentForDiscordServer/Services/MessageSnipeService.cs
index d2217bb..7b9af28 100644
--- a/ModularAssistentForDiscordServer/Services/MessageSnipeService.cs
+++ b/ModularAssistentForDiscordServer/Services/MessageSnipeService.cs
@@ -104,14 +104,12 @@ private static void PostEvictionCallback(object key, object value, EvictionReaso
public void AddMessage(DiscordMessage message)
{
var id = CacheHelper.GetMessageSnipeKey(message.ChannelId);
- _memoryCache.Remove(id);
_memoryCache.Set(id, message, _options);
}
public void AddEditedMessage(DiscordMessage message)
{
var id = CacheHelper.GetMessageEditSnipeKey(message.ChannelId);
- _memoryCache.Remove(id);
_memoryCache.Set(id, message, _options);
}
@@ -130,16 +128,26 @@ public void DeleteMessage(ulong channel)
public bool TryGetMessage(ulong channelId, out DiscordMessage message)
{
var id = CacheHelper.GetMessageSnipeKey(channelId);
- var result = _memoryCache.TryGetValue(id, out message);
- if (result) _memoryCache.Remove(id);
- return result;
+ message = _memoryCache.Get(id);
+ if (message is not null)
+ {
+ _memoryCache.Remove(id);
+ return true;
+ }
+
+ return false;
}
public bool TryGetEditedMessage(ulong channelId, out DiscordMessage message)
{
var id = CacheHelper.GetMessageEditSnipeKey(channelId);
- var result = _memoryCache.TryGetValue(id, out message);
- if (result) _memoryCache.Remove(id);
- return result;
+ message = _memoryCache.Get(id);
+ if (message is not null)
+ {
+ _memoryCache.Remove(id);
+ return true;
+ }
+
+ return false;
}
}
\ No newline at end of file