mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 13:54:36 +00:00
Mark blocking as obsolete, don't accept new blocks
This commit is contained in:
parent
febfd27ece
commit
841d120015
4 changed files with 17 additions and 2 deletions
|
@ -142,6 +142,11 @@ public class ConfigModule : BotModuleBase {
|
|||
}
|
||||
}
|
||||
|
||||
public const string ObsoleteAttrReason = "Made redundant by Discord's built-in command permissions. Will be removed eventually.";
|
||||
const string ObsoleteNotice = ":x: This feature shall be removed in the near future, and no further blocks will be accepted. "
|
||||
+ "Please use Discord's equivalent built-in features to limit access to your users.\n"
|
||||
+ "For more information: https://discord.com/blog/slash-commands-permissions-discord-apps-bots.";
|
||||
[Obsolete(ObsoleteAttrReason)]
|
||||
[Group("block", HelpCmdBlocking)]
|
||||
public class SubCmdsConfigBlocking : BotModuleBase {
|
||||
[SlashCommand("add-block", HelpPfxModOnly + "Add a user to the block list.")]
|
||||
|
@ -162,8 +167,10 @@ public class ConfigModule : BotModuleBase {
|
|||
return;
|
||||
}
|
||||
|
||||
if (setting) db.BlocklistEntries.Add(new BlocklistEntry() { GuildId = user.Guild.Id, UserId = user.Id });
|
||||
else db.Remove(existing!);
|
||||
if (setting) {
|
||||
await RespondAsync(ObsoleteNotice);
|
||||
return;
|
||||
} else db.Remove(existing!);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
await RespondAsync($":white_check_mark: {Common.FormatName(user, false)} has been {(setting ? "" : "un")}blocked.");
|
||||
|
@ -171,6 +178,11 @@ public class ConfigModule : BotModuleBase {
|
|||
|
||||
[SlashCommand("set-moderated", HelpPfxModOnly + "Set moderated mode on the server.")]
|
||||
public async Task CmdSetModerated([Summary(name: "enable", description: "The moderated mode setting.")] bool setting) {
|
||||
if (setting == true) {
|
||||
await RespondAsync(ObsoleteNotice);
|
||||
return;
|
||||
}
|
||||
|
||||
var current = false;
|
||||
await DoDatabaseUpdate(Context, s => {
|
||||
current = s.Moderated;
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace BirthdayBot.ApplicationCommands;
|
|||
/// Only users not on the blocklist or affected by moderator mode may use the command.<br/>
|
||||
/// This is used in the <see cref="BotModuleBase"/> base class. Manually using it anywhere else is unnecessary.
|
||||
/// </summary>
|
||||
[Obsolete(ConfigModule.ObsoleteAttrReason)]
|
||||
class EnforceBlockingAttribute : PreconditionAttribute {
|
||||
public const string FailModerated = "Guild has moderator mode enabled.";
|
||||
public const string FailBlocked = "User is in the guild's block list.";
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
||||
namespace BirthdayBot.Data;
|
||||
|
||||
[Obsolete(ApplicationCommands.ConfigModule.ObsoleteAttrReason)]
|
||||
[Table("banned_users")]
|
||||
public class BlocklistEntry {
|
||||
[Key]
|
||||
|
|
|
@ -17,6 +17,7 @@ public class BotDatabaseContext : DbContext {
|
|||
}.ToString();
|
||||
}
|
||||
|
||||
[Obsolete(ApplicationCommands.ConfigModule.ObsoleteAttrReason)]
|
||||
public DbSet<BlocklistEntry> BlocklistEntries { get; set; } = null!;
|
||||
public DbSet<GuildConfig> GuildConfigurations { get; set; } = null!;
|
||||
public DbSet<UserEntry> UserEntries { get; set; } = null!;
|
||||
|
|
Loading…
Reference in a new issue