Repository navigation
Conversation
…he, User Records ## Modernization - Upgrade target framework net5.0 → net8.0 - Discord.Net 2.4.0 → 3.18.0 with required GatewayIntents (MessageContent + GuildMembers — must enable in Developer Portal) - Discord.Addons.Hosting 4.0.2 → 6.1.0; migrate from IHostBuilder extensions to IServiceCollection (AddDiscordHost, AddCommandService) - Discord.Addons.Interactive removed; Fergun.Interactive 1.9.1 added - EF Core 5.0.7 → 9.0.2; Serilog 2.x → 4.3.1 + updated sinks - Fix DI lifetime mismatch: AddDbContext → AddDbContextFactory so singleton repositories create/dispose contexts per operation - Remove broken async-void IDisposable from GuildConfigs - Remove unused imports (SQLitePCL, EF Query.Internal, Net.Sockets) - Fill in all CommandHandler error switch cases - TemplateModuleBase now inherits ModuleBase<SocketCommandContext> ## Permissions system (role + user based) - BotPermission enum: None / Moderator / Admin - GuildRolePermission + GuildUserPermission entities - GuildPermissions repository: user overrides > role max; owner = Admin - RequirePermissionLevelAttribute precondition - Commands: !permit role/user, !revoke role/user, !permissions ## Rules Cache - GuildRule entity; GuildRules repository with auto-renumbering - RulesCacheService singleton (ConcurrentDictionary, lazy-loaded, invalidated on write) - Commands: !rules, !rules add/remove/edit (Moderator+) ## User Records / moderation database - RecordType enum + UserRecord entity (Warning/Mute/Kick/Ban/…) - UserRecords repository - Commands: !warn, !history, !clearwarnings ## Database - EF Core migration AddPermissionsRulesAndRecords adds four new tables: GuildRolePermissions, GuildUserPermissions, GuildRules, UserRecords ## Docs - README rewritten with setup instructions, command reference, extension guide, and package table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR modernizes the boilerplate from its original .NET 5 / Discord.Net 2.4 state and adds the three features listed in the README TODO.
Modernization
net5.0→net8.0GatewayIntents(MessageContent+GuildMembers— privileged, must be enabled in the Developer Portal)IHostBuilderextensions (ConfigureDiscordHost,UseCommandService) to the newIServiceCollectionAPI (AddDiscordHost,AddCommandService)Discord.Addons.Interactiveremoved; replaced withFergun.Interactive1.9.1 (actively maintained fork) registered as anInteractiveServicesingletonAddDbContext→AddDbContextFactory<TemplateBotContext>so singleton services create/dispose their own short-lived contexts per operationasync void Disposepattern fromGuildConfigsSQLitePCL,EF Query.Internal,System.Net.Sockets)CommandHandlererrorswitchcases (previously all TODOs)TemplateModuleBasenow inheritsModuleBase<SocketCommandContext>directlyPermissions system (role + user based)
BotPermissionenum:None / Moderator / AdminGuildRolePermission+GuildUserPermissionEF entitiesGuildPermissionsrepository: user-level overrides take precedence over role-level grants; guild owner always resolves toAdminRequirePermissionLevelAttributeprecondition (named to avoid conflict withDiscord.Commands.RequireBotPermissionAttribute)Administrator):!permit role/user,!revoke role/user,!permissionsRules Cache
GuildRuleentity;GuildRulesrepository with automatic contiguous renumbering on removalRulesCacheServicesingleton —ConcurrentDictionary<ulong, List<GuildRule>>populated lazily per guild, invalidated on any write!rules(public),!rules add/remove/edit(Moderator+)User Records / moderation database
RecordTypeenum (Warning / Mute / Unmute / Kick / Ban / Unban)UserRecordentity: guild, user, moderator, type, reason, timestampUserRecordsrepository!warn @user <reason>(Moderator+),!history @user(Moderator+),!clearwarnings @user(Admin+)Database migration
New migration
AddPermissionsRulesAndRecordsadds four tables:GuildRolePermissions,GuildUserPermissions,GuildRules,UserRecords.Docs
README fully rewritten with setup instructions, Developer Portal steps, full command reference, extension guide, and package table.
Test plan
dotnet buildpasses with 0 errors, 0 warningsdotnet run— bot connects and logs show no gateway intent errors!pingreturnsPong!!permit role @SomeRole Moderator— success embed;!permissionsshows the grant!rules add No spamming— rule Modernize to .NET 8 / Discord.Net 3.18 + add Permissions, Rules Cache, User Records #1 added;!rulesdisplays it!rules remove 1— rule removed;!rulesshows empty!warn @user test warning— warning embed shown;!history @userlists the record!clearwarnings @user— clears warnings (requires Admin)🤖 Generated with Claude Code