Skip to content

Commit f040b99

Browse files
authored
feat: showcase (#59)
* chore: bump discordjs to 14.26.4 * feat: add SHOWCASE_CHANNEL_ID env var * feat: add member utils * feat: replace inline util with extracted one * chore: update function name * feat: implement showcase feature * fix: add missing env * chore: change name to projectName * chore: remove unused console logs * fix: add missing test env
1 parent 600c399 commit f040b99

13 files changed

Lines changed: 552 additions & 56 deletions

File tree

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SERVER_ID=434487340535382016
99
GUIDES_CHANNEL_ID=1429492053825290371
1010
REPEL_LOG_CHANNEL_ID=1403558160144531589
1111
ADVENT_OF_CODE_CHANNEL_ID=1047623689488830495
12+
SHOWCASE_CHANNEL_ID=1517161718818541658
1213

1314
# Role IDs (from your dev server)
1415
REPEL_ROLE_ID=1002411741776461844

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SERVER_ID=your-server-id
1616
GUIDES_CHANNEL_ID=your-guide-channel-id
1717
ADVENT_OF_CODE_CHANNEL_ID=your_advent_of_code_forum_channel_id_here
1818
REPEL_LOG_CHANNEL_ID=your-repel-log-channel-id
19+
SHOWCASE_CHANNEL_ID=your-showcase-forum-channel-id
1920

2021
# Role IDs (from your dev server)
2122
REPEL_ROLE_ID=your-repel-role-id

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"license": "MIT",
2727
"packageManager": "pnpm@10.17.1",
2828
"dependencies": {
29-
"discord.js": "^14.22.1",
29+
"discord.js": "^14.26.4",
3030
"node-cron": "^4.2.1",
3131
"typescript": "^5.9.3",
3232
"web-features": "^3.9.2"

pnpm-lock.yaml

Lines changed: 53 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cacheMessages from '@/features/moderation/cache-messages.js';
44
import { repelCommand } from '@/features/moderation/repel.js';
55
import { pingCommand } from '@/features/ping/index.js';
66
import { publicGuidesCommand } from '@/features/public-guides/index.js';
7+
import { createShowcaseCommand } from '@/features/showcase/create-showcase.js';
78
import { tipsCommands } from '@/features/tips/index.js';
89
import type { Command } from './types.js';
910

@@ -16,6 +17,7 @@ export const commands = new Map<string, Command>(
1617
repelCommand,
1718
cacheMessages,
1819
publicGuidesCommand,
20+
createShowcaseCommand,
1921
]
2022
.flat()
2123
.map((command) => [command.data.name, command])

src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const config = {
3838
repelLogs: requireEnv('REPEL_LOG_CHANNEL_ID'),
3939
guides: requireEnv('GUIDES_CHANNEL_ID'),
4040
adventOfCode: requireEnv('ADVENT_OF_CODE_CHANNEL_ID'),
41+
showcase: requireEnv('SHOWCASE_CHANNEL_ID'),
4142
},
4243
onboarding: {
4344
channelId: optionalEnv('ONBOARDING_CHANNEL_ID'),

src/features/auto-roles/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import { Events } from 'discord.js';
44
import { createEvent } from '@/common/events/create-event.js';
55
import { config } from '@/env.js';
6-
import { hasRoles } from '@/util/member.js';
6+
import { hasAllRoles } from '@/util/member.js';
77

88
export const autoRoleEvent = createEvent(
99
{
1010
name: Events.GuildMemberUpdate,
1111
},
1212
async (_, newMember) => {
13-
const hasRoleC = hasRoles(newMember, config.roleIds.c);
13+
const hasRoleC = hasAllRoles(newMember, config.roleIds.c);
1414
if (!hasRoleC) {
15-
const hasRequiredRoles = hasRoles(newMember, config.roleIds.a, config.roleIds.b);
15+
const hasRequiredRoles = hasAllRoles(newMember, config.roleIds.a, config.roleIds.b);
1616
if (hasRequiredRoles) {
1717
try {
1818
await newMember.roles.add(config.roleIds.c);

src/features/moderation/repel.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Colors,
66
ContainerBuilder,
77
EmbedBuilder,
8-
GuildMember,
8+
type GuildMember,
99
type Message,
1010
MessageFlags,
1111
PermissionFlagsBits,
@@ -14,6 +14,7 @@ import {
1414
TextDisplayBuilder,
1515
type User,
1616
} from 'discord.js';
17+
import { isUserInServer } from '@/util/member.js';
1718
import { createSlashCommand } from '../../common/commands/create-commands.js';
1819
import { HOUR, MINUTE, timeToString } from '../../constants/time.js';
1920
import { config } from '../../env.js';
@@ -24,10 +25,6 @@ import { logToChannel } from '../../util/channel-logging.js';
2425
const DEFAULT_LOOK_BACK_MS = 10 * MINUTE;
2526
const DEFAULT_TIMEOUT_DURATION_MS = 1 * HOUR;
2627

27-
const isUserInServer = (target: User | GuildMember): target is GuildMember => {
28-
return target instanceof GuildMember;
29-
};
30-
3128
const isUserTimedOut = (target: GuildMember) => {
3229
return target.communicationDisabledUntilTimestamp
3330
? target.communicationDisabledUntilTimestamp > Date.now()

0 commit comments

Comments
 (0)