Skip to content

Commit

Permalink
feat: add integration types
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Sep 22, 2024
1 parent 6c3b1e4 commit c180fc4
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/commands/choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { escapeInlineCode } from '#lib/common/escape';
import { LanguageKeys } from '#lib/i18n/LanguageKeys';
import { Command, RegisterCommand } from '@skyra/http-framework';
import { applyLocalizedBuilder, resolveKey, resolveUserKey } from '@skyra/http-framework-i18n';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, LanguageKeys.Commands.Choice.RootName, LanguageKeys.Commands.Choice.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, LanguageKeys.Commands.Choice.OptionsValues).setMinLength(3).setRequired(true))
)
Expand Down
3 changes: 2 additions & 1 deletion src/commands/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { Command, RegisterCommand } from '@skyra/http-framework';
import { applyLocalizedBuilder, resolveUserKey } from '@skyra/http-framework-i18n';
import { Json, safeTimedFetch } from '@skyra/safe-fetch';
import { formatHex, formatHex8, hsl, oklch, p3, parse, rgb, type Color } from 'culori';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Color;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.Input).setRequired(true))
)
Expand Down
4 changes: 3 additions & 1 deletion src/commands/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { codeBlock } from '@discordjs/builders';
import type { RawFile } from '@discordjs/rest';
import { Command, RegisterMessageCommand, RegisterUserCommand, type TransformedArguments } from '@skyra/http-framework';
import { applyNameLocalizedBuilder } from '@skyra/http-framework-i18n';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

export class UserCommand extends Command {
@RegisterMessageCommand((builder) =>
applyNameLocalizedBuilder(builder, LanguageKeys.Commands.Content.MessageJsonName) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
)
public message(interaction: Command.MessageInteraction, options: TransformedArguments.Message) {
Expand All @@ -17,6 +18,7 @@ export class UserCommand extends Command {

@RegisterUserCommand((builder) =>
applyNameLocalizedBuilder(builder, LanguageKeys.Commands.Content.UserJsonName) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
)
public user(interaction: Command.UserInteraction, options: TransformedArguments.User) {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Units, renderUnit, sanitizeUnit, searchUnits } from '#lib/utilities/con
import { isNullish } from '@sapphire/utilities';
import { Command, RegisterCommand, type AutocompleteInteractionArguments } from '@skyra/http-framework';
import { applyLocalizedBuilder, getSupportedUserLanguageT, resolveUserKey } from '@skyra/http-framework-i18n';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Convert;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addNumberOption((builder) => applyLocalizedBuilder(builder, LanguageKeys.Commands.Convert.Amount).setRequired(true))
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.From).setAutocomplete(true).setRequired(true).setMaxLength(100))
Expand Down
3 changes: 2 additions & 1 deletion src/commands/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { Result, none, some } from '@sapphire/result';
import { Command, RegisterCommand, type MessageResponseOptions } from '@skyra/http-framework';
import { applyLocalizedBuilder, getSupportedLanguageT, type TFunction } from '@skyra/http-framework-i18n';
import { Json, isAbortError, safeTimedFetch, type FetchError } from '@skyra/safe-fetch';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { readFile } from 'node:fs/promises';

const Root = LanguageKeys.Commands.Dictionary;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.OptionsInput).setMinLength(2).setMaxLength(45).setRequired(true))
)
Expand Down
3 changes: 2 additions & 1 deletion src/commands/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import { isNullish, isNullishOrEmpty } from '@sapphire/utilities';
import { Command, RegisterCommand, RegisterMessageCommand, type TransformedArguments } from '@skyra/http-framework';
import { applyLocalizedBuilder, applyNameLocalizedBuilder, createSelectMenuChoiceName, resolveKey, resolveUserKey } from '@skyra/http-framework-i18n';
import { safeTimedFetch } from '@skyra/safe-fetch';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Emoji;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.OptionsEmoji).setRequired(true))
.addStringOption((builder) =>
Expand Down
3 changes: 2 additions & 1 deletion src/commands/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { envIsDefined, envParseString } from '@skyra/env-utilities';
import { Command, RegisterCommand, type MakeArguments } from '@skyra/http-framework';
import { applyLocalizedBuilder, getSupportedLanguageT, resolveUserKey, type TFunction } from '@skyra/http-framework-i18n';
import { Json, isAbortError, safeTimedFetch, type FetchError } from '@skyra/safe-fetch';
import { InteractionContextType, MessageFlags, type LocaleString } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags, type LocaleString } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Price;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) =>
// T - SAFEMOON
Expand Down
3 changes: 2 additions & 1 deletion src/commands/reddit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import {
type RedditError
} from '@skyra/reddit-helpers';
import { isAbortError, type FetchError } from '@skyra/safe-fetch';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Reddit;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
)
export class UserCommand extends Command {
Expand Down
10 changes: 9 additions & 1 deletion src/commands/reminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ import {
resolveKey,
resolveUserKey
} from '@skyra/http-framework-i18n';
import { ButtonStyle, InteractionContextType, MessageFlags, Routes, type RESTPatchAPIChannelMessageJSONBody } from 'discord-api-types/v10';
import {
ApplicationIntegrationType,
ButtonStyle,
InteractionContextType,
MessageFlags,
Routes,
type RESTPatchAPIChannelMessageJSONBody
} from 'discord-api-types/v10';
import { DateTime, Duration } from 'luxon';

const Root = LanguageKeys.Commands.Reminders;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
)
export class UserCommand extends Command {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { Result } from '@sapphire/result';
import { isNullish } from '@sapphire/utilities';
import { Command, RegisterCommand, RegisterSubcommand, type AutocompleteInteractionArguments } from '@skyra/http-framework';
import { applyLocalizedBuilder, getSupportedUserLanguageName, resolveUserKey } from '@skyra/http-framework-i18n';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.TimeZone;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
)
export class UserCommand extends Command {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { EmbedBuilder } from '@discordjs/builders';
import { Command, RegisterCommand } from '@skyra/http-framework';
import { applyLocalizedBuilder, getSupportedLanguageT } from '@skyra/http-framework-i18n';
import { TwitchBrandingColor, TwitchLogoUrl, areTwitchClientCredentialsSet, fetchUserFollowage, fetchUsers } from '@skyra/twitch-helpers';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Twitch;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.UserOptionsName).setMinLength(2).setMaxLength(20).setRequired(true))
)
Expand Down
3 changes: 2 additions & 1 deletion src/commands/unicode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import {
type TFunction,
type TypedT
} from '@skyra/http-framework-i18n';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Unicode;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
)
export class UserCommand extends Command {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import {
} from '@skyra/http-framework-i18n';
import { getWeatherData, getWeatherName, type CurrentCondition, type ValueWrapper, type Weather } from '@skyra/weather-helpers';
import { Canvas } from 'canvas-constructor/napi-rs';
import { InteractionContextType, MessageFlags, type LocaleString } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags, type LocaleString } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Weather;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.OptionsPlace).setMinLength(3).setMaxLength(85).setRequired(true))
.addStringOption((builder) =>
Expand Down
3 changes: 2 additions & 1 deletion src/commands/wikipedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { isNullishOrEmpty } from '@sapphire/utilities';
import { Command, RegisterCommand, type AutocompleteInteractionArguments } from '@skyra/http-framework';
import { applyLocalizedBuilder, resolveKey, resolveUserKey, type TypedT } from '@skyra/http-framework-i18n';
import { Json, isAbortError, safeTimedFetch } from '@skyra/safe-fetch';
import { InteractionContextType, MessageFlags } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';

const Root = LanguageKeys.Commands.Wikipedia;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription) //
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.OptionsInput).setAutocomplete(true).setRequired(true))
)
Expand Down
3 changes: 2 additions & 1 deletion src/commands/youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { envParseString } from '@skyra/env-utilities';
import { Command, RegisterCommand, type MessageResponseOptions } from '@skyra/http-framework';
import { applyLocalizedBuilder, createSelectMenuChoiceName, resolveUserKey } from '@skyra/http-framework-i18n';
import { Json, isAbortError, safeTimedFetch, type FetchError } from '@skyra/safe-fetch';
import { InteractionContextType, MessageFlags, type APISelectMenuOption } from 'discord-api-types/v10';
import { ApplicationIntegrationType, InteractionContextType, MessageFlags, type APISelectMenuOption } from 'discord-api-types/v10';
import he from 'he';

const Root = LanguageKeys.Commands.YouTube;

@RegisterCommand((builder) =>
applyLocalizedBuilder(builder, Root.RootName, Root.RootDescription)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
.addStringOption((builder) => applyLocalizedBuilder(builder, Root.OptionsQuery).setRequired(true))
.addStringOption((builder) =>
Expand Down

0 comments on commit c180fc4

Please sign in to comment.