discordjs-testing
Advanced tools
Comparing version 0.0.0-beta to 0.0.0-delta
{ | ||
"name": "discordjs-testing", | ||
"version": "0.0.0-beta", | ||
"version": "0.0.0-delta", | ||
"description": "Helper package for testing DiscordJS bots with Mocha/Chai", | ||
@@ -12,3 +12,4 @@ "main": "prod/index.js", | ||
"test": "ts-mocha -u tdd test/index.spec.ts test/**/*.spec.ts --recursive --timeout 10000", | ||
"prepack": "npm run build" | ||
"prepack": "npm run build", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -15,0 +16,0 @@ "repository": { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -36,6 +45,8 @@ exports.MockBanManager = void 0; | ||
fetch(id) { | ||
if (id) { | ||
return new Promise(() => this._cache.get(id) || null); | ||
} | ||
return new Promise(() => this._cache); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (id) { | ||
return this._cache.get(id) || null; | ||
} | ||
return this._cache; | ||
}); | ||
} | ||
@@ -53,9 +64,11 @@ /** | ||
create(user, options) { | ||
const ban = new MockBan_1.MockBan({ | ||
member: user, | ||
reason: (options === null || options === void 0 ? void 0 : options.reason) || "No reason provided.", | ||
guild: this._guild, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const ban = new MockBan_1.MockBan({ | ||
member: user, | ||
reason: (options === null || options === void 0 ? void 0 : options.reason) || "No reason provided.", | ||
guild: this._guild, | ||
}); | ||
this._cache.set(ban.user.id, ban); | ||
return user; | ||
}); | ||
this._cache.set(ban.user.id, ban); | ||
return new Promise(() => user); | ||
} | ||
@@ -71,6 +84,8 @@ /** | ||
remove(user) { | ||
this._cache.delete(user.id); | ||
return new Promise(() => user); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._cache.delete(user.id); | ||
return user; | ||
}); | ||
} | ||
} | ||
exports.MockBanManager = MockBanManager; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -73,6 +82,8 @@ exports.MockChannel = void 0; | ||
send(message, author) { | ||
const msg = this._messages.send(message, author); | ||
return new Promise(() => msg); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const msg = yield this._messages.send(message, author); | ||
return msg; | ||
}); | ||
} | ||
} | ||
exports.MockChannel = MockChannel; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -36,6 +45,8 @@ exports.MockChannelManager = void 0; | ||
fetch(id) { | ||
if (id) { | ||
return new Promise(() => this._cache.get(id) || null); | ||
} | ||
return new Promise(() => this._cache); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (id) { | ||
return this._cache.get(id) || null; | ||
} | ||
return this._cache; | ||
}); | ||
} | ||
@@ -52,5 +63,7 @@ /** | ||
create(options) { | ||
const channel = new MockChannel_1.MockChannel(Object.assign(Object.assign({}, options), { guild: this._guild })); | ||
this._cache.set(channel.id, channel); | ||
return new Promise(() => channel); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const channel = new MockChannel_1.MockChannel(Object.assign(Object.assign({}, options), { guild: this._guild })); | ||
this._cache.set(channel.id, channel); | ||
return channel; | ||
}); | ||
} | ||
@@ -66,6 +79,8 @@ /** | ||
delete(id) { | ||
this._cache.delete(id); | ||
return Promise.resolve(); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._cache.delete(id); | ||
return; | ||
}); | ||
} | ||
} | ||
exports.MockChannelManager = MockChannelManager; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -124,8 +133,10 @@ exports.MockChatInputCommandInteraction = void 0; | ||
deferReply(options) { | ||
if (this._deferred) { | ||
throw new Error("Interaction already deferred."); | ||
} | ||
this._deferred = true; | ||
this._ephemeral = (options === null || options === void 0 ? void 0 : options.ephemeral) || false; | ||
return new Promise(() => true); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this._deferred) { | ||
throw new Error("Interaction already deferred."); | ||
} | ||
this._deferred = true; | ||
this._ephemeral = (options === null || options === void 0 ? void 0 : options.ephemeral) || false; | ||
return true; | ||
}); | ||
} | ||
@@ -142,26 +153,28 @@ /** | ||
reply(payload) { | ||
if (this._deferred || this._replies.length) { | ||
throw new Error("Interaction already deferred or replied."); | ||
} | ||
if (typeof payload === "string") { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this._deferred || this._replies.length) { | ||
throw new Error("Interaction already deferred or replied."); | ||
} | ||
if (typeof payload === "string") { | ||
const message = new MockInteractionMessage_1.MockInteractionMessage({ | ||
content: payload, | ||
author: this._bot, | ||
channel: this._channel, | ||
ephemeral: this._ephemeral, | ||
}); | ||
this._replies.push(message); | ||
return message; | ||
} | ||
const { content, embeds, attachments, ephemeral } = payload; | ||
const message = new MockInteractionMessage_1.MockInteractionMessage({ | ||
content: payload, | ||
content, | ||
embeds, | ||
attachments, | ||
ephemeral, | ||
author: this._bot, | ||
channel: this._channel, | ||
ephemeral: this._ephemeral, | ||
}); | ||
this._replies.push(message); | ||
return new Promise(() => message); | ||
} | ||
const { content, embeds, attachments, ephemeral } = payload; | ||
const message = new MockInteractionMessage_1.MockInteractionMessage({ | ||
content, | ||
embeds, | ||
attachments, | ||
ephemeral, | ||
author: this._bot, | ||
channel: this._channel, | ||
return message; | ||
}); | ||
this._replies.push(message); | ||
return new Promise(() => message); | ||
} | ||
@@ -179,8 +192,10 @@ /** | ||
editReply(payload) { | ||
if (!this._deferred && this._replies.length !== 1) { | ||
throw new Error("Interaction has not been deferred or replied."); | ||
} | ||
this._replies.pop(); | ||
const message = this.reply(payload); | ||
return message; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this._deferred && this._replies.length !== 1) { | ||
throw new Error("Interaction has not been deferred or replied."); | ||
} | ||
this._replies.pop(); | ||
const message = this.reply(payload); | ||
return message; | ||
}); | ||
} | ||
@@ -187,0 +202,0 @@ /** |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -76,3 +85,5 @@ exports.MockGuild = void 0; | ||
fetch() { | ||
return new Promise(() => this); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this; | ||
}); | ||
} | ||
@@ -88,7 +99,9 @@ /** | ||
ban(options) { | ||
const ban = new MockBan_1.MockBan(options); | ||
this._bans.create(options.member, ban); | ||
return new Promise(() => ban); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const ban = new MockBan_1.MockBan(options); | ||
this._bans.create(options.member, ban); | ||
return ban; | ||
}); | ||
} | ||
} | ||
exports.MockGuild = MockGuild; |
@@ -52,3 +52,2 @@ import { PermissionsBitField } from "discord.js"; | ||
* @public | ||
* @readonly | ||
*/ | ||
@@ -59,6 +58,15 @@ get bannable(): boolean; | ||
* @public | ||
* @readonly | ||
*/ | ||
set bannable(value: boolean); | ||
/** | ||
* @type {boolean} | ||
* @public | ||
*/ | ||
get kickable(): boolean; | ||
/** | ||
* @type {boolean} | ||
* @public | ||
*/ | ||
set kickable(value: boolean); | ||
/** | ||
* @type {number} | ||
@@ -79,2 +87,3 @@ * @public | ||
* @param {string} reason The reason for the ban. | ||
* @returns {Promise<MockMember>} The member. | ||
* @public | ||
@@ -96,2 +105,3 @@ * @async | ||
* @param {number} timeout The timeout in milliseconds. | ||
* @returns {Promise<MockMember>} The member. | ||
* @public | ||
@@ -98,0 +108,0 @@ * @async |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -61,3 +70,2 @@ exports.MockMember = void 0; | ||
* @public | ||
* @readonly | ||
*/ | ||
@@ -70,4 +78,10 @@ get bannable() { | ||
* @public | ||
* @readonly | ||
*/ | ||
set bannable(value) { | ||
this._bannable = value; | ||
} | ||
/** | ||
* @type {boolean} | ||
* @public | ||
*/ | ||
get kickable() { | ||
@@ -77,2 +91,9 @@ return this._kickable; | ||
/** | ||
* @type {boolean} | ||
* @public | ||
*/ | ||
set kickable(value) { | ||
this._kickable = value; | ||
} | ||
/** | ||
* @type {number} | ||
@@ -97,2 +118,3 @@ * @public | ||
* @param {string} reason The reason for the ban. | ||
* @returns {Promise<MockMember>} The member. | ||
* @public | ||
@@ -102,8 +124,11 @@ * @async | ||
ban(reason) { | ||
this._guild.ban({ | ||
reason, | ||
member: this, | ||
guild: this._guild, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._guild.ban({ | ||
reason, | ||
member: this, | ||
guild: this._guild, | ||
}); | ||
this._guild.members.remove(this._id); | ||
return this; | ||
}); | ||
return new Promise(() => this); | ||
} | ||
@@ -118,4 +143,6 @@ /** | ||
kick() { | ||
this._guild.members.remove(this._id); | ||
return new Promise(() => this); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._guild.members.remove(this._id); | ||
return this; | ||
}); | ||
} | ||
@@ -126,2 +153,3 @@ /** | ||
* @param {number} timeout The timeout in milliseconds. | ||
* @returns {Promise<MockMember>} The member. | ||
* @public | ||
@@ -131,6 +159,8 @@ * @async | ||
timeout(timeout) { | ||
this._timeoutDuration = timeout; | ||
return new Promise(() => this); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._timeoutDuration = timeout; | ||
return this; | ||
}); | ||
} | ||
} | ||
exports.MockMember = MockMember; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -36,6 +45,8 @@ exports.MockMemberManager = void 0; | ||
fetch(id) { | ||
if (id) { | ||
return new Promise(() => this._cache.get(id) || null); | ||
} | ||
return new Promise(() => this._cache); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (id) { | ||
return this._cache.get(id) || null; | ||
} | ||
return this._cache; | ||
}); | ||
} | ||
@@ -50,8 +61,10 @@ /** | ||
add(user) { | ||
const member = new MockMember_1.MockMember({ | ||
user, | ||
guild: this._guild, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const member = new MockMember_1.MockMember({ | ||
user, | ||
guild: this._guild, | ||
}); | ||
this._cache.set(member.user.id, member); | ||
return member; | ||
}); | ||
this._cache.set(member.user.id, member); | ||
return new Promise(() => member); | ||
} | ||
@@ -58,0 +71,0 @@ /** |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -108,13 +117,15 @@ exports.MockMessage = void 0; | ||
edit(options) { | ||
if (typeof options === "string") { | ||
this._content = options; | ||
} | ||
else { | ||
this._content = options.content || this._content; | ||
this._embeds = options.embeds || this._embeds; | ||
this._attachments = options.attachments || this._attachments; | ||
} | ||
return new Promise(() => this); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof options === "string") { | ||
this._content = options; | ||
} | ||
else { | ||
this._content = options.content || this._content; | ||
this._embeds = options.embeds || this._embeds; | ||
this._attachments = options.attachments || this._attachments; | ||
} | ||
return this; | ||
}); | ||
} | ||
} | ||
exports.MockMessage = MockMessage; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -44,6 +53,8 @@ exports.MockMessageManager = void 0; | ||
fetch(id) { | ||
if (id) { | ||
return new Promise(() => this._cache.get(id) || null); | ||
} | ||
return new Promise(() => this._cache); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (id) { | ||
return this._cache.get(id) || null; | ||
} | ||
return this._cache; | ||
}); | ||
} | ||
@@ -60,8 +71,10 @@ /** | ||
send(message, author) { | ||
const opts = typeof message === "string" ? { content: message } : message; | ||
const mockMessage = new MockMessage_1.MockMessage(Object.assign(Object.assign({}, opts), { channel: this._channel, guild: this._channel.guild, author })); | ||
this._cache.set(mockMessage.id, mockMessage); | ||
return new Promise(() => mockMessage); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const opts = typeof message === "string" ? { content: message } : message; | ||
const mockMessage = new MockMessage_1.MockMessage(Object.assign(Object.assign({}, opts), { channel: this._channel, guild: this._channel.guild, author })); | ||
this._cache.set(mockMessage.id, mockMessage); | ||
return mockMessage; | ||
}); | ||
} | ||
} | ||
exports.MockMessageManager = MockMessageManager; |
@@ -45,5 +45,6 @@ import { Collection } from "discord.js"; | ||
* @param {string?} options.reason The reason for the role. | ||
* @returns {MockRole} The created role. | ||
* @public | ||
*/ | ||
create(options: Omit<RoleParameters, "guild">): void; | ||
create(options: Omit<RoleParameters, "guild">): MockRole; | ||
/** | ||
@@ -50,0 +51,0 @@ * Removes a role from the guild. |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -36,6 +45,8 @@ exports.MockRoleManager = void 0; | ||
fetch(id) { | ||
if (id) { | ||
return new Promise(() => this._cache.get(id) || null); | ||
} | ||
return new Promise(() => this._cache); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (id) { | ||
return this._cache.get(id) || null; | ||
} | ||
return this._cache; | ||
}); | ||
} | ||
@@ -47,2 +58,3 @@ /** | ||
* @param {string?} options.reason The reason for the role. | ||
* @returns {MockRole} The created role. | ||
* @public | ||
@@ -53,2 +65,3 @@ */ | ||
this._cache.set(role.id, role); | ||
return role; | ||
} | ||
@@ -55,0 +68,0 @@ /** |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -98,3 +107,5 @@ exports.MockUser = void 0; | ||
fetch() { | ||
return new Promise(() => this); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this; | ||
}); | ||
} | ||
@@ -120,6 +131,8 @@ /** | ||
send(options) { | ||
this._dms.push(options); | ||
return new Promise(() => new MockMessage_1.MockMessage(options)); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._dms.push(options); | ||
return new MockMessage_1.MockMessage(options); | ||
}); | ||
} | ||
} | ||
exports.MockUser = MockUser; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -36,6 +45,8 @@ exports.MockUserManager = void 0; | ||
fetch(id) { | ||
if (id) { | ||
return new Promise(() => this._cache.get(id) || null); | ||
} | ||
return new Promise(() => this._cache); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (id) { | ||
return this._cache.get(id) || null; | ||
} | ||
return this._cache; | ||
}); | ||
} | ||
@@ -51,5 +62,7 @@ /** | ||
add(options) { | ||
const user = new MockUser_1.MockUser(options); | ||
this._cache.set(user.id, user); | ||
return new Promise(() => user); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const user = new MockUser_1.MockUser(options); | ||
this._cache.set(user.id, user); | ||
return user; | ||
}); | ||
} | ||
@@ -56,0 +69,0 @@ /** |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -36,4 +45,6 @@ exports.MockWebhook = void 0; | ||
send(options) { | ||
const message = this._channel.send(options, this._user); | ||
return message; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const message = this._channel.send(options, this._user); | ||
return message; | ||
}); | ||
} | ||
@@ -40,0 +51,0 @@ /** |
@@ -15,3 +15,3 @@ "use strict"; | ||
constructor() { | ||
this._id = new snowflake_1.Snowflake(Date.now()).generate().toString(10); | ||
this._id = snowflake_1.DiscordSnowflake.generate().toString(10); | ||
} | ||
@@ -18,0 +18,0 @@ /** |
124436
3451