@spatulox/simplediscordbot 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +53 -47
- package/dist/index.mjs +21 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -341,6 +341,7 @@ declare abstract class BasicUserManager {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
declare class GuildUserManager extends BasicUserManager {
|
|
344
|
+
static find(userId: string, guild: Guild | string): Promise<GuildMember | null>;
|
|
344
345
|
static rename(member: GuildMember, nickname: string, maxAttempts?: number): Promise<boolean>;
|
|
345
346
|
/**
|
|
346
347
|
* Check if user is banned from guild
|
|
@@ -528,7 +529,7 @@ declare class GuildManager {
|
|
|
528
529
|
static readonly channel: typeof GuildChannelList;
|
|
529
530
|
static readonly invite: typeof InviteManager;
|
|
530
531
|
static list(): Guild[];
|
|
531
|
-
static find(guild_id: string): Promise<Guild
|
|
532
|
+
static find(guild_id: string): Promise<Guild>;
|
|
532
533
|
/**
|
|
533
534
|
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
534
535
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -341,6 +341,7 @@ declare abstract class BasicUserManager {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
declare class GuildUserManager extends BasicUserManager {
|
|
344
|
+
static find(userId: string, guild: Guild | string): Promise<GuildMember | null>;
|
|
344
345
|
static rename(member: GuildMember, nickname: string, maxAttempts?: number): Promise<boolean>;
|
|
345
346
|
/**
|
|
346
347
|
* Check if user is banned from guild
|
|
@@ -528,7 +529,7 @@ declare class GuildManager {
|
|
|
528
529
|
static readonly channel: typeof GuildChannelList;
|
|
529
530
|
static readonly invite: typeof InviteManager;
|
|
530
531
|
static list(): Guild[];
|
|
531
|
-
static find(guild_id: string): Promise<Guild
|
|
532
|
+
static find(guild_id: string): Promise<Guild>;
|
|
532
533
|
/**
|
|
533
534
|
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
534
535
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1559,7 +1559,7 @@ var ReactionManager = class {
|
|
|
1559
1559
|
};
|
|
1560
1560
|
|
|
1561
1561
|
// src/manager/guild/GuildManager.ts
|
|
1562
|
-
var
|
|
1562
|
+
var import_discord14 = require("discord.js");
|
|
1563
1563
|
|
|
1564
1564
|
// src/manager/direct/BasicUserManager.ts
|
|
1565
1565
|
var import_discord8 = require("discord.js");
|
|
@@ -1634,9 +1634,22 @@ var BasicUserManager = class {
|
|
|
1634
1634
|
};
|
|
1635
1635
|
|
|
1636
1636
|
// src/manager/guild/GuildUserManager.ts
|
|
1637
|
+
var import_discord9 = require("discord.js");
|
|
1637
1638
|
var import_promises2 = require("timers/promises");
|
|
1638
1639
|
var MAX_NICKNAME_LENGTH = 32;
|
|
1639
1640
|
var GuildUserManager = class extends BasicUserManager {
|
|
1641
|
+
static async find(userId, guild) {
|
|
1642
|
+
try {
|
|
1643
|
+
if (guild instanceof import_discord9.Guild) {
|
|
1644
|
+
return await guild.members.fetch(userId);
|
|
1645
|
+
} else {
|
|
1646
|
+
return await (await GuildManager.find(guild)).members.fetch(userId);
|
|
1647
|
+
}
|
|
1648
|
+
} catch (error) {
|
|
1649
|
+
Log.error(`UserManager: Member ${userId} not found`);
|
|
1650
|
+
return null;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1640
1653
|
static async rename(member, nickname, maxAttempts = 3) {
|
|
1641
1654
|
if (nickname.length > MAX_NICKNAME_LENGTH) {
|
|
1642
1655
|
nickname = nickname.slice(0, MAX_NICKNAME_LENGTH);
|
|
@@ -1925,15 +1938,15 @@ var RoleManager = class {
|
|
|
1925
1938
|
};
|
|
1926
1939
|
|
|
1927
1940
|
// src/manager/guild/ChannelManager/ForumChannelManager.ts
|
|
1928
|
-
var
|
|
1941
|
+
var import_discord10 = require("discord.js");
|
|
1929
1942
|
var ForumChannelManager = class extends GuildChannelManager {
|
|
1930
1943
|
static async findInGuild(guildId, channelId) {
|
|
1931
1944
|
const channel = await super.findInGuild(guildId, channelId);
|
|
1932
|
-
return channel instanceof
|
|
1945
|
+
return channel instanceof import_discord10.ForumChannel ? channel : null;
|
|
1933
1946
|
}
|
|
1934
1947
|
static async find(channelId) {
|
|
1935
1948
|
const channel = await super.find(channelId);
|
|
1936
|
-
return channel instanceof
|
|
1949
|
+
return channel instanceof import_discord10.ForumChannel ? channel : null;
|
|
1937
1950
|
}
|
|
1938
1951
|
static findAll(guildId) {
|
|
1939
1952
|
const guild = Bot.client.guilds.cache.get(guildId);
|
|
@@ -1941,27 +1954,27 @@ var ForumChannelManager = class extends GuildChannelManager {
|
|
|
1941
1954
|
Log.warn(`Guild ${guildId} not found`);
|
|
1942
1955
|
return [];
|
|
1943
1956
|
}
|
|
1944
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
1957
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord10.ForumChannel);
|
|
1945
1958
|
}
|
|
1946
1959
|
static async create(guildId, name, options) {
|
|
1947
1960
|
return await super._create(guildId, {
|
|
1948
1961
|
name,
|
|
1949
|
-
type:
|
|
1962
|
+
type: import_discord10.ChannelType.GuildForum,
|
|
1950
1963
|
...options
|
|
1951
1964
|
});
|
|
1952
1965
|
}
|
|
1953
1966
|
};
|
|
1954
1967
|
|
|
1955
1968
|
// src/manager/guild/ChannelManager/NewsChannelManager.ts
|
|
1956
|
-
var
|
|
1969
|
+
var import_discord11 = require("discord.js");
|
|
1957
1970
|
var NewsChannelManager = class extends GuildChannelManager {
|
|
1958
1971
|
static async findInGuild(guildId, channelId) {
|
|
1959
1972
|
const channel = await super.findInGuild(guildId, channelId);
|
|
1960
|
-
return channel instanceof
|
|
1973
|
+
return channel instanceof import_discord11.NewsChannel ? channel : null;
|
|
1961
1974
|
}
|
|
1962
1975
|
static async find(channelId) {
|
|
1963
1976
|
const channel = await super.find(channelId);
|
|
1964
|
-
return channel instanceof
|
|
1977
|
+
return channel instanceof import_discord11.NewsChannel ? channel : null;
|
|
1965
1978
|
}
|
|
1966
1979
|
static findAll(guildId) {
|
|
1967
1980
|
const guild = Bot.client.guilds.cache.get(guildId);
|
|
@@ -1969,27 +1982,27 @@ var NewsChannelManager = class extends GuildChannelManager {
|
|
|
1969
1982
|
Log.warn(`Guild ${guildId} not found`);
|
|
1970
1983
|
return [];
|
|
1971
1984
|
}
|
|
1972
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
1985
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord11.NewsChannel);
|
|
1973
1986
|
}
|
|
1974
1987
|
static async create(guildId, name, options) {
|
|
1975
1988
|
return await super._create(guildId, {
|
|
1976
1989
|
name,
|
|
1977
|
-
type:
|
|
1990
|
+
type: import_discord11.ChannelType.GuildAnnouncement,
|
|
1978
1991
|
...options
|
|
1979
1992
|
});
|
|
1980
1993
|
}
|
|
1981
1994
|
};
|
|
1982
1995
|
|
|
1983
1996
|
// src/manager/guild/ChannelManager/StageChannelManager.ts
|
|
1984
|
-
var
|
|
1997
|
+
var import_discord12 = require("discord.js");
|
|
1985
1998
|
var StageChannelManager = class extends GuildChannelManager {
|
|
1986
1999
|
static async findInGuild(guildId, channelId) {
|
|
1987
2000
|
const channel = await super.findInGuild(guildId, channelId);
|
|
1988
|
-
return channel instanceof
|
|
2001
|
+
return channel instanceof import_discord12.StageChannel ? channel : null;
|
|
1989
2002
|
}
|
|
1990
2003
|
static async find(channelId) {
|
|
1991
2004
|
const channel = await super.find(channelId);
|
|
1992
|
-
return channel instanceof
|
|
2005
|
+
return channel instanceof import_discord12.StageChannel ? channel : null;
|
|
1993
2006
|
}
|
|
1994
2007
|
static findAll(guildId) {
|
|
1995
2008
|
const guild = Bot.client.guilds.cache.get(guildId);
|
|
@@ -1997,12 +2010,12 @@ var StageChannelManager = class extends GuildChannelManager {
|
|
|
1997
2010
|
Log.warn(`Guild ${guildId} not found`);
|
|
1998
2011
|
return [];
|
|
1999
2012
|
}
|
|
2000
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
2013
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord12.StageChannel);
|
|
2001
2014
|
}
|
|
2002
2015
|
static async create(guildId, name, options) {
|
|
2003
2016
|
return await super._create(guildId, {
|
|
2004
2017
|
name,
|
|
2005
|
-
type:
|
|
2018
|
+
type: import_discord12.ChannelType.GuildStageVoice,
|
|
2006
2019
|
...options
|
|
2007
2020
|
});
|
|
2008
2021
|
}
|
|
@@ -2050,7 +2063,7 @@ var ThreadChannelManager = class {
|
|
|
2050
2063
|
};
|
|
2051
2064
|
|
|
2052
2065
|
// src/manager/guild/ChannelManager/GuildVoiceChannelManager.ts
|
|
2053
|
-
var
|
|
2066
|
+
var import_discord13 = require("discord.js");
|
|
2054
2067
|
var GuildVoiceChannelManager = class extends GuildChannelManager {
|
|
2055
2068
|
static async findInGuild(guildId, channelId) {
|
|
2056
2069
|
const channel = await super.findInGuild(guildId, channelId);
|
|
@@ -2066,12 +2079,12 @@ var GuildVoiceChannelManager = class extends GuildChannelManager {
|
|
|
2066
2079
|
Log.warn(`Guild ${guildId} not found`);
|
|
2067
2080
|
return [];
|
|
2068
2081
|
}
|
|
2069
|
-
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof
|
|
2082
|
+
return Array.from(guild.channels.cache.values()).filter((c) => c instanceof import_discord13.VoiceChannel);
|
|
2070
2083
|
}
|
|
2071
2084
|
static async create(guildId, name, options) {
|
|
2072
2085
|
return await super._create(guildId, {
|
|
2073
2086
|
name,
|
|
2074
|
-
type:
|
|
2087
|
+
type: import_discord13.ChannelType.GuildVoice,
|
|
2075
2088
|
...options
|
|
2076
2089
|
});
|
|
2077
2090
|
}
|
|
@@ -2153,14 +2166,7 @@ var GuildManager = class {
|
|
|
2153
2166
|
return Array.from(Bot.client.guilds.cache.values());
|
|
2154
2167
|
}
|
|
2155
2168
|
static async find(guild_id) {
|
|
2156
|
-
|
|
2157
|
-
const cached = Bot.client.guilds.cache.get(guild_id);
|
|
2158
|
-
if (cached) return cached;
|
|
2159
|
-
return await Bot.client.guilds.fetch(guild_id);
|
|
2160
|
-
} catch (error) {
|
|
2161
|
-
Log.error(`GuildManager: Guild ${guild_id} : ${error} `);
|
|
2162
|
-
return null;
|
|
2163
|
-
}
|
|
2169
|
+
return await Bot.client.guilds.fetch(guild_id);
|
|
2164
2170
|
}
|
|
2165
2171
|
/**
|
|
2166
2172
|
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
@@ -2199,7 +2205,7 @@ var GuildManager = class {
|
|
|
2199
2205
|
*/
|
|
2200
2206
|
static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = Time.minute.MIN_05.toMilliseconds()) {
|
|
2201
2207
|
let guild;
|
|
2202
|
-
if (guildId instanceof
|
|
2208
|
+
if (guildId instanceof import_discord14.Guild) {
|
|
2203
2209
|
guild = guildId;
|
|
2204
2210
|
} else {
|
|
2205
2211
|
let tmp = Bot.client.guilds.cache.get(guildId);
|
|
@@ -2252,10 +2258,10 @@ var GuildManager = class {
|
|
|
2252
2258
|
if (!toChannel) {
|
|
2253
2259
|
throw new Error(`To channel ${toChannelId} not found`);
|
|
2254
2260
|
}
|
|
2255
|
-
if (!(fromChannel instanceof
|
|
2261
|
+
if (!(fromChannel instanceof import_discord14.VoiceChannel || fromChannel instanceof import_discord14.StageChannel)) {
|
|
2256
2262
|
throw new Error(`From channel ${fromChannelId} is not a voice/stage channel`);
|
|
2257
2263
|
}
|
|
2258
|
-
if (!(toChannel instanceof
|
|
2264
|
+
if (!(toChannel instanceof import_discord14.VoiceChannel || toChannel instanceof import_discord14.StageChannel)) {
|
|
2259
2265
|
throw new Error(`To channel ${toChannelId} is not a voice/stage channel`);
|
|
2260
2266
|
}
|
|
2261
2267
|
if (member.voice.channelId !== fromChannelId) {
|
|
@@ -2292,7 +2298,7 @@ var UserManager = class extends BasicUserManager {
|
|
|
2292
2298
|
};
|
|
2293
2299
|
|
|
2294
2300
|
// src/manager/interactions/ModalManager.ts
|
|
2295
|
-
var
|
|
2301
|
+
var import_discord15 = require("discord.js");
|
|
2296
2302
|
var ModalManager = class _ModalManager {
|
|
2297
2303
|
/**
|
|
2298
2304
|
* Load modal from JSON file and return ModalBuilder
|
|
@@ -2318,17 +2324,17 @@ var ModalManager = class _ModalManager {
|
|
|
2318
2324
|
}
|
|
2319
2325
|
}
|
|
2320
2326
|
static jsonToBuilder(json) {
|
|
2321
|
-
const modal = new
|
|
2327
|
+
const modal = new import_discord15.ModalBuilder().setCustomId(json.customId).setTitle(json.title.slice(0, 45));
|
|
2322
2328
|
const actionRows = [];
|
|
2323
2329
|
for (const fieldJson of json.fields) {
|
|
2324
2330
|
const input = this.fieldJsonToInput(fieldJson);
|
|
2325
|
-
const row = new
|
|
2331
|
+
const row = new import_discord15.ActionRowBuilder().addComponents(input);
|
|
2326
2332
|
actionRows.push(row);
|
|
2327
2333
|
}
|
|
2328
2334
|
return modal.addComponents(...actionRows);
|
|
2329
2335
|
}
|
|
2330
2336
|
static fieldJsonToInput(fieldJson) {
|
|
2331
|
-
const input = new
|
|
2337
|
+
const input = new import_discord15.TextInputBuilder().setCustomId(fieldJson.customId).setLabel(fieldJson.title.slice(0, 45)).setPlaceholder(fieldJson.placeholder || "Enter value...").setRequired(fieldJson.required !== false).setMinLength(fieldJson.minLength || 0).setMaxLength(fieldJson.maxLength || 400);
|
|
2332
2338
|
const style = fieldJson.style;
|
|
2333
2339
|
if (typeof style === "number") {
|
|
2334
2340
|
input.setStyle(style);
|
|
@@ -2337,13 +2343,13 @@ var ModalManager = class _ModalManager {
|
|
|
2337
2343
|
case "Number":
|
|
2338
2344
|
case "Phone":
|
|
2339
2345
|
case "Date":
|
|
2340
|
-
input.setStyle(
|
|
2346
|
+
input.setStyle(import_discord15.TextInputStyle.Short);
|
|
2341
2347
|
input.setPlaceholder(
|
|
2342
2348
|
style === "Number" ? "123" : style === "Phone" ? "+33 6 12 34 56 78" : "2024-02-05"
|
|
2343
2349
|
);
|
|
2344
2350
|
break;
|
|
2345
2351
|
default:
|
|
2346
|
-
input.setStyle(
|
|
2352
|
+
input.setStyle(import_discord15.TextInputStyle.Short);
|
|
2347
2353
|
}
|
|
2348
2354
|
}
|
|
2349
2355
|
return input;
|
|
@@ -2379,13 +2385,13 @@ var ModalManager = class _ModalManager {
|
|
|
2379
2385
|
};
|
|
2380
2386
|
|
|
2381
2387
|
// src/manager/interactions/SelectMenuManager.ts
|
|
2382
|
-
var
|
|
2388
|
+
var import_discord16 = require("discord.js");
|
|
2383
2389
|
var SelectMenuManager = class {
|
|
2384
2390
|
/**
|
|
2385
2391
|
* Creates base StringSelectMenu - SIMPLE API !
|
|
2386
2392
|
*/
|
|
2387
2393
|
static create(customId, placeholder = "Select an option...") {
|
|
2388
|
-
return new
|
|
2394
|
+
return new import_discord16.StringSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(1);
|
|
2389
2395
|
}
|
|
2390
2396
|
/**
|
|
2391
2397
|
* Quick StringSelectMenu
|
|
@@ -2403,10 +2409,10 @@ var SelectMenuManager = class {
|
|
|
2403
2409
|
* Pagination menu
|
|
2404
2410
|
*/
|
|
2405
2411
|
static paginated(customId, options, pageSize = 25) {
|
|
2406
|
-
const row = new
|
|
2412
|
+
const row = new import_discord16.ActionRowBuilder();
|
|
2407
2413
|
for (let i = 0; i < options.length; i += pageSize) {
|
|
2408
2414
|
const pageOptions = options.slice(i, i + pageSize);
|
|
2409
|
-
const menu = new
|
|
2415
|
+
const menu = new import_discord16.StringSelectMenuBuilder().setCustomId(`${customId}_page_${Math.floor(i / pageSize)}`).setPlaceholder(`Page ${Math.floor(i / pageSize) + 1}`).addOptions(pageOptions.map((opt) => {
|
|
2410
2416
|
return this.option(opt);
|
|
2411
2417
|
}));
|
|
2412
2418
|
row.addComponents(menu);
|
|
@@ -2417,25 +2423,25 @@ var SelectMenuManager = class {
|
|
|
2417
2423
|
* User Select Menu (Components V2)
|
|
2418
2424
|
*/
|
|
2419
2425
|
static users(customId, placeholder = "Select users...") {
|
|
2420
|
-
return new
|
|
2426
|
+
return new import_discord16.UserSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25);
|
|
2421
2427
|
}
|
|
2422
2428
|
/**
|
|
2423
2429
|
* Role Select Menu (Components V2)
|
|
2424
2430
|
*/
|
|
2425
2431
|
static roles(customId, placeholder = "Select roles...") {
|
|
2426
|
-
return new
|
|
2432
|
+
return new import_discord16.RoleSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25);
|
|
2427
2433
|
}
|
|
2428
2434
|
/**
|
|
2429
2435
|
* Mentionable Select Menu (Components V2)
|
|
2430
2436
|
*/
|
|
2431
2437
|
static mentionables(customId, placeholder = "Select users/roles...") {
|
|
2432
|
-
return new
|
|
2438
|
+
return new import_discord16.MentionableSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25);
|
|
2433
2439
|
}
|
|
2434
2440
|
/**
|
|
2435
2441
|
* Channel Select Menu (Components V2)
|
|
2436
2442
|
*/
|
|
2437
2443
|
static channels(customId, placeholder = "Select channels...", channelTypes = []) {
|
|
2438
|
-
return new
|
|
2444
|
+
return new import_discord16.ChannelSelectMenuBuilder().setCustomId(customId).setPlaceholder(placeholder).setMinValues(1).setMaxValues(25).setChannelTypes(...channelTypes);
|
|
2439
2445
|
}
|
|
2440
2446
|
static option(option) {
|
|
2441
2447
|
if (Array.isArray(option)) {
|
|
@@ -2444,7 +2450,7 @@ var SelectMenuManager = class {
|
|
|
2444
2450
|
return this._createOption(option);
|
|
2445
2451
|
}
|
|
2446
2452
|
static _createOption(option) {
|
|
2447
|
-
const builder = new
|
|
2453
|
+
const builder = new import_discord16.StringSelectMenuOptionBuilder().setLabel(option.label).setValue(option.value);
|
|
2448
2454
|
option.description && builder.setDescription(option.description);
|
|
2449
2455
|
option.emoji && builder.setEmoji(option.emoji);
|
|
2450
2456
|
return builder;
|
|
@@ -2465,7 +2471,7 @@ var SelectMenuManager = class {
|
|
|
2465
2471
|
* ActionRow
|
|
2466
2472
|
*/
|
|
2467
2473
|
static row(component) {
|
|
2468
|
-
return new
|
|
2474
|
+
return new import_discord16.ActionRowBuilder().addComponents(component);
|
|
2469
2475
|
}
|
|
2470
2476
|
/**
|
|
2471
2477
|
* Rows multiples (5 max)
|
|
@@ -2518,7 +2524,7 @@ var SimpleMutex = class {
|
|
|
2518
2524
|
// package.json
|
|
2519
2525
|
var package_default = {
|
|
2520
2526
|
name: "@spatulox/simplediscordbot",
|
|
2521
|
-
version: "1.0
|
|
2527
|
+
version: "1.1.0",
|
|
2522
2528
|
author: "Spatulox",
|
|
2523
2529
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2524
2530
|
exports: {
|
package/dist/index.mjs
CHANGED
|
@@ -1520,7 +1520,11 @@ var ReactionManager = class {
|
|
|
1520
1520
|
};
|
|
1521
1521
|
|
|
1522
1522
|
// src/manager/guild/GuildManager.ts
|
|
1523
|
-
import {
|
|
1523
|
+
import {
|
|
1524
|
+
Guild as Guild3,
|
|
1525
|
+
VoiceChannel as VoiceChannel2,
|
|
1526
|
+
StageChannel as StageChannel2
|
|
1527
|
+
} from "discord.js";
|
|
1524
1528
|
|
|
1525
1529
|
// src/manager/direct/BasicUserManager.ts
|
|
1526
1530
|
import { GuildMember as GuildMember2 } from "discord.js";
|
|
@@ -1595,9 +1599,22 @@ var BasicUserManager = class {
|
|
|
1595
1599
|
};
|
|
1596
1600
|
|
|
1597
1601
|
// src/manager/guild/GuildUserManager.ts
|
|
1602
|
+
import { Guild as Guild2 } from "discord.js";
|
|
1598
1603
|
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
1599
1604
|
var MAX_NICKNAME_LENGTH = 32;
|
|
1600
1605
|
var GuildUserManager = class extends BasicUserManager {
|
|
1606
|
+
static async find(userId, guild) {
|
|
1607
|
+
try {
|
|
1608
|
+
if (guild instanceof Guild2) {
|
|
1609
|
+
return await guild.members.fetch(userId);
|
|
1610
|
+
} else {
|
|
1611
|
+
return await (await GuildManager.find(guild)).members.fetch(userId);
|
|
1612
|
+
}
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
Log.error(`UserManager: Member ${userId} not found`);
|
|
1615
|
+
return null;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1601
1618
|
static async rename(member, nickname, maxAttempts = 3) {
|
|
1602
1619
|
if (nickname.length > MAX_NICKNAME_LENGTH) {
|
|
1603
1620
|
nickname = nickname.slice(0, MAX_NICKNAME_LENGTH);
|
|
@@ -2114,14 +2131,7 @@ var GuildManager = class {
|
|
|
2114
2131
|
return Array.from(Bot.client.guilds.cache.values());
|
|
2115
2132
|
}
|
|
2116
2133
|
static async find(guild_id) {
|
|
2117
|
-
|
|
2118
|
-
const cached = Bot.client.guilds.cache.get(guild_id);
|
|
2119
|
-
if (cached) return cached;
|
|
2120
|
-
return await Bot.client.guilds.fetch(guild_id);
|
|
2121
|
-
} catch (error) {
|
|
2122
|
-
Log.error(`GuildManager: Guild ${guild_id} : ${error} `);
|
|
2123
|
-
return null;
|
|
2124
|
-
}
|
|
2134
|
+
return await Bot.client.guilds.fetch(guild_id);
|
|
2125
2135
|
}
|
|
2126
2136
|
/**
|
|
2127
2137
|
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
@@ -2160,7 +2170,7 @@ var GuildManager = class {
|
|
|
2160
2170
|
*/
|
|
2161
2171
|
static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = Time.minute.MIN_05.toMilliseconds()) {
|
|
2162
2172
|
let guild;
|
|
2163
|
-
if (guildId instanceof
|
|
2173
|
+
if (guildId instanceof Guild3) {
|
|
2164
2174
|
guild = guildId;
|
|
2165
2175
|
} else {
|
|
2166
2176
|
let tmp = Bot.client.guilds.cache.get(guildId);
|
|
@@ -2492,7 +2502,7 @@ var SimpleMutex = class {
|
|
|
2492
2502
|
// package.json
|
|
2493
2503
|
var package_default = {
|
|
2494
2504
|
name: "@spatulox/simplediscordbot",
|
|
2495
|
-
version: "1.0
|
|
2505
|
+
version: "1.1.0",
|
|
2496
2506
|
author: "Spatulox",
|
|
2497
2507
|
description: "Simple discord bot framework to set up a bot under 30 secondes",
|
|
2498
2508
|
exports: {
|