Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use token property in SlasherClientOptions #11

Closed
Romejanic opened this issue Jul 25, 2022 · 2 comments
Closed

Cannot use token property in SlasherClientOptions #11

Romejanic opened this issue Jul 25, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Romejanic
Copy link
Owner

Describe the bug
Attempting to set the bot token via the token property in the client options results in the token being unable to be loaded. This is caused because the token property is removed from the options object before it can be read by the token loading code.

// called BEFORE the token is read
function filterOptions(options) {
    let finalOptions = options;
    if (!options.intents) {
        finalOptions.intents = [discord_js_1.Intents.FLAGS.GUILDS];
    }
    else if (Array.isArray(options.intents)) {
        finalOptions.intents = [...options.intents, discord_js_1.Intents.FLAGS.GUILDS];
    }
    else if (typeof options.intents === "number") {
        finalOptions.intents = options.intents & discord_js_1.Intents.FLAGS.GUILDS;
    }
    else if (typeof options.intents === "string") {
        // this probably shouldn't be used, but maybe the user
        // needs a specific intent other than GUILDS? just leave
        // it be
        finalOptions.intents = options.intents;
    }
    delete options.token; // <-- HERE token is erroneously deleted
    return finalOptions;
}
@Romejanic Romejanic added the bug Something isn't working label Jul 25, 2022
@Romejanic Romejanic self-assigned this Jul 25, 2022
@Romejanic
Copy link
Owner Author

Probably no reason to delete the token property. The object is only passed to the underlying discord.js client constructor which will do nothing with it.

@Romejanic
Copy link
Owner Author

Fixed in release 0.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant