@ayanaware/bentocord
Version:
Bentocord is a Bento plugin designed to rapidly build fully functional Discord Bots.
131 lines (130 loc) • 5.79 kB
TypeScript
import { Plugin, PluginAPI } from '@ayanaware/bento';
import { ActivityPartial, BotActivityType, Message } from 'eris';
import type { LocalizedEmbedBuilder } from './builders/LocalizedEmbedBuilder';
import type { AnyCommandContext } from './commands/CommandContext';
import type { Command } from './commands/interfaces/Command';
import type { CommandPermissionDefaults } from './commands/interfaces/CommandDefinition';
import { DiscordPermission } from './discord/constants/DiscordPermission';
import type { MessageLocation } from './interfaces/MessageLocation';
import { PermissionScope } from './interfaces/PermissionScope';
export interface ShardData {
/** shardIds, currently MUST be sorted & consecutive. 0, 1, 2. NOT 0, 2, 42 */
shardIds: Array<number>;
/** shard count */
shardCount: number;
}
export declare class BentocordInterface implements Plugin {
name: string;
api: PluginAPI;
replaceable: boolean;
protected readonly owners: string;
protected readonly prefixes: Map<string, string>;
protected readonly permissions: Map<string, boolean>;
protected activity: ActivityPartial<BotActivityType>;
/**
* Used to determine what shards this process controls.
* @returns Shard Data
*/
getShardData(): Promise<ShardData>;
/**
* Check if userId is a bot owner.
* @param userId Discord User ID
* @returns boolean
*/
isOwner(userId: string): Promise<boolean>;
getHelpEmbed(embed: LocalizedEmbedBuilder): Promise<LocalizedEmbedBuilder>;
/**
* Default & Required selfPermissions for command
* @param command Command
* @param ctx AnyCommandContext
* @returns Array<DiscordPermission>
*/
selfPermissions(command: Command, ctx: AnyCommandContext): Promise<Array<DiscordPermission>>;
/**
* Allow's for domain-specific disabling of commands based on context.
* Useful for many things, but not limited to:
* - Disable free instance when paid instance is in the server
* - Simple blacklist functionality
* - Literally anything else you might want to check before running a command
* @param command Command
* @param ctx CommandContext
* @returns boolean Whether or not to continue execution of command
*/
checkCommand(command: Command, ctx: AnyCommandContext): Promise<boolean>;
/**
* Get the prefix for a given snowflake (ex: guildId).
* @param snowflake The snowflake
* @returns The prefix
*/
getPrefix(snowflake: string): Promise<string>;
/**
* Set the prefix for a given snowflake.
* @param snowflake The snowflake
* @param prefix The prefix
*/
setPrefix(snowflake: string, prefix: string): Promise<void>;
/** Extra ALWAYS available prefixes */
getExtraPrefixes(): Promise<Array<string>>;
resolveAlias(name: string, args: string, message: Message): Promise<Array<string>>;
formatNumber(num: number, ctx?: Record<string, string>): Promise<string>;
formatDate(date: Date, ctx?: Record<string, string>): Promise<string>;
/**
* Get locale code for a given context.
* @param ctx Translation Context (Snowflakes)
* @returns Locale Code
*/
getLocale(ctx: Record<string, string>): Promise<string>;
/**
* Format a translation string
* @param key Translation key
* @param repl Translation Replacements
* @param ctx Translation Context (Snowflakes)
* @param backup Translation Backup
* @returns Translated string
*/
formatTranslation(key: string, repl?: Record<string, unknown>, ctx?: Record<string, string>, backup?: string): Promise<string>;
/**
* Format a translation in all available languages.
* @param key Translation Key
* @param repl Translation Replacements
* @returns Object, key is language, value is translation
*/
formatTranslationMap(key: string, repl?: Record<string, unknown>): Promise<Record<string, string>>;
/**
* Can be used to convert translations to only the subset that discord supports
* @param translations Translation Map from formatTranslationMap
* @returns Converted Translation Map
*/
convertTranslationMap(translations: Record<string, string>): Promise<Record<string, string>>;
/**
* Get the permission for a given snowflake.
* @param permission The permission to check.
* @param snowflake The snowflake to check (usually guildId or userId)
* @param scope The scope to check.
* @returns Whether the permission is allowed.
*/
getPermission(permission: string, snowflake?: string, scope?: PermissionScope): Promise<boolean>;
/**
* Set the permission for a given snowflake.
* @param permission The permission to set.
* @param value Whether the permission is allowed.
* @param snowflake The snowflake to set (usually guildId or userId)
* @param scope The scope to set.
*/
setPermission(permission: string, value: boolean, snowflake?: string, scope?: PermissionScope): Promise<void>;
/**
* Find permission override for a given context (guild, channel, user)
* @param permission Permission to check
* @param snowflakes Snowflakes of the context
* @returns Tuple with [state, where] boolean if explicitly set, otherwise null
*/
findPermission(permission: string, snowflakes?: MessageLocation): Promise<[boolean, string]>;
/**
* Check if ctx has a given permission.
* @param ctx CommandContext
* @param perm Permission
* @param def Permission defaults
* @returns Whether context has the provided permission.
*/
checkPermission(ctx: AnyCommandContext, perm: string | Array<string>, def?: CommandPermissionDefaults | boolean): Promise<boolean>;
}