🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

amethystjs

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amethystjs - npm Package Compare versions

Comparing version
1.8.0
to
1.8.1
+3
dist/events/messageUpdate.d.ts
import { AmethystEvent } from "../structures/Event";
declare const _default: AmethystEvent<"messageUpdate">;
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Event_1 = require("../structures/Event");
const messageInputRun_1 = require("../utils/messageInputRun");
exports.default = new Event_1.AmethystEvent('messageUpdate', (oldMessage, newMessage) => {
if (oldMessage.content === newMessage.content)
return;
(0, messageInputRun_1.messageInputRun)(newMessage);
});
import { Precondition } from "../structures/Precondition";
declare const _default: Precondition;
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Precondition_1 = require("../structures/Precondition");
const Client_1 = require("../typings/Client");
exports.default = new Precondition_1.Precondition('UserInVoiceChannel').setMessageRun(({ message }) => {
if (!message.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserNotInVoiceChannel
},
type: 'message',
channelMessage: message
};
return {
ok: true,
type: 'message',
channelMessage: message
};
}).setButtonRun(({ button }) => {
if (!button.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserNotInVoiceChannel
},
type: 'button',
buttonInteraction: button
};
return {
ok: true,
type: 'button',
buttonInteraction: button
};
}).setChatInputRun(({ interaction }) => {
if (!interaction.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserNotInVoiceChannel
},
type: 'chatInput',
interaction
};
return {
ok: true,
type: 'chatInput',
interaction
};
}).setMessageContextMenuRun(({ interaction }) => {
if (!interaction.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserNotInVoiceChannel
},
type: 'messageContextMenu',
interaction
};
return {
ok: true,
type: 'messageContextMenu',
interaction
};
}).setUserContextMenuRun(({ interaction }) => {
if (!interaction.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserNotInVoiceChannel
},
type: 'userContextMenu',
interaction
};
return {
ok: true,
type: 'userContextMenu',
interaction
};
}).setModalRun(({ modal }) => {
if (!modal.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserNotInVoiceChannel
},
type: 'modal',
modal
};
return {
ok: true,
type: 'modal',
modal
};
});
import { Precondition } from "../structures/Precondition";
declare const _default: Precondition;
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Precondition_1 = require("../structures/Precondition");
const Client_1 = require("../typings/Client");
exports.default = new Precondition_1.Precondition('UserNotInVoiceChannel').setMessageRun(({ message }) => {
if (message.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user not in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserInVoiceChannel
},
type: 'message',
channelMessage: message
};
return {
ok: true,
type: 'message',
channelMessage: message
};
}).setButtonRun(({ button }) => {
if (button.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user not in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserInVoiceChannel
},
type: 'button',
buttonInteraction: button
};
return {
ok: true,
type: 'button',
buttonInteraction: button
};
}).setChatInputRun(({ interaction }) => {
if (interaction.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user not in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserInVoiceChannel
},
type: 'chatInput',
interaction
};
return {
ok: true,
type: 'chatInput',
interaction
};
}).setMessageContextMenuRun(({ interaction }) => {
if (interaction.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user not in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserInVoiceChannel
},
type: 'messageContextMenu',
interaction
};
return {
ok: true,
type: 'messageContextMenu',
interaction
};
}).setUserContextMenuRun(({ interaction }) => {
if (interaction.member?.voice?.channelId)
return {
ok: false,
message: 'Command executable only if user not in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserInVoiceChannel
},
type: 'userContextMenu',
interaction
};
return {
ok: true,
type: 'userContextMenu',
interaction
};
}).setModalRun(({ modal }) => {
if (modal.member?.voice?.channelId)
return {
ok: false,
message: 'Modal executable only if user not in voice channel',
metadata: {
code: Client_1.commandDeniedCode.UserInVoiceChannel
},
type: 'modal',
modal
};
return {
ok: true,
type: 'modal',
modal
};
});
import { Message } from 'discord.js';
export declare const messageInputRun: (message: Message) => boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.messageInputRun = void 0;
const tslib_1 = require("tslib");
const cooldowns_1 = tslib_1.__importDefault(require("../maps/cooldowns"));
const Client_1 = require("../typings/Client");
const functions_1 = require("../utils/functions");
const messageInputRun = (message) => {
const test = (0, functions_1.testMessage)(message);
if (!test.valid || message.author.bot || message.webhookId)
return;
const args = message.content.slice(test.length).trim().split(/ +/g);
const cmdName = args.shift();
const cmd = message.client.messageCommands.find((x) => x.options.name === cmdName.toLowerCase() ||
x.options.aliases.includes(cmdName.toLowerCase()) ||
(message.client.configs.commandLocalizationsUsedAsNames &&
Object.keys(x.options.nameLocalizations ?? {})
.map((y) => (x.options.nameLocalizations ?? {})[y])
.includes(cmdName.toLowerCase())));
const argumentOptions = {
args: args,
first: args[0] ?? null,
second: args[1] ?? null,
emptyArgs: args.length === 0,
commandName: cmdName
};
if (!cmd) {
message.client.debug(`An user used an unexisting command: ${cmdName}`, Client_1.DebugImportance.Information);
return;
}
if (!cmd.messageRun) {
return message.client.emit('commandError', {
isMessage: true,
type: 'message',
message,
command: cmd,
user: message.author,
client: message.client
}, {
code: Client_1.errorCode.NoMessageRun,
message: `The command hasn't a run proprety. Use <#AmethytCommand>.setMessageRun()`,
metadata: {
commandName: cmd.options.name
}
});
}
if (cmd.options.clientPermissions?.length > 0 && message.guild) {
let missing = [];
cmd.options.clientPermissions.forEach((perm) => {
if (!message.guild.members.me.permissions.has(perm))
missing.push(perm);
});
if (missing.length > 0) {
return message.client.emit('commandDenied', {
command: cmd,
type: 'message',
message,
isMessage: true,
user: message.author,
client: message.client
}, {
message: 'Client is missing permissions',
code: Client_1.commandDeniedCode.ClientMissingPerms,
metadata: {
permissions: {
need: cmd.options.clientPermissions,
got: cmd.options.clientPermissions.filter((x) => !missing.includes(x)),
missing: missing
}
}
});
}
}
if (cmd.options.permissions?.length > 0 && message.guild) {
let missing = [];
cmd.options.permissions.forEach((perm) => {
if (!message.guild.members.me.permissions.has(perm))
missing.push(perm);
});
if (missing.length > 0) {
return message.client.emit('commandDenied', {
command: cmd,
message,
type: 'message',
isMessage: true,
user: message.author,
client: message.client
}, {
message: 'User is missing permissions',
code: Client_1.commandDeniedCode.UserMissingPerms,
metadata: {
permissions: {
need: cmd.options.clientPermissions,
got: cmd.options.clientPermissions.filter((x) => !missing.includes(x)),
missing: missing
}
}
});
}
}
let ok = true;
if (cmd.options.preconditions?.length > 0 &&
cmd.options.preconditions.filter((x) => x.messageRun !== undefined).length > 0) {
cmd.options.preconditions
.filter((x) => x.messageRun !== undefined)
.forEach((prec) => {
if (!ok)
return;
const result = prec.messageRun({
message,
command: cmd,
client: message.client,
arguments: argumentOptions
});
if (!result.ok) {
ok = false;
return message.client.emit('commandDenied', {
command: cmd,
type: 'message',
isMessage: true,
message,
user: message.author,
client: message.client
}, {
message: `A precondition failed: ${prec.name}`,
code: result?.metadata?.code ?? Client_1.commandDeniedCode.CustomPrecondition,
metadata: result.metadata ?? {}
});
}
});
}
if (!ok)
return;
if (cmd.options.messageInputChannelTypes?.length > 0) {
if (!cmd.options.messageInputChannelTypes.includes(message.channel.type)) {
return message.client.emit('commandDenied', {
command: cmd,
type: 'message',
isMessage: true,
message,
user: message.author,
client: message.client
}, {
code: Client_1.commandDeniedCode.InvalidChannelType,
message: 'Command runned in an invalid channel type',
metadata: {
channelType: {
expected: cmd.options.messageInputChannelTypes,
got: message.channel.type
}
}
});
}
}
const cdCode = `${message.author.id}.${cmd.options.name}`;
if (cooldowns_1.default.has(cdCode)) {
return message.client.emit('commandDenied', {
isMessage: true,
message,
type: 'message',
command: cmd,
user: message.author,
client: message.client
}, {
message: 'User is under cooldown',
metadata: {
remainingCooldownTime: cooldowns_1.default.get(cdCode) - Date.now()
},
code: Client_1.commandDeniedCode.UnderCooldown
});
}
cooldowns_1.default.set(cdCode, Date.now() + (cmd.options.cooldown || message.client.configs.defaultCooldownTime) * 1000);
setTimeout(() => {
cooldowns_1.default.delete(cdCode);
}, (cmd.options.cooldown || message.client.configs.defaultCooldownTime) * 1000);
cmd.messageRun({
message,
options: argumentOptions,
client: message.client
});
};
exports.messageInputRun = messageInputRun;
+1
-1

@@ -1,3 +0,3 @@

import { AmethystEvent } from '../structures/Event';
import { AmethystEvent } from "../structures/Event.js";
declare const _default: AmethystEvent<"messageCreate">;
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const cooldowns_1 = tslib_1.__importDefault(require("../maps/cooldowns"));
const Event_1 = require("../structures/Event");
const Client_1 = require("../typings/Client");
const functions_1 = require("../utils/functions");
exports.default = new Event_1.AmethystEvent('messageCreate', (message) => {
const test = (0, functions_1.testMessage)(message);
if (!test.valid || message.author.bot || message.webhookId)
return;
const args = message.content.slice(test.length).trim().split(/ +/g);
const cmdName = args.shift();
const cmd = message.client.messageCommands.find((x) => x.options.name === cmdName.toLowerCase() ||
x.options.aliases.includes(cmdName.toLowerCase()) ||
(message.client.configs.commandLocalizationsUsedAsNames &&
Object.keys(x.options.nameLocalizations ?? {})
.map((y) => (x.options.nameLocalizations ?? {})[y])
.includes(cmdName.toLowerCase())));
if (!cmd) {
message.client.debug(`An user used an unexisting command: ${cmdName}`, Client_1.DebugImportance.Information);
return;
}
if (!cmd.messageRun) {
return message.client.emit('commandError', {
isMessage: true,
type: 'message',
message,
command: cmd,
user: message.author,
client: message.client
}, {
code: Client_1.errorCode.NoMessageRun,
message: `The command hasn't a run proprety. Use <#AmethytCommand>.setMessageRun()`,
metadata: {
commandName: cmd.options.name
}
});
}
if (cmd.options.clientPermissions?.length > 0 && message.guild) {
let missing = [];
cmd.options.clientPermissions.forEach((perm) => {
if (!message.guild.members.me.permissions.has(perm))
missing.push(perm);
});
if (missing.length > 0) {
return message.client.emit('commandDenied', {
command: cmd,
type: 'message',
message,
isMessage: true,
user: message.author,
client: message.client
}, {
message: 'Client is missing permissions',
code: Client_1.commandDeniedCode.ClientMissingPerms,
metadata: {
permissions: {
need: cmd.options.clientPermissions,
got: cmd.options.clientPermissions.filter((x) => !missing.includes(x)),
missing: missing
}
}
});
}
}
if (cmd.options.permissions?.length > 0 && message.guild) {
let missing = [];
cmd.options.permissions.forEach((perm) => {
if (!message.guild.members.me.permissions.has(perm))
missing.push(perm);
});
if (missing.length > 0) {
return message.client.emit('commandDenied', {
command: cmd,
message,
type: 'message',
isMessage: true,
user: message.author,
client: message.client
}, {
message: 'User is missing permissions',
code: Client_1.commandDeniedCode.UserMissingPerms,
metadata: {
permissions: {
need: cmd.options.clientPermissions,
got: cmd.options.clientPermissions.filter((x) => !missing.includes(x)),
missing: missing
}
}
});
}
}
let ok = true;
if (cmd.options.preconditions?.length > 0 &&
cmd.options.preconditions.filter((x) => x.messageRun !== undefined).length > 0) {
cmd.options.preconditions
.filter((x) => x.messageRun !== undefined)
.forEach((prec) => {
if (!ok)
return;
const result = prec.messageRun({
message,
command: cmd,
client: message.client
});
if (!result.ok) {
ok = false;
return message.client.emit('commandDenied', {
command: cmd,
type: 'message',
isMessage: true,
message,
user: message.author,
client: message.client
}, {
message: `A precondition failed: ${prec.name}`,
code: result?.metadata?.code ?? Client_1.commandDeniedCode.CustomPrecondition,
metadata: result.metadata ?? {}
});
}
});
}
if (!ok)
return;
if (cmd.options.messageInputChannelTypes?.length > 0) {
if (!cmd.options.messageInputChannelTypes.includes(message.channel.type)) {
return message.client.emit('commandDenied', {
command: cmd,
type: 'message',
isMessage: true,
message,
user: message.author,
client: message.client
}, {
code: Client_1.commandDeniedCode.InvalidChannelType,
message: 'Command runned in an invalid channel type',
metadata: {
channelType: {
expected: cmd.options.messageInputChannelTypes,
got: message.channel.type
}
}
});
}
}
const cdCode = `${message.author.id}.${cmd.options.name}`;
if (cooldowns_1.default.has(cdCode)) {
return message.client.emit('commandDenied', {
isMessage: true,
message,
type: 'message',
command: cmd,
user: message.author,
client: message.client
}, {
message: 'User is under cooldown',
metadata: {
remainingCooldownTime: cooldowns_1.default.get(cdCode) - Date.now()
},
code: Client_1.commandDeniedCode.UnderCooldown
});
}
cooldowns_1.default.set(cdCode, Date.now() + (cmd.options.cooldown || message.client.configs.defaultCooldownTime) * 1000);
setTimeout(() => {
cooldowns_1.default.delete(cdCode);
}, (cmd.options.cooldown || message.client.configs.defaultCooldownTime) * 1000);
cmd.messageRun({
message,
options: {
args: args,
first: args[0] ?? null,
second: args[1] ?? null,
emptyArgs: args.length === 0,
commandName: cmdName
},
client: message.client
});
});
const Event_js_1 = require("../structures/Event.js");
const messageInputRun_js_1 = require("../utils/messageInputRun.js");
exports.default = new Event_js_1.AmethystEvent('messageCreate', messageInputRun_js_1.messageInputRun);

@@ -17,3 +17,3 @@ import { Precondition } from './structures/Precondition';

export { ButtonDenied, ButtonDeniedCode, ButtonHandlerOptions, ButtonHandlerRun } from './typings/ButtonHandler';
export { ChatInputRun, commandDeniedPayload, commandOptions, MessageRun, UserContextRun, MessageContextRun, commandInteractionType, deniedPayloadInteractionType } from './typings/Command';
export { ChatInputRun, commandDeniedPayload, commandOptions, MessageRun, UserContextRun, MessageContextRun, commandInteractionType, deniedPayloadInteractionType, commandArgumentOptions } from './typings/Command';
export { AutocompleteListenerOptions, AutocompleteListenerRun, autocompleteListenerNamesType } from './typings/autocompleteListener';

@@ -20,0 +20,0 @@ export { amethystPaginatorOptions } from './structures/Paginator';

@@ -10,2 +10,4 @@ "use strict";

const log4JS = tslib_1.__importStar(require("./utils/log4js"));
const UserInVoiceChannel_1 = tslib_1.__importDefault(require("./preconditions/UserInVoiceChannel"));
const UserNotInVoiceChannel_1 = tslib_1.__importDefault(require("./preconditions/UserNotInVoiceChannel"));
// Structures

@@ -45,3 +47,5 @@ var AmethystClient_1 = require("./structures/AmethystClient");

NsfwOnly: NsfwOnly_1.default,
OwnerOnly: OwnerOnly_1.default
OwnerOnly: OwnerOnly_1.default,
UserInVoiceChannel: UserInVoiceChannel_1.default,
UserNotInVoiceChannel: UserNotInVoiceChannel_1.default
};

@@ -48,0 +52,0 @@ exports.log4js = log4JS;

@@ -52,3 +52,5 @@ "use strict";

defaultWaitTime: Math.round(Math.abs(configs?.defaultCooldownTime ?? 60000)),
defaultWhoCanReact: configs?.defaultWhoCanReact ?? 'useronly'
defaultWhoCanReact: configs?.defaultWhoCanReact ?? 'useronly',
runMessageCommandsOnMessageEdit: configs?.runMessageCommandsOnMessageEdit ?? false,
activity: configs?.activity,
};

@@ -159,2 +161,11 @@ }

this.on('ready', () => {
if (!!this.configs.activity) {
this.user.setActivity({
name: this.configs.activity?.name,
type: this.configs.activity?.type,
url: this.configs.activity?.url,
shardId: this.configs.activity?.shardId
});
}
this.user.setActivity();
const sc = [

@@ -339,2 +350,6 @@ ...this._chatInputCommands.map((cmd) => cmd.options),

[interactionCreate, messageCreate].forEach((x) => this.on(x.key, x.run));
if (this.configs.runMessageCommandsOnMessageEdit) {
const messageUpdate = require(`../events/messageUpdate.js`).default;
this.on(messageUpdate.key, messageUpdate.run);
}
this.on('ready', () => {

@@ -341,0 +356,0 @@ this.debug(`Logged as ${this.user.tag}`, Client_1.DebugImportance.Information);

@@ -1,2 +0,2 @@

import { BaseInteraction, ButtonInteraction, ChannelSelectMenuInteraction, ChannelType, ComponentType, InteractionReplyOptions, MentionableSelectMenuInteraction, Message, PermissionsString, RoleSelectMenuInteraction, StringSelectMenuInteraction, TextChannel, User, UserSelectMenuInteraction } from 'discord.js';
import { ActivityOptions, BaseInteraction, ButtonInteraction, ChannelSelectMenuInteraction, ChannelType, ComponentType, InteractionReplyOptions, MentionableSelectMenuInteraction, Message, PermissionsString, RoleSelectMenuInteraction, StringSelectMenuInteraction, TextChannel, User, UserSelectMenuInteraction } from 'discord.js';
type pathLike = `./${string}`;

@@ -216,2 +216,18 @@ export type architectureType = 'simple' | 'double';

};
/**
* Automatically set the bot's activity to the specified value
*
* @default `undefined`
* @type {ActivityOptions}
*/
activity?: ActivityOptions;
/**
* Defines if the bot has to handle the command if the content is edited
*
* For instance, if the command is `!!ping`, and the user sends `!!pong`, and then he edits it as `!!ping`, the bot will run the command (or not depending on this property)
*
* @default `false`
* @type {boolean}
*/
runMessageCommandsOnMessageEdit?: boolean;
};

@@ -312,3 +328,11 @@ export type startOptions = {

*/
ChannelNotNsfw = "Channel is not NSFW"
ChannelNotNsfw = "Channel is not NSFW",
/**
* Command can be executed only if the user is in a voice channel
*/
UserNotInVoiceChannel = "User not in voice channel",
/**
* Command can be executed only if the user is not in a voice channel
*/
UserInVoiceChannel = "User is in voice channel"
}

@@ -315,0 +339,0 @@ export declare enum errorCode {

@@ -56,2 +56,10 @@ "use strict";

commandDeniedCode["ChannelNotNsfw"] = "Channel is not NSFW";
/**
* Command can be executed only if the user is in a voice channel
*/
commandDeniedCode["UserNotInVoiceChannel"] = "User not in voice channel";
/**
* Command can be executed only if the user is not in a voice channel
*/
commandDeniedCode["UserInVoiceChannel"] = "User is in voice channel";
})(commandDeniedCode || (exports.commandDeniedCode = commandDeniedCode = {}));

@@ -58,0 +66,0 @@ var errorCode;

@@ -129,2 +129,29 @@ import { ChatInputApplicationCommandData, CommandInteractionOptionResolver, CommandInteraction, PermissionsString, Message, ChannelType, User, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction } from 'discord.js';

}) => void | unknown;
export type commandArgumentOptions = {
/**
* First argument parsed by the user
* It can be null if the user parses no arguments
*/
first: string | null;
/**
* Second argument parsed by the user
* It can be null if the user parses only one argument
*/
second: string | null;
/**
* Arguments parsed for the command
* Arguments are the rest of the command, splitted by space, after the command name
*
* This proprety also includes `first` and `second` arguments in options
*/
args: string[];
/**
* Indicates if arguments have been parsed by the user or not
*/
emptyArgs: boolean;
/**
* Name of the command used by the user to trigger the command
*/
commandName: string;
};
export type MessageRun = (options: {

@@ -138,29 +165,3 @@ /**

*/
options: {
/**
* First argument parsed by the user
* It can be null if the user parses no arguments
*/
first: string | null;
/**
* Second argument parsed by the user
* It can be null if the user parses only one argument
*/
second: string | null;
/**
* Arguments parsed for the command
* Arguments are the rest of the command, splitted by space, after the command name
*
* This proprety also includes `first` and `second` arguments in options
*/
args: string[];
/**
* Indicates if arguments have been parsed by the user or not
*/
emptyArgs: boolean;
/**
* Name of the command used by the user to trigger the command
*/
commandName: string;
};
options: commandArgumentOptions;
/**

@@ -167,0 +168,0 @@ * Amethyst Client of the command

import { ButtonInteraction, CacheType, CommandInteraction, CommandInteractionOptionResolver, ContextMenuCommandInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitInteraction, User, UserContextMenuCommandInteraction } from 'discord.js';
import { AmethystCommand } from '../structures/Command';
import { AmethystClient } from '../structures/AmethystClient';
import { commandArgumentOptions } from './Command';
/**

@@ -122,2 +123,8 @@ * Type of a precondition

message: Message;
/**
* Options passed to the command by the user
*
* @type commandArgumentOptions
*/
arguments: commandArgumentOptions;
} & BaseRun) => preconditionRunReturn;

@@ -124,0 +131,0 @@ /**

@@ -51,3 +51,4 @@ import {

commandInteractionType,
deniedPayloadInteractionType
deniedPayloadInteractionType,
commandArgumentOptions
} from './dist/typings/Command';

@@ -112,3 +113,4 @@ import { ButtonDenied, ButtonDeniedCode, ButtonHandlerOptions, ButtonHandlerRun } from './dist/typings/ButtonHandler';

fractionnedReplyReply,
fractionnedReplyType
fractionnedReplyType,
commandArgumentOptions
};

@@ -170,2 +172,3 @@ export { commandOptions, commandDeniedPayload } from './dist/typings/Command';

* defaultCooldownTime: 10,
* defaultWhoCanReact: 'useronly',
* waitForDefaultReplies: {

@@ -177,3 +180,9 @@ * user: ({ user, interaction }) => ({ content: "You cannot interact with this message" }),

* eventsArchitecture: 'simple',
* commandLocalizationsUsedAsNames: true
* commandLocalizationsUsedAsNames: true,
* activity: {
* name: 'Amethyst',
* type: 'Playing',
* url: 'https://github.com/Greensky-gs/amethystjs'
* },
* runMessageCommandsOnMessageEdit: true
* })

@@ -708,3 +717,3 @@ * ```

type preconditionNames = 'GuildOnly' | 'NsfwOnly' | 'DMOnly' | 'OwnerOnly';
type preconditionNames = 'GuildOnly' | 'NsfwOnly' | 'DMOnly' | 'OwnerOnly' | 'UserInVoiceChannel' | 'UserNotInVoiceChannel';
export const preconditions: Record<preconditionNames, Precondition>;

@@ -711,0 +720,0 @@ export { waitForInteraction } from './dist/utils/waitForInteraction';

{
"name": "amethystjs",
"version": "1.8.0",
"version": "1.8.1",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "repository": {

+44
-18

@@ -56,20 +56,31 @@ <p align="center">

}, {
botName: "your bot's name", // Optionnal
botNameWorksAsPrefix: true, // Wether if we can use the bot's name as prefix - optionnal
commandsFolder: './yourCommandsFolder', // Optionnal
eventsFolder: './yourEventsFolder', // Optionnal
prefix: "bot's prefix", // Optionnal
strictPrefix: true, // Wether if the prefix must be exactly the same - optionnal
mentionWorksAsPrefix: true, // Wether if we can use the bot by mentionning it
token: "Your bot's token",
debug: false, // Enable debug mode (get a lot of messages in the console) - optionnal
defaultCooldownTime: 5, // Default cooldown time
preconditionsFolder: "./yourPreconditionsFolder", // Specify the preconditions folder - optionnal
autocompleteListenersFolder: "./autocompleteListenersFolder", // Specify the autocomplete folder - optionnal
buttonsFolder: './buttonsFolder', // Specify the button folder for button handlers - optionnal
customPrefixAndDefaultAvailable?: true, // Specify if the default prefix is usable when a custom prefix is set - optionnal
modalHandlersFolder: "./yourModalHandlersFolder", // Specify the modal handlers folder
debbugColors: 'none', // 'none' | 'icon' | 'line', defines if the debugger uses colors - optional
commandsArchitecture: 'simple', // 'simple' | 'double', if simple, the commands inside the commandsFolder will be read, if double, the commands inside the directories of the commandsFolder will be read
eventsArchitecture: 'simple' // 'simple' | 'double', if simple, the events inside the eventsFolder will be read, if double, the events inside the directories of the eventsFolder will be read
token: process.env.token,
debug: true,
commandsFolder: './commands',
buttonsFolder: './button',
eventsFolder: './events',
modalHandlersFolder: './modals',
autocompleteListenersFolder: './autocompletes',
preconditionsFolder: './preconditions',
prefix: '!!',
strictPrefix: false,
botName: 'Amethyst',
botNameWorksAsPrefix: true,
mentionWorksAsPrefix: true,
defaultCooldownTime: 10,
waitForDefaultReplies: {
user: ({ user, interaction }) => ({ content: "You cannot interact with this message" }),
everyone: ({ user, interaction }) => ({ content: "You cannot interact with this message" })
},
commandsArchitecture: 'simple',
eventsArchitecture: 'simple',
commandLocalizationsUsedAsNames: true,
defaultWhoCanReact: 'useronly',
activity: {
name: 'Amethyst',
type: 'Playing',
url: 'https://github.com/Greensky-gs/amethystjs'
},
runMessageCommandsOnMessageEdit: true,
});

@@ -154,2 +165,17 @@ client.start({

### Before you start
Before you start creating your preconditions, know that there are defaults preconditions you can access using the `preconditions` object of the framework, like so :
```ts
import { preconditions, AmethystCommand } from 'amethystjs';
export default new AmethystCommand({
name: 'name',
preconditions: [ preconditions.OwnerOnly ] // Add the precondition you want
});
```
### Create a precondition
First, import the Precondition from Amethyst

@@ -156,0 +182,0 @@

Sorry, the diff of this file is not supported yet