From f2857289e023430166dddb68af12974ff977a6cf Mon Sep 17 00:00:00 2001 From: Ed Halley <1223980+hariedo@users.noreply.github.com> Date: Fri, 20 Feb 2026 22:53:55 -0600 Subject: [PATCH] Fix UserModule.cs 0-slap If no users listed to slap, give a generic response. --- DiscordBot/Modules/UserModule.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/DiscordBot/Modules/UserModule.cs b/DiscordBot/Modules/UserModule.cs index d58924e0..4cdd353d 100644 --- a/DiscordBot/Modules/UserModule.cs +++ b/DiscordBot/Modules/UserModule.cs @@ -632,6 +632,7 @@ public async Task SlapUser(params IUser[] users) { await LoggingService.LogChannelAndFile($"Error while loading '{Settings.UserModuleSlapObjectsTable}'.\nEx:{e}", ExtendedLogSeverity.LowWarning); + return; } if (_slapObjects.Count == 0) _slapObjects.Add(Settings.UserModuleSlapChoices); @@ -643,15 +644,24 @@ public async Task SlapUser(params IUser[] users) if (_slapFails.Count == 0) _slapFails.Add("hurting themselves"); - var sb = new StringBuilder(); var uname = Context.User.GetUserPreferredName(); + + if (users == null || users.Length == 0) + { + await Context.Channel.SendMessageAsync( + $"**{uname}** slaps away an invisible pest."); + await Context.Message.DeleteAfterSeconds(seconds: 1); + return; + } + + var sb = new StringBuilder(); var mentions = users.ToMentionArray().ToCommaList(); bool fail = (_random.Next(1, 100) < 5); if (fail) { sb.Append($"**{uname}** tries to slap {mentions} "); - sb.Append(" around a bit with a large "); + sb.Append("around a bit with a large "); sb.Append(_slapObjects.Pick(true)); sb.Append(", but misses and ends up "); sb.Append(_slapFails.Pick(true)); @@ -660,7 +670,7 @@ public async Task SlapUser(params IUser[] users) else { sb.Append($"**{uname}** slaps {mentions} "); - sb.Append(" around a bit with a large "); + sb.Append("around a bit with a large "); sb.Append(_slapObjects.Pick(true)); sb.Append("."); }