New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

arunabase

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arunabase - npm Package Compare versions

Comparing version 1.0.0-ALPHA.3 to 1.0.0-ALPHA.4

12

package.json
{
"name": "arunabase",
"version": "1.0.0-ALPHA.3",
"version": "1.0.0-ALPHA.4",
"description": "An API made to help developers what works with discord and twitch.",

@@ -32,14 +32,14 @@ "main": "./src/index.js",

"@types/express": "^4.17.15",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"eslint": "^8.31.0",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"prettier": "^2.8.2",
"prettier": "^2.8.3",
"typescript": "^4.9.4"
}
}

@@ -45,2 +45,3 @@ "use strict";

client: this,
logger: this.logger,
prefix: this.prefix,

@@ -47,0 +48,0 @@ allowLegacyCommands: this.allowLegacyCommands,

@@ -69,3 +69,4 @@ import { IAsyncCommandOptions, ICommandGuildScope, ICommandManagerOptions, ICommandOptions } from '../../interfaces';

*/
registerCommand(command: CommandStructureBased): Promise<Collection<string | ICommandGuildScope, CommandStructureBased>>;
registerCommand(command: CommandStructureBased): Promise<CommandStructureBased>;
unregisterCommand(command: CommandStructureBased): Promise<boolean>;
/**

@@ -72,0 +73,0 @@ * Gets the collection of guild-specific commands.

@@ -90,10 +90,13 @@ "use strict";

if (!command)
throw new Error('Command is not defined');
throw new Error('CommandManager: Command is not defined.');
if (!this.options.client.isReady()) {
throw new Error('CommandManager: Tryed to register a command before the client is ready. ' + command.getName());
}
if (command.isGlobalCommand() && this.globalCommands.has(command.getName()))
throw new Error(`Command ${command.getName()} already exists in global scope.`);
// eslint-disable-next-line max-len
if (!command.isGlobalCommand() && this.guildCommands.has({ guildID: command.getGuildID(), commandName: command.getName() }))
throw new Error(`Command ${command.getName()} already exists in guild scope.`);
if (command.isSlash()) {
// Slash Command
if (command.isGlobalCommand() && this.globalCommands.has(command.getName()))
throw new Error(`Command ${command.getName()} already exists in global scope.`);
// eslint-disable-next-line max-len
if (!command.isGlobalCommand() && this.guildCommands.has({ guildID: command.getGuildID(), commandName: command.getName() }))
throw new Error(`Command ${command.getName()} already exists in guild scope.`);
const structuredCommand = {

@@ -104,4 +107,2 @@ name: command.getName(),

dm_permission: command.isDMAllowed(),
guild_id: command.getGuildID(),
options: command.getParameters(),
};

@@ -115,6 +116,6 @@ if (command.isLocalizedCommand()) {

}
if (command.getParameters().length === 0)
delete structuredCommand.options;
if (command.isGlobalCommand())
delete structuredCommand.guild_id;
if (command.getParameters().length > 0)
Object.defineProperty(structuredCommand, 'options', command.getParameters());
if (!command.isGlobalCommand())
Object.defineProperty(structuredCommand, 'guild_id', command.getGuildID());
const requestResult = yield this.httpClient.post('v10',

@@ -127,10 +128,39 @@ // eslint-disable-next-line max-len

throw new Error(`${!command.isGlobalCommand() ? 'Guild ' : ''}Command ${command.getName()} could not be registered.\nStatus code: ${requestResult[1]}\nResponse: ${requestResult[0]}`);
const responseJson = JSON.parse(requestResult[0]);
command.setSlashId(responseJson.id);
}
// eslint-disable-next-line max-len
if (command.isGlobalCommand())
this.globalCommands.set(command.getName(), command);
else
this.guildCommands.set({ guildID: command.getGuildID(), commandName: command.getName() }, command);
return command;
});
}
unregisterCommand(command) {
return __awaiter(this, void 0, void 0, function* () {
if (!command)
throw new Error('CommandManager: Command is not defined.');
if (!this.options.client.isReady())
throw new Error('CommandManager: Tryed to unregister a command before the client is ready. ' + command.getName());
if (command.isGlobalCommand() && !this.globalCommands.has(command.getName()))
throw new Error(`Command ${command.getName()} does not exists in global scope.`);
// eslint-disable-next-line max-len
if (!command.isGlobalCommand() && !this.guildCommands.has({ guildID: command.getGuildID(), commandName: command.getName() }))
throw new Error(`Command ${command.getName()} does not exists in guild scope.`);
if (command.isSlash()) {
const requestResult = yield this.httpClient.delete('v10',
// eslint-disable-next-line max-len
if (command.isGlobalCommand())
return this.globalCommands.set(command.getName(), command);
else
return this.guildCommands.set({ guildID: command.getGuildID(), commandName: command.getName() }, command);
command.isGlobalCommand() ? `applications/${this.options.client.application.id}/commands/${command.getSlashId()}` : `applications/${this.options.client.application.id}/guilds/${command.getGuildID()}/commands/${command.getSlashId()}`, this.options.client.token);
const commandUnregisterSuccessfully = (requestResult[1] === 204);
// eslint-disable-next-line max-len
if (!commandUnregisterSuccessfully)
throw new Error(`${!command.isGlobalCommand() ? 'Guild ' : ''}Command ${command.getName()} could not be unregistered.\nStatus code: ${requestResult[1]}\nResponse: ${requestResult[0]}`);
}
// if it succeeds we set the command internally, otherwise we throw an error and the command is not registered
return this.globalCommands.set(command.getName(), command);
if (command.isGlobalCommand()) {
return this.globalCommands.delete(command.getName());
}
else {
return this.guildCommands.delete({ guildID: command.getGuildID(), commandName: command.getName() });
}
});

@@ -137,0 +167,0 @@ }

@@ -17,2 +17,3 @@ import { IAsyncCommandOptions, ICommandOptions, ICommandParameter, ILocalizationBase, IDiscordCommandContext } from '../../interfaces';

protected nsfw: boolean;
protected slashId: string;
constructor(name: string, options: ICommandOptions);

@@ -29,2 +30,4 @@ private checkAndFixInvalidParameters;

getParameters(): ICommandParameter[];
getSlashId(): string;
setSlashId(id: string): void;
isAsyncCommand(): boolean;

@@ -39,10 +42,10 @@ isSlash(): boolean;

export declare class CommandStructure extends CommandStructureBase {
protected command: (context: IDiscordCommandContext) => void;
constructor(name: string, options: ICommandOptions);
run(context: IDiscordCommandContext): void;
protected execute(context: IDiscordCommandContext): void;
}
export declare class AsyncCommandStructure extends CommandStructure {
protected command: (context: IDiscordCommandContext) => Promise<void>;
constructor(name: string, options: IAsyncCommandOptions);
run(context: IDiscordCommandContext): Promise<void>;
protected execute(context: IDiscordCommandContext): Promise<void>;
}

@@ -49,0 +52,0 @@ export type CommandStructureBased = CommandStructure | AsyncCommandStructure;

@@ -192,2 +192,12 @@ "use strict";

}
getSlashId() {
return this.slashId;
}
setSlashId(id) {
if (!this.isSlashCommand)
throw new Error('Cannot set slash ID on a non slash command');
if (this.slashId)
throw new Error('Slash ID is already set');
this.slashId = id;
}
isAsyncCommand() {

@@ -218,10 +228,12 @@ return this.isAsync;

super(name, options);
if (!options.command)
throw new Error('Command is not defined');
this.command = options.command;
if (options.command !== null)
this.execute = options.command;
this.isAsync = false;
}
run(context) {
return this.command(context);
return this.execute(context);
}
execute(context) {
throw new Error('Method not implemented.');
}
}

@@ -232,5 +244,4 @@ exports.CommandStructure = CommandStructure;

super(name, options);
if (!options.command)
throw new Error('Command is not defined');
this.command = options.command;
if (options.command !== null)
this.execute = options.command;
this.isAsync = true;

@@ -240,6 +251,11 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield this.command(context);
return yield this.execute(context);
});
}
execute(context) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error('Method not implemented.');
});
}
}
exports.AsyncCommandStructure = AsyncCommandStructure;

@@ -1,5 +0,4 @@

/// <reference types="node" />
import { IncomingMessage } from 'http';
import { HTTPClientBase } from '../../http';
export declare class HTTPClient extends HTTPClientBase {
private makeRequest;
/**

@@ -12,8 +11,8 @@ * post

*/
delete(version: string, path: string, token: string, body?: any): Promise<IncomingMessage>;
delete(version: string, path: string, token: string, body?: any): Promise<[string | null, number]>;
/**
* patch
*/
patch(version: string, path: string, token: string, body?: any): Promise<IncomingMessage>;
patch(version: string, path: string, token: string, body?: any): Promise<[string | null, number]>;
}
//# sourceMappingURL=HTTPClient.d.ts.map

@@ -15,9 +15,6 @@ "use strict";

class HTTPClient extends http_1.HTTPClientBase {
/**
* post
*/
post(version, path, token, body = null) {
makeRequest(method, version, path, token, body = null) {
return __awaiter(this, void 0, void 0, function* () {
const request = yield this.sendRequest(`https://discord.com/api/${version}/${path}`, {
method: 'POST',
method: method.toUpperCase(),
protocol: 'https',

@@ -43,13 +40,15 @@ headers: {

/**
* post
*/
post(version, path, token, body = null) {
return __awaiter(this, void 0, void 0, function* () {
return this.makeRequest('POST', version, path, token, body);
});
}
/**
* delete
*/
delete(version, path, token, body = null) {
return this.sendRequest(`https://discord.com/api/${version}/${path}`, {
method: 'DELETE',
protocol: 'https',
headers: {
Authorization: `Bot ${token}`,
'Content-Type': 'application/json',
},
body,
return __awaiter(this, void 0, void 0, function* () {
return this.makeRequest('DELETE', version, path, token, body);
});

@@ -61,10 +60,4 @@ }

patch(version, path, token, body = null) {
return this.sendRequest(`https://discord.com/api/${version}/${path}`, {
method: 'PATCH',
protocol: 'https',
headers: {
Authorization: `Bot ${token}`,
'Content-Type': 'application/json',
},
body,
return __awaiter(this, void 0, void 0, function* () {
return this.makeRequest('PATCH', version, path, token, body);
});

@@ -71,0 +64,0 @@ }

import { ApplicationCommandOptionType, ApplicationCommandPermissions, ApplicationCommandType, APIApplicationCommandOptionChoice, CategoryChannelType } from 'discord.js';
import { IDiscordCommandContext } from './IDiscordCommandContext';
import { Utils } from '@twitchapis/twitch.js';
import { DiscordClient } from '../discord';
export interface ICommandManagerOptions {
client: DiscordClient;
logger: Utils.Logger;
additionalContext?: {

@@ -39,3 +41,3 @@ [key: symbol]: any;

allowDM?: boolean;
command: (context: IDiscordCommandContext) => void;
command?: (context: IDiscordCommandContext) => void;
guildID?: string;

@@ -49,4 +51,4 @@ aliases?: string[];

export interface IAsyncCommandOptions extends ICommandOptions {
command: (context: IDiscordCommandContext) => Promise<void>;
command?: (context: IDiscordCommandContext) => Promise<void>;
}
//# sourceMappingURL=IOptions.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc