parent
c1d18d7d8f
commit
aad37ef855
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,15 @@
|
||||||
import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js';
|
import {
|
||||||
|
SlashCommandBuilder,
|
||||||
|
SlashCommandOptionsOnlyBuilder,
|
||||||
|
SlashCommandSubcommandsOnlyBuilder,
|
||||||
|
ChatInputCommandInteraction,
|
||||||
|
} from 'discord.js';
|
||||||
|
|
||||||
|
/** Values returned from {@link SlashCommandBuilder} after chaining options or subcommands only. */
|
||||||
|
export type SlashCommandData =
|
||||||
|
| SlashCommandBuilder
|
||||||
|
| SlashCommandOptionsOnlyBuilder
|
||||||
|
| SlashCommandSubcommandsOnlyBuilder;
|
||||||
import { prisma } from '../database';
|
import { prisma } from '../database';
|
||||||
import { SupportedLocale } from '../i18n';
|
import { SupportedLocale } from '../i18n';
|
||||||
|
|
||||||
|
|
@ -77,7 +88,7 @@ export async function ensureGuildPaidForTrait(
|
||||||
* `trait`은 {@link Command.toModule}을 통해 붙이며, 특성 필터링 시 사용합니다.
|
* `trait`은 {@link Command.toModule}을 통해 붙이며, 특성 필터링 시 사용합니다.
|
||||||
*/
|
*/
|
||||||
export type CommandModule = {
|
export type CommandModule = {
|
||||||
data: SlashCommandBuilder;
|
data: SlashCommandData;
|
||||||
execute: (interaction: ChatInputCommandInteraction, locale: SupportedLocale) => Promise<void>;
|
execute: (interaction: ChatInputCommandInteraction, locale: SupportedLocale) => Promise<void>;
|
||||||
trait?: CommandTrait;
|
trait?: CommandTrait;
|
||||||
};
|
};
|
||||||
|
|
@ -103,7 +114,7 @@ export type CommandModule = {
|
||||||
* 명령 파일마다 반복되던 길드-only 같은 공통 처리는 이 클래스에 모을 수 있습니다.
|
* 명령 파일마다 반복되던 길드-only 같은 공통 처리는 이 클래스에 모을 수 있습니다.
|
||||||
*/
|
*/
|
||||||
export abstract class Command {
|
export abstract class Command {
|
||||||
private cachedData: SlashCommandBuilder | null = null;
|
private cachedData: SlashCommandData | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 이 명령의 도메인 특성입니다. 서브클래스에서 반드시 한 값으로 고정하세요.
|
* 이 명령의 도메인 특성입니다. 서브클래스에서 반드시 한 값으로 고정하세요.
|
||||||
|
|
@ -128,7 +139,7 @@ export abstract class Command {
|
||||||
* 최초 접근 시 {@link define}을 한 번만 호출해 결과를 캐시합니다.
|
* 최초 접근 시 {@link define}을 한 번만 호출해 결과를 캐시합니다.
|
||||||
* 같은 인스턴스에서 `data`를 여러 번 읽어도 빌더는 한 번만 만들어집니다.
|
* 같은 인스턴스에서 `data`를 여러 번 읽어도 빌더는 한 번만 만들어집니다.
|
||||||
*/
|
*/
|
||||||
get data(): SlashCommandBuilder {
|
get data(): SlashCommandData {
|
||||||
if (!this.cachedData) {
|
if (!this.cachedData) {
|
||||||
this.cachedData = this.define();
|
this.cachedData = this.define();
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +150,7 @@ export abstract class Command {
|
||||||
* 슬래시 명령의 정의(이름, 설명, 로컬라이즈, 서브커맨드, 옵션, `setDefaultMemberPermissions` 등)를
|
* 슬래시 명령의 정의(이름, 설명, 로컬라이즈, 서브커맨드, 옵션, `setDefaultMemberPermissions` 등)를
|
||||||
* `SlashCommandBuilder`로 구성해 반환합니다.
|
* `SlashCommandBuilder`로 구성해 반환합니다.
|
||||||
*/
|
*/
|
||||||
protected abstract define(): SlashCommandBuilder;
|
protected abstract define(): SlashCommandData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 공통 가드를 통과한 뒤 실행되는 본 처리입니다.
|
* 공통 가드를 통과한 뒤 실행되는 본 처리입니다.
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ export class EventService {
|
||||||
|
|
||||||
const diff = event.startsAt.getTime() - now.getTime();
|
const diff = event.startsAt.getTime() - now.getTime();
|
||||||
|
|
||||||
const dueOffsets = event.reminderOffsets.filter(offset =>
|
const dueOffsets = event.reminderOffsets.filter((offset: number) =>
|
||||||
offset > 0 &&
|
offset > 0 &&
|
||||||
!event.sentReminderOffsets.includes(offset) &&
|
!event.sentReminderOffsets.includes(offset) &&
|
||||||
diff <= offset * 60 * 1000 &&
|
diff <= offset * 60 * 1000 &&
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ const FEATURE_DEFINITIONS: FeatureDefinition[] = [
|
||||||
],
|
],
|
||||||
resolveChannelIds: async (guildId) => {
|
resolveChannelIds: async (guildId) => {
|
||||||
const generators = await prisma.voiceGenerator.findMany({ where: { guildId } });
|
const generators = await prisma.voiceGenerator.findMany({ where: { guildId } });
|
||||||
return generators.map((g) => g.channelId);
|
return generators.map((g: { channelId: string }) => g.channelId);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -103,7 +103,9 @@ const FEATURE_DEFINITIONS: FeatureDefinition[] = [
|
||||||
],
|
],
|
||||||
resolveChannelIds: async (guildId) => {
|
resolveChannelIds: async (guildId) => {
|
||||||
const generators = await prisma.voiceGenerator.findMany({ where: { guildId } });
|
const generators = await prisma.voiceGenerator.findMany({ where: { guildId } });
|
||||||
return generators.map((g) => g.categoryId).filter((id): id is string => id !== null);
|
return generators
|
||||||
|
.map((g: { categoryId: string | null }) => g.categoryId)
|
||||||
|
.filter((id: string | null): id is string => id !== null);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -120,7 +122,7 @@ const FEATURE_DEFINITIONS: FeatureDefinition[] = [
|
||||||
scope: 'hierarchy',
|
scope: 'hierarchy',
|
||||||
resolveTargetRoleIds: async (guildId) => {
|
resolveTargetRoleIds: async (guildId) => {
|
||||||
const inviteRoles = await prisma.inviteRole.findMany({ where: { guildId } });
|
const inviteRoles = await prisma.inviteRole.findMany({ where: { guildId } });
|
||||||
return inviteRoles.map((ir) => ir.roleId);
|
return inviteRoles.map((ir: { roleId: string }) => ir.roleId);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue