mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Do not allow certain commands to be used in DMs (#49)
This PR prevents usage of `/about`, `/ping` and `/remind` inside DMs. While it may look like these commands do not require a guild attached to them, the language system depends on having a guild to fetch settings from, so it is not possible to use these commands in DMs. Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
c6dd3727c3
commit
f75926c604
3 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,8 @@ using JetBrains.Annotations;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
using Remora.Discord.Commands.Attributes;
|
||||||
|
using Remora.Discord.Commands.Conditions;
|
||||||
using Remora.Discord.Commands.Contexts;
|
using Remora.Discord.Commands.Contexts;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
|
@ -41,6 +43,8 @@ public class AboutCommandGroup : CommandGroup {
|
||||||
/// A feedback sending result which may or may not have succeeded.
|
/// A feedback sending result which may or may not have succeeded.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Command("about")]
|
[Command("about")]
|
||||||
|
[DiscordDefaultDMPermission(false)]
|
||||||
|
[RequireContext(ChannelContext.Guild)]
|
||||||
[Description("Shows Boyfriend's developers")]
|
[Description("Shows Boyfriend's developers")]
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> SendAboutBotAsync() {
|
public async Task<Result> SendAboutBotAsync() {
|
||||||
|
|
|
@ -5,6 +5,8 @@ using JetBrains.Annotations;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
using Remora.Discord.Commands.Attributes;
|
||||||
|
using Remora.Discord.Commands.Conditions;
|
||||||
using Remora.Discord.Commands.Contexts;
|
using Remora.Discord.Commands.Contexts;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
|
@ -44,6 +46,8 @@ public class PingCommandGroup : CommandGroup {
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Command("ping", "пинг")]
|
[Command("ping", "пинг")]
|
||||||
[Description("Get bot latency")]
|
[Description("Get bot latency")]
|
||||||
|
[DiscordDefaultDMPermission(false)]
|
||||||
|
[RequireContext(ChannelContext.Guild)]
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> SendPingAsync() {
|
public async Task<Result> SendPingAsync() {
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out _))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out _))
|
||||||
|
|
|
@ -6,6 +6,7 @@ using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.Commands.Attributes;
|
using Remora.Discord.Commands.Attributes;
|
||||||
|
using Remora.Discord.Commands.Conditions;
|
||||||
using Remora.Discord.Commands.Contexts;
|
using Remora.Discord.Commands.Contexts;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
|
@ -40,8 +41,9 @@ public class RemindCommandGroup : CommandGroup {
|
||||||
/// <param name="message">The text of the reminder.</param>
|
/// <param name="message">The text of the reminder.</param>
|
||||||
/// <returns>A feedback sending result which may or may not have succeeded.</returns>
|
/// <returns>A feedback sending result which may or may not have succeeded.</returns>
|
||||||
[Command("remind")]
|
[Command("remind")]
|
||||||
[DiscordDefaultDMPermission(false)]
|
|
||||||
[Description("Create a reminder")]
|
[Description("Create a reminder")]
|
||||||
|
[DiscordDefaultDMPermission(false)]
|
||||||
|
[RequireContext(ChannelContext.Guild)]
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> AddReminderAsync(
|
public async Task<Result> AddReminderAsync(
|
||||||
[Description("After what period of time mention the reminder")]
|
[Description("After what period of time mention the reminder")]
|
||||||
|
|
Loading…
Reference in a new issue