mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: reset
This commit is contained in:
1 parent
d769b852a9
commit
f7c356de1e
111 files changed
-11745
No files matched your search
@@ -1,51 +0,0 @@
|
||||
import { APIApplicationCommandBasicOption, ApplicationCommandOptionType } from 'discord.js';
|
||||
|
||||
import { HelpOption, InfoOption } from '../enums/index.js';
|
||||
import { Language } from '../models/enum-helpers/index.js';
|
||||
import { Lang } from '../services/index.js';
|
||||
|
||||
export class Args {
|
||||
public static readonly HELP_OPTION: APIApplicationCommandBasicOption = {
|
||||
name: Lang.getRef('arguments.option', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('arguments.option'),
|
||||
description: Lang.getRef('argDescs.helpOption', Language.Default),
|
||||
description_localizations: Lang.getRefLocalizationMap('argDescs.helpOption'),
|
||||
type: ApplicationCommandOptionType.String,
|
||||
choices: [
|
||||
{
|
||||
name: Lang.getRef('helpOptionDescs.contactSupport', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('helpOptionDescs.contactSupport'),
|
||||
value: HelpOption.CONTACT_SUPPORT,
|
||||
},
|
||||
{
|
||||
name: Lang.getRef('helpOptionDescs.commands', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('helpOptionDescs.commands'),
|
||||
value: HelpOption.COMMANDS,
|
||||
},
|
||||
],
|
||||
};
|
||||
public static readonly INFO_OPTION: APIApplicationCommandBasicOption = {
|
||||
name: Lang.getRef('arguments.option', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('arguments.option'),
|
||||
description: Lang.getRef('argDescs.helpOption', Language.Default),
|
||||
description_localizations: Lang.getRefLocalizationMap('argDescs.helpOption'),
|
||||
type: ApplicationCommandOptionType.String,
|
||||
choices: [
|
||||
{
|
||||
name: Lang.getRef('infoOptions.about', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('infoOptions.about'),
|
||||
value: InfoOption.ABOUT,
|
||||
},
|
||||
{
|
||||
name: Lang.getRef('infoOptions.translate', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('infoOptions.translate'),
|
||||
value: InfoOption.TRANSLATE,
|
||||
},
|
||||
{
|
||||
name: Lang.getRef('infoOptions.dev', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('infoOptions.dev'),
|
||||
value: InfoOption.DEV,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import { ChatInputCommandInteraction, EmbedBuilder, PermissionsString } from 'discord.js';
|
||||
|
||||
import { HelpOption } from '../../enums/index.js';
|
||||
import { Language } from '../../models/enum-helpers/index.js';
|
||||
import { EventData } from '../../models/internal-models.js';
|
||||
import { Lang } from '../../services/index.js';
|
||||
import { ClientUtils, FormatUtils, InteractionUtils } from '../../utils/index.js';
|
||||
import { Command, CommandDeferType } from '../index.js';
|
||||
|
||||
export class HelpCommand implements Command {
|
||||
public names = [Lang.getRef('chatCommands.help', Language.Default)];
|
||||
public deferType = CommandDeferType.PUBLIC;
|
||||
public requireClientPerms: PermissionsString[] = [];
|
||||
public async execute(intr: ChatInputCommandInteraction, data: EventData): Promise<void> {
|
||||
let args = {
|
||||
option: intr.options.getString(
|
||||
Lang.getRef('arguments.option', Language.Default)
|
||||
) as HelpOption,
|
||||
};
|
||||
|
||||
let embed: EmbedBuilder;
|
||||
switch (args.option) {
|
||||
case HelpOption.CONTACT_SUPPORT: {
|
||||
embed = Lang.getEmbed('displayEmbeds.helpContactSupport', data.lang);
|
||||
break;
|
||||
}
|
||||
case HelpOption.COMMANDS: {
|
||||
embed = Lang.getEmbed('displayEmbeds.helpCommands', data.lang, {
|
||||
CMD_LINK_TEST: FormatUtils.commandMention(
|
||||
await ClientUtils.findAppCommand(
|
||||
intr.client,
|
||||
Lang.getRef('chatCommands.test', Language.Default)
|
||||
)
|
||||
),
|
||||
CMD_LINK_INFO: FormatUtils.commandMention(
|
||||
await ClientUtils.findAppCommand(
|
||||
intr.client,
|
||||
Lang.getRef('chatCommands.info', Language.Default)
|
||||
)
|
||||
),
|
||||
});
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await InteractionUtils.send(intr, embed);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export { HelpCommand } from './help-command.js';
|
||||
export { InfoCommand } from './info-command.js';
|
||||
export { TestCommand } from './test-command.js';
|
||||
@@ -1,117 +0,0 @@
|
||||
import djs, { ChatInputCommandInteraction, EmbedBuilder, PermissionsString } from 'discord.js';
|
||||
import { createRequire } from 'node:module';
|
||||
import os from 'node:os';
|
||||
import typescript from 'typescript';
|
||||
|
||||
import { InfoOption } from '../../enums/index.js';
|
||||
import { Language } from '../../models/enum-helpers/index.js';
|
||||
import { EventData } from '../../models/internal-models.js';
|
||||
import { Lang } from '../../services/index.js';
|
||||
import { FormatUtils, InteractionUtils, ShardUtils } from '../../utils/index.js';
|
||||
import { Command, CommandDeferType } from '../index.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
let Config = require('../../../config/config.json');
|
||||
let TsConfig = require('../../../tsconfig.json');
|
||||
|
||||
export class InfoCommand implements Command {
|
||||
public names = [Lang.getRef('chatCommands.info', Language.Default)];
|
||||
public deferType = CommandDeferType.PUBLIC;
|
||||
public requireClientPerms: PermissionsString[] = [];
|
||||
|
||||
public async execute(intr: ChatInputCommandInteraction, data: EventData): Promise<void> {
|
||||
let args = {
|
||||
option: intr.options.getString(
|
||||
Lang.getRef('arguments.option', Language.Default)
|
||||
) as InfoOption,
|
||||
};
|
||||
|
||||
let embed: EmbedBuilder;
|
||||
switch (args.option) {
|
||||
case InfoOption.ABOUT: {
|
||||
embed = Lang.getEmbed('displayEmbeds.about', data.lang);
|
||||
break;
|
||||
}
|
||||
case InfoOption.TRANSLATE: {
|
||||
embed = Lang.getEmbed('displayEmbeds.translate', data.lang);
|
||||
for (let langCode of Language.Enabled) {
|
||||
embed.addFields([
|
||||
{
|
||||
name: Language.Data[langCode].nativeName,
|
||||
value: Lang.getRef('meta.translators', langCode),
|
||||
},
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InfoOption.DEV: {
|
||||
if (!Config.developers.includes(intr.user.id)) {
|
||||
await InteractionUtils.send(
|
||||
intr,
|
||||
Lang.getEmbed('validationEmbeds.devOnly', data.lang)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let shardCount = intr.client.shard?.count ?? 1;
|
||||
let serverCount: number;
|
||||
if (intr.client.shard) {
|
||||
try {
|
||||
serverCount = await ShardUtils.serverCount(intr.client.shard);
|
||||
} catch (error) {
|
||||
if (error.name.includes('ShardingInProcess')) {
|
||||
await InteractionUtils.send(
|
||||
intr,
|
||||
Lang.getEmbed('errorEmbeds.startupInProcess', data.lang)
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
serverCount = intr.client.guilds.cache.size;
|
||||
}
|
||||
|
||||
let memory = process.memoryUsage();
|
||||
embed = Lang.getEmbed('displayEmbeds.dev', data.lang, {
|
||||
NODE_VERSION: process.version,
|
||||
TS_VERSION: `v${typescript.version}`,
|
||||
ES_VERSION: TsConfig.compilerOptions.target,
|
||||
DJS_VERSION: `v${djs.version}`,
|
||||
SHARD_COUNT: shardCount.toLocaleString(data.lang),
|
||||
SERVER_COUNT: serverCount.toLocaleString(data.lang),
|
||||
SERVER_COUNT_PER_SHARD: Math.round(serverCount / shardCount).toLocaleString(
|
||||
data.lang
|
||||
),
|
||||
RSS_SIZE: FormatUtils.fileSize(memory.rss),
|
||||
RSS_SIZE_PER_SERVER:
|
||||
serverCount > 0
|
||||
? FormatUtils.fileSize(memory.rss / serverCount)
|
||||
: Lang.getRef('other.na', data.lang),
|
||||
HEAP_TOTAL_SIZE: FormatUtils.fileSize(memory.heapTotal),
|
||||
HEAP_TOTAL_SIZE_PER_SERVER:
|
||||
serverCount > 0
|
||||
? FormatUtils.fileSize(memory.heapTotal / serverCount)
|
||||
: Lang.getRef('other.na', data.lang),
|
||||
HEAP_USED_SIZE: FormatUtils.fileSize(memory.heapUsed),
|
||||
HEAP_USED_SIZE_PER_SERVER:
|
||||
serverCount > 0
|
||||
? FormatUtils.fileSize(memory.heapUsed / serverCount)
|
||||
: Lang.getRef('other.na', data.lang),
|
||||
HOSTNAME: os.hostname(),
|
||||
SHARD_ID: (intr.guild?.shardId ?? 0).toString(),
|
||||
SERVER_ID: intr.guild?.id ?? Lang.getRef('other.na', data.lang),
|
||||
BOT_ID: intr.client.user?.id,
|
||||
USER_ID: intr.user.id,
|
||||
});
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await InteractionUtils.send(intr, embed);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { ChatInputCommandInteraction, PermissionsString } from 'discord.js';
|
||||
import { RateLimiter } from 'discord.js-rate-limiter';
|
||||
|
||||
import { Language } from '../../models/enum-helpers/index.js';
|
||||
import { EventData } from '../../models/internal-models.js';
|
||||
import { Lang } from '../../services/index.js';
|
||||
import { InteractionUtils } from '../../utils/index.js';
|
||||
import { Command, CommandDeferType } from '../index.js';
|
||||
|
||||
export class TestCommand implements Command {
|
||||
public names = [Lang.getRef('chatCommands.test', Language.Default)];
|
||||
public cooldown = new RateLimiter(1, 5000);
|
||||
public deferType = CommandDeferType.PUBLIC;
|
||||
public requireClientPerms: PermissionsString[] = [];
|
||||
|
||||
public async execute(intr: ChatInputCommandInteraction, data: EventData): Promise<void> {
|
||||
await InteractionUtils.send(intr, Lang.getEmbed('displayEmbeds.test', data.lang));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import {
|
||||
ApplicationCommandOptionChoiceData,
|
||||
AutocompleteFocusedOption,
|
||||
AutocompleteInteraction,
|
||||
CommandInteraction,
|
||||
PermissionsString,
|
||||
} from 'discord.js';
|
||||
import { RateLimiter } from 'discord.js-rate-limiter';
|
||||
|
||||
import { EventData } from '../models/internal-models.js';
|
||||
|
||||
export interface Command {
|
||||
names: string[];
|
||||
cooldown?: RateLimiter;
|
||||
deferType: CommandDeferType;
|
||||
requireClientPerms: PermissionsString[];
|
||||
autocomplete?(
|
||||
intr: AutocompleteInteraction,
|
||||
option: AutocompleteFocusedOption
|
||||
): Promise<ApplicationCommandOptionChoiceData[]>;
|
||||
execute(intr: CommandInteraction, data: EventData): Promise<void>;
|
||||
}
|
||||
|
||||
export enum CommandDeferType {
|
||||
PUBLIC = 'PUBLIC',
|
||||
HIDDEN = 'HIDDEN',
|
||||
NONE = 'NONE',
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export { Args } from './args.js';
|
||||
export { Command, CommandDeferType } from './command.js';
|
||||
export { ChatCommandMetadata, MessageCommandMetadata, UserCommandMetadata } from './metadata.js';
|
||||
@@ -1 +0,0 @@
|
||||
export { ViewDateSent } from './view-date-sent.js';
|
||||
@@ -1,30 +0,0 @@
|
||||
import { MessageContextMenuCommandInteraction, PermissionsString } from 'discord.js';
|
||||
import { RateLimiter } from 'discord.js-rate-limiter';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
import { Language } from '../../models/enum-helpers/index.js';
|
||||
import { EventData } from '../../models/internal-models.js';
|
||||
import { Lang } from '../../services/index.js';
|
||||
import { InteractionUtils } from '../../utils/index.js';
|
||||
import { Command, CommandDeferType } from '../index.js';
|
||||
|
||||
export class ViewDateSent implements Command {
|
||||
public names = [Lang.getRef('messageCommands.viewDateSent', Language.Default)];
|
||||
public cooldown = new RateLimiter(1, 5000);
|
||||
public deferType = CommandDeferType.PUBLIC;
|
||||
public requireClientPerms: PermissionsString[] = [];
|
||||
|
||||
public async execute(
|
||||
intr: MessageContextMenuCommandInteraction,
|
||||
data: EventData
|
||||
): Promise<void> {
|
||||
await InteractionUtils.send(
|
||||
intr,
|
||||
Lang.getEmbed('displayEmbeds.viewDateSent', data.lang, {
|
||||
DATE: DateTime.fromJSDate(intr.targetMessage.createdAt).toLocaleString(
|
||||
DateTime.DATE_HUGE
|
||||
),
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import {
|
||||
ApplicationCommandType,
|
||||
RESTPostAPIChatInputApplicationCommandsJSONBody,
|
||||
RESTPostAPIContextMenuApplicationCommandsJSONBody,
|
||||
} from 'discord.js';
|
||||
|
||||
import { Args } from './index.js';
|
||||
import { Language } from '../models/enum-helpers/index.js';
|
||||
import { Lang } from '../services/index.js';
|
||||
|
||||
export const ChatCommandMetadata: {
|
||||
[command: string]: RESTPostAPIChatInputApplicationCommandsJSONBody;
|
||||
} = {
|
||||
HELP: {
|
||||
type: ApplicationCommandType.ChatInput,
|
||||
name: Lang.getRef('chatCommands.help', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('chatCommands.help'),
|
||||
description: Lang.getRef('commandDescs.help', Language.Default),
|
||||
description_localizations: Lang.getRefLocalizationMap('commandDescs.help'),
|
||||
dm_permission: true,
|
||||
default_member_permissions: undefined,
|
||||
options: [
|
||||
{
|
||||
...Args.HELP_OPTION,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
INFO: {
|
||||
type: ApplicationCommandType.ChatInput,
|
||||
name: Lang.getRef('chatCommands.info', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('chatCommands.info'),
|
||||
description: Lang.getRef('commandDescs.info', Language.Default),
|
||||
description_localizations: Lang.getRefLocalizationMap('commandDescs.info'),
|
||||
dm_permission: true,
|
||||
default_member_permissions: undefined,
|
||||
options: [
|
||||
{
|
||||
...Args.INFO_OPTION,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
TEST: {
|
||||
type: ApplicationCommandType.ChatInput,
|
||||
name: Lang.getRef('chatCommands.test', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('chatCommands.test'),
|
||||
description: Lang.getRef('commandDescs.test', Language.Default),
|
||||
description_localizations: Lang.getRefLocalizationMap('commandDescs.test'),
|
||||
dm_permission: true,
|
||||
default_member_permissions: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
export const MessageCommandMetadata: {
|
||||
[command: string]: RESTPostAPIContextMenuApplicationCommandsJSONBody;
|
||||
} = {
|
||||
VIEW_DATE_SENT: {
|
||||
type: ApplicationCommandType.Message,
|
||||
name: Lang.getRef('messageCommands.viewDateSent', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('messageCommands.viewDateSent'),
|
||||
default_member_permissions: undefined,
|
||||
dm_permission: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const UserCommandMetadata: {
|
||||
[command: string]: RESTPostAPIContextMenuApplicationCommandsJSONBody;
|
||||
} = {
|
||||
VIEW_DATE_JOINED: {
|
||||
type: ApplicationCommandType.User,
|
||||
name: Lang.getRef('userCommands.viewDateJoined', Language.Default),
|
||||
name_localizations: Lang.getRefLocalizationMap('userCommands.viewDateJoined'),
|
||||
default_member_permissions: undefined,
|
||||
dm_permission: true,
|
||||
},
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export { ViewDateJoined } from './view-date-joined.js';
|
||||
@@ -1,32 +0,0 @@
|
||||
import { DMChannel, PermissionsString, UserContextMenuCommandInteraction } from 'discord.js';
|
||||
import { RateLimiter } from 'discord.js-rate-limiter';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
import { Language } from '../../models/enum-helpers/index.js';
|
||||
import { EventData } from '../../models/internal-models.js';
|
||||
import { Lang } from '../../services/index.js';
|
||||
import { InteractionUtils } from '../../utils/index.js';
|
||||
import { Command, CommandDeferType } from '../index.js';
|
||||
|
||||
export class ViewDateJoined implements Command {
|
||||
public names = [Lang.getRef('userCommands.viewDateJoined', Language.Default)];
|
||||
public cooldown = new RateLimiter(1, 5000);
|
||||
public deferType = CommandDeferType.PUBLIC;
|
||||
public requireClientPerms: PermissionsString[] = [];
|
||||
|
||||
public async execute(intr: UserContextMenuCommandInteraction, data: EventData): Promise<void> {
|
||||
let joinDate: Date;
|
||||
if (!(intr.channel instanceof DMChannel)) {
|
||||
let member = await intr.guild.members.fetch(intr.targetUser.id);
|
||||
joinDate = member.joinedAt;
|
||||
} else joinDate = intr.targetUser.createdAt;
|
||||
|
||||
await InteractionUtils.send(
|
||||
intr,
|
||||
Lang.getEmbed('displayEmbeds.viewDateJoined', data.lang, {
|
||||
TARGET: intr.targetUser.toString(),
|
||||
DATE: DateTime.fromJSDate(joinDate).toLocaleString(DateTime.DATE_HUGE),
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user