Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 1 addition & 82 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {Command, CommandRequirements, CommandContext} from './Command';
import {EventListener, EventContext} from './EventListener';
import defaultMessageListener from './defaultMessageListener';
import {Resolves, makeArray} from './util';
import * as deprecations from './deprecations';

/** The options passed to the client constructor. Includes Eris options. */
export interface ClientOptions extends Eris.ClientOptions {
Expand All @@ -29,13 +28,6 @@ export interface ClientOptions extends Eris.ClientOptions {
ignoreBots?: boolean;
/** A set of requirements to check for all commands. */
globalCommandRequirements?: CommandRequirements;
/**
* If true, requirements set via the globalCommandRequirements option will
* be ignored.
* @deprecated Pass no `globalCommandRequirements` client option instead.
* See https://github.com/eritbh/yuuko/issues/89
*/
ignoreGlobalRequirements?: boolean;
/**
* If true, the client does not respond to commands by default, and the user
* must register their own `messageCreate` listener, which can call
Expand All @@ -45,13 +37,6 @@ export interface ClientOptions extends Eris.ClientOptions {
disableDefaultMessageListener?: boolean;
}

/**
* Information returned from the API about the bot's OAuth application.
* @deprecated Use `Eris.OAuthApplicationInfo` instead. See
* https://github.com/eritbh/yuuko/issues/91
*/
export type ClientOAuthApplication = Eris.OAuthApplicationInfo;

// A function that takes a message and a context argument and returns a prefix,
// an array of prefixes, or void.
export interface PrefixFunction {
Expand Down Expand Up @@ -85,14 +70,6 @@ export class Client extends Eris.Client implements ClientOptions {
/** A set of requirements to check for all commands. */
globalCommandRequirements: CommandRequirements = {};

/**
* If true, requirements set via `setGlobalRequirements` will be ignored. Used
* for debugging, probably shouldn't be used in production.
* @deprecated Pass no `globalCommandRequirements` client option instead.
* See https://github.com/eritbh/yuuko/issues/89
*/
ignoreGlobalRequirements: boolean = false;

/**
* If true, the client does not respond to commands by default, and the user
* must register their own `messageCreate` listener, which can call
Expand Down Expand Up @@ -123,7 +100,7 @@ export class Client extends Eris.Client implements ClientOptions {
mentionPrefixRegExp: RegExp | null = null;

/** Information about the bot's OAuth application. */
app: ClientOAuthApplication | null = null;
app: Eris.OAuthApplicationInfo | null = null;

/** An object of stuff to add to the context object for command functions */
contextAdditions: object = {};
Expand All @@ -145,10 +122,6 @@ export class Client extends Eris.Client implements ClientOptions {
if (options.allowMention !== undefined) this.allowMention = options.allowMention;
if (options.ignoreBots !== undefined) this.ignoreBots = options.ignoreBots;
if (options.globalCommandRequirements !== undefined) this.globalCommandRequirements = options.globalCommandRequirements;
if (options.ignoreGlobalRequirements !== undefined) {
deprecations.ignoreGlobalRequirements();
this.ignoreGlobalRequirements = options.ignoreGlobalRequirements;
}
if (options.disableDefaultMessageListener !== undefined) this.disableDefaultMessageListener = options.disableDefaultMessageListener;

// Warn if we're using an empty prefix
Expand Down Expand Up @@ -246,17 +219,6 @@ export class Client extends Eris.Client implements ClientOptions {
return this;
}

/**
* Set requirements for all commands at once
* @deprecated Use the `globalCommandRequirements` client option instead.
* See https://github.com/eritbh/yuuko/issues/89
*/
setGlobalRequirements (requirements: CommandRequirements) {
deprecations.setGlobalRequirements();
Object.assign(this.globalCommandRequirements, requirements);
return this;
}

/** Register a command to the client. */
addCommand (command: Command): this {
if (!(command instanceof Command)) throw new TypeError('Not a command');
Expand Down Expand Up @@ -413,34 +375,6 @@ export class Client extends Eris.Client implements ClientOptions {
return this;
}

/**
* Alias for `addDir`.
* @deprecated Use `addDir` instead. See
* https://github.com/eritbh/yuuko/issues/88
*/
addCommandDir (dirname: string): this {
deprecations.addCommandDir();
return this.addDir(dirname);
}

/**
* Alias for `addFile`.
* @deprecated Use `addFile` instead. See https://github.com/eritbh/yuuko/issues/88
*/
addCommandFile (filename: string): this {
deprecations.addCommandFile();
return this.addFile(filename);
}

/**
* Alias for `reloadFiles()`.
* @deprecated Use `reloadFiles` instead. See https://github.com/eritbh/yuuko/issues/88
*/
reloadCommands (): this {
deprecations.reloadCommands();
return this.reloadFiles();
}

/**
* Checks the list of registered commands and returns one whch is known by a
* given name. Passing an empty string will return the default command, if
Expand Down Expand Up @@ -508,21 +442,6 @@ export class Client extends Eris.Client implements ClientOptions {
// we got nothing
return null;
}

/**
* Alias of `prefix`.
* @deprecated Use `prefix` instead.
* See https://github.com/eritbh/yuuko/issues/90
*/
get defaultPrefix () {
deprecations.defaultPrefix();
return this.prefix;
}

set defaultPrefix (val: string) {
deprecations.defaultPrefix();
this.prefix = val;
}
}

export interface ClientEvents<T> extends Eris.ClientEvents<T> {
Expand Down
6 changes: 2 additions & 4 deletions src/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,8 @@ export class Command {

/** Checks whether or not a command can be executed. */
async checkPermissions (msg: Eris.Message, args: string[], ctx: CommandContext): Promise<boolean> {
if (!ctx.client.ignoreGlobalRequirements) {
if (!await fulfillsRequirements(ctx.client.globalCommandRequirements, msg, args, ctx)) {
return false;
}
if (!await fulfillsRequirements(ctx.client.globalCommandRequirements, msg, args, ctx)) {
return false;
}
return fulfillsRequirements(this.requirements, msg, args, ctx);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Command} from '../Yuuko';
export default new Command('reload', (msg, args, {client}) => {
msg.channel.sendTyping();
setTimeout(() => { // Delay by 100ms to make sure the sendTyping arrives first
client.reloadCommands();
client.reloadFiles();
msg.channel.createMessage('Reloaded commands.');
}, 100);
}, {
Expand Down
15 changes: 3 additions & 12 deletions src/deprecations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {emitWarning} from 'process';

// This function being unused is fine, it just means there's nothing deprecated
// to emit warnings about right now. There will be more in the future :V
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function warningEmitter (warning, code) {
let hasWarned = false;
return () => {
Expand All @@ -8,15 +11,3 @@ function warningEmitter (warning, code) {
emitWarning(warning, 'DeprecationWarning', code);
};
}

// https://github.com/eritbh/yuuko/issues/88
export const addCommandDir = warningEmitter('Client#addCommandDir is deprecated. Use Client#addDir instead.', 'yuuko#88');
export const addCommandFile = warningEmitter('Client#addCommandFile is deprecated. Use Client#addFile instead.', 'yuuko#88');
export const reloadCommands = warningEmitter('Client#reloadCommands is deprecated. Use Client#reloadFiles instead.', 'yuuko#88');

// https://github.com/eritbh/yuuko/issues/89
export const setGlobalRequirements = warningEmitter('Client#setGlobalRequirements is deprecated. Use the globalCommandRequirements client option instead.', 'yuuko#89');
export const ignoreGlobalRequirements = warningEmitter('The ignoreGlobalRequirements client option is deprecated. Pass no globalCommandRequirements client option instead.', 'yuuko#89');

// https://github.com/eritbh/yuuko/issues/90
export const defaultPrefix = warningEmitter('Client#edfaultPrefix is deprecated. Use Client#prefix instead.', 'yuuko#90');