feat: initialize booster role bot with database and Discord integration

- Add drizzle configuration for SQLite database
- Create package.json with necessary dependencies and scripts
- Implement configuration loading for Discord bot
- Define permissions for roles
- Set up database schema for booster roles
- Create Discord client and commands for managing booster roles
- Handle guild member updates to manage roles based on boost status
- Implement boost eligibility checks and role management logic
- Add tests for boost eligibility and role guards
- Create service for managing booster roles with in-memory storage for testing
- Configure TypeScript settings for the project
This commit is contained in:
MythEclipse
2026-05-15 23:03:35 +07:00
parent 63d3e0a8c1
commit c6b1087eb3
20 changed files with 919 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
import { Client, GatewayIntentBits } from "discord.js";
export function createDiscordClient(): Client {
return new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers]
});
}
+25
View File
@@ -0,0 +1,25 @@
import { SlashCommandBuilder } from "discord.js";
export const boosterRoleCommand = new SlashCommandBuilder()
.setName("booster-role")
.setDescription("Manage your cosmetic booster role")
.addSubcommand((command) =>
command
.setName("claim")
.setDescription("Claim a new custom cosmetic booster role")
.addStringOption((option) => option.setName("name").setDescription("Role name").setRequired(true))
.addStringOption((option) => option.setName("color").setDescription("Hex color like #AABBCC"))
)
.addSubcommand((command) =>
command
.setName("rename")
.setDescription("Rename your bot-managed booster role")
.addStringOption((option) => option.setName("name").setDescription("New role name").setRequired(true))
)
.addSubcommand((command) =>
command
.setName("recolor")
.setDescription("Recolor your bot-managed booster role")
.addStringOption((option) => option.setName("color").setDescription("Hex color like #AABBCC").setRequired(true))
)
.addSubcommand((command) => command.setName("delete").setDescription("Delete your bot-managed booster role"));
+11
View File
@@ -0,0 +1,11 @@
import type { GuildMember } from "discord.js";
import type { BoosterRoleService } from "../../services/boosterRoleService";
export async function handleGuildMemberUpdate(oldMember: GuildMember, newMember: GuildMember, service: BoosterRoleService): Promise<void> {
const hadBoost = Boolean(oldMember.premiumSince);
const hasBoost = Boolean(newMember.premiumSince);
if (hadBoost && !hasBoost) {
await service.removeRoleForLostBoost({ guildId: newMember.guild.id, userId: newMember.id });
}
}