mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-29 02:29:55 +03:00
Reduce boilerplate in command data checks
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
61e5016f1b
commit
b46c366e5e
4 changed files with 39 additions and 27 deletions
|
@ -1,9 +1,12 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using DiffPlex.DiffBuilder.Model;
|
||||
using Remora.Discord.API;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Discord.API.Objects;
|
||||
using Remora.Discord.Commands.Contexts;
|
||||
using Remora.Discord.Commands.Extensions;
|
||||
using Remora.Discord.Extensions.Embeds;
|
||||
using Remora.Discord.Extensions.Formatting;
|
||||
using Remora.Rest.Core;
|
||||
|
@ -141,4 +144,15 @@ public static class Extensions {
|
|||
var list = source.ToList();
|
||||
return list.Any() ? list.Max(selector) : default;
|
||||
}
|
||||
|
||||
public static bool TryGetContextIDs(
|
||||
this ICommandContext context, [NotNullWhen(true)] out Snowflake? guildId,
|
||||
[NotNullWhen(true)] out Snowflake? channelId, [NotNullWhen(true)] out Snowflake? userId) {
|
||||
guildId = null;
|
||||
channelId = null;
|
||||
userId = null;
|
||||
return context.TryGetGuildID(out guildId)
|
||||
&& context.TryGetChannelID(out channelId)
|
||||
&& context.TryGetUserID(out userId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue