Skip to content

Commit

Permalink
Merge pull request #28 from Tropicallism/main
Browse files Browse the repository at this point in the history
I hope it will work fine :))
  • Loading branch information
aiko-chan-ai authored Apr 11, 2022
2 parents 6af816d + 3bc4608 commit 5caadfe
Show file tree
Hide file tree
Showing 21 changed files with 5,918 additions and 5,938 deletions.
446 changes: 223 additions & 223 deletions src/managers/ApplicationCommandManager.js

Large diffs are not rendered by default.

844 changes: 422 additions & 422 deletions src/managers/ApplicationCommandPermissionsManager.js

Large diffs are not rendered by default.

150 changes: 75 additions & 75 deletions src/managers/BlockedManager.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
'use strict';

const CachedManager = require('./CachedManager');
const GuildMember = require('../structures/GuildMember');
const Message = require('../structures/Message');
const ThreadMember = require('../structures/ThreadMember');
const User = require('../structures/User');

/**
* Manages API methods for users and stores their cache.
* @extends {CachedManager}
*/
class BlockedManager extends CachedManager {
constructor(client, iterable) {
super(client, User, iterable);
}

/**
* The cache of this manager
* @type {Collection<Snowflake, User>}
* @name BlockedManager#cache
*/

/**
* Data that resolves to give a User object. This can be:
* * A User object
* * A Snowflake
* * A Message object (resolves to the message author)
* * A GuildMember object
* * A ThreadMember object
* @typedef {User|Snowflake|Message|GuildMember|ThreadMember} UserResolvable
*/

/**
* Resolves a {@link UserResolvable} to a {@link User} object.
* @param {UserResolvable} user The UserResolvable to identify
* @returns {?User}
*/
resolve(user) {
if (user instanceof GuildMember || user instanceof ThreadMember) return user.user;
if (user instanceof Message) return user.author;
return super.resolve(user);
}

/**
* Resolves a {@link UserResolvable} to a {@link User} id.
* @param {UserResolvable} user The UserResolvable to identify
* @returns {?Snowflake}
*/
resolveId(user) {
if (user instanceof ThreadMember) return user.id;
if (user instanceof GuildMember) return user.user.id;
if (user instanceof Message) return user.author.id;
return super.resolveId(user);
}

/**
* Obtains a user from Discord, or the user cache if it's already available.
* @param {UserResolvable} user The user to fetch
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<User>}
*/
async fetch(user, { cache = true, force = false } = {}) {
const id = this.resolveId(user);
if (!force) {
const existing = this.cache.get(id);
if (existing && !existing.partial) return existing;
}

const data = await this.client.api.users(id).get();
return this._add(data, cache);
}
}

module.exports = BlockedManager;
'use strict';

const CachedManager = require('./CachedManager');
const GuildMember = require('../structures/GuildMember');
const Message = require('../structures/Message');
const ThreadMember = require('../structures/ThreadMember');
const User = require('../structures/User');

/**
* Manages API methods for users and stores their cache.
* @extends {CachedManager}
*/
class BlockedManager extends CachedManager {
constructor(client, iterable) {
super(client, User, iterable);
}

/**
* The cache of this manager
* @type {Collection<Snowflake, User>}
* @name BlockedManager#cache
*/

/**
* Data that resolves to give a User object. This can be:
* * A User object
* * A Snowflake
* * A Message object (resolves to the message author)
* * A GuildMember object
* * A ThreadMember object
* @typedef {User|Snowflake|Message|GuildMember|ThreadMember} UserResolvable
*/

/**
* Resolves a {@link UserResolvable} to a {@link User} object.
* @param {UserResolvable} user The UserResolvable to identify
* @returns {?User}
*/
resolve(user) {
if (user instanceof GuildMember || user instanceof ThreadMember) return user.user;
if (user instanceof Message) return user.author;
return super.resolve(user);
}

/**
* Resolves a {@link UserResolvable} to a {@link User} id.
* @param {UserResolvable} user The UserResolvable to identify
* @returns {?Snowflake}
*/
resolveId(user) {
if (user instanceof ThreadMember) return user.id;
if (user instanceof GuildMember) return user.user.id;
if (user instanceof Message) return user.author.id;
return super.resolveId(user);
}

/**
* Obtains a user from Discord, or the user cache if it's already available.
* @param {UserResolvable} user The user to fetch
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<User>}
*/
async fetch(user, { cache = true, force = false } = {}) {
const id = this.resolveId(user);
if (!force) {
const existing = this.cache.get(id);
if (existing && !existing.partial) return existing;
}

const data = await this.client.api.users(id).get();
return this._add(data, cache);
}
}

module.exports = BlockedManager;
Loading

0 comments on commit 5caadfe

Please sign in to comment.