@spatulox/simplediscordbot 1.0.30 → 1.0.32
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/.npmignore_old +23 -0
- package/dist/index.d.mts +915 -0
- package/dist/index.d.ts +915 -17
- package/dist/index.js +2576 -36
- package/dist/index.mjs +2554 -0
- package/package.json +3 -2
- package/dist/SimpleDiscordBotInfo.d.ts +0 -8
- package/dist/SimpleDiscordBotInfo.js +0 -14
- package/dist/bot/Bot.d.ts +0 -35
- package/dist/bot/Bot.js +0 -92
- package/dist/bot/BotEnv.d.ts +0 -6
- package/dist/bot/BotEnv.js +0 -24
- package/dist/bot/BotInteraction.d.ts +0 -21
- package/dist/bot/BotInteraction.js +0 -74
- package/dist/bot/BotLog.d.ts +0 -52
- package/dist/bot/BotLog.js +0 -134
- package/dist/bot/BotMessage.d.ts +0 -20
- package/dist/bot/BotMessage.js +0 -110
- package/dist/manager/FileManager.d.ts +0 -37
- package/dist/manager/FileManager.js +0 -136
- package/dist/manager/builder/SendableComponentBuilder.d.ts +0 -3
- package/dist/manager/builder/SendableComponentBuilder.js +0 -63
- package/dist/manager/direct/BasicUserManager.d.ts +0 -28
- package/dist/manager/direct/BasicUserManager.js +0 -81
- package/dist/manager/direct/UserManager.d.ts +0 -6
- package/dist/manager/direct/UserManager.js +0 -18
- package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts +0 -9
- package/dist/manager/guild/ChannelManager/ForumChannelManager.js +0 -33
- package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts +0 -17
- package/dist/manager/guild/ChannelManager/GuildChannelList.js +0 -20
- package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts +0 -18
- package/dist/manager/guild/ChannelManager/GuildChannelManager.js +0 -91
- package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts +0 -23
- package/dist/manager/guild/ChannelManager/GuildMessageManager.js +0 -93
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts +0 -9
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.js +0 -33
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts +0 -9
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.js +0 -33
- package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts +0 -9
- package/dist/manager/guild/ChannelManager/NewsChannelManager.js +0 -33
- package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts +0 -9
- package/dist/manager/guild/ChannelManager/StageChannelManager.js +0 -33
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts +0 -13
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.js +0 -49
- package/dist/manager/guild/GuildManager.d.ts +0 -32
- package/dist/manager/guild/GuildManager.js +0 -144
- package/dist/manager/guild/GuildUserManager.d.ts +0 -49
- package/dist/manager/guild/GuildUserManager.js +0 -251
- package/dist/manager/guild/InviteManager.d.ts +0 -21
- package/dist/manager/guild/InviteManager.js +0 -68
- package/dist/manager/guild/InviteManager_old.d.ts +0 -24
- package/dist/manager/guild/InviteManager_old.js +0 -89
- package/dist/manager/guild/RoleManager.d.ts +0 -24
- package/dist/manager/guild/RoleManager.js +0 -83
- package/dist/manager/interactions/ModalManager.d.ts +0 -23
- package/dist/manager/interactions/ModalManager.js +0 -113
- package/dist/manager/interactions/SelectMenuManager.d.ts +0 -58
- package/dist/manager/interactions/SelectMenuManager.js +0 -123
- package/dist/manager/messages/EmbedManager.d.ts +0 -97
- package/dist/manager/messages/EmbedManager.js +0 -161
- package/dist/manager/messages/ReactionManager.d.ts +0 -26
- package/dist/manager/messages/ReactionManager.js +0 -99
- package/dist/manager/messages/WebhookManager.d.ts +0 -33
- package/dist/manager/messages/WebhookManager.js +0 -108
- package/dist/test/client.d.ts +0 -3
- package/dist/test/client.js +0 -15
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.js +0 -31
- package/dist/test/randomActivityList.d.ts +0 -3
- package/dist/test/randomActivityList.js +0 -9
- package/dist/type/FolderName.d.ts +0 -2
- package/dist/type/FolderName.js +0 -10
- package/dist/utils/DiscordRegex.d.ts +0 -66
- package/dist/utils/DiscordRegex.js +0 -117
- package/dist/utils/Log.d.ts +0 -9
- package/dist/utils/Log.js +0 -28
- package/dist/utils/SimpleMutex.d.ts +0 -16
- package/dist/utils/SimpleMutex.js +0 -39
- package/dist/utils/network/InternetChecker.d.ts +0 -10
- package/dist/utils/network/InternetChecker.js +0 -54
- package/dist/utils/times/UnitTime.d.ts +0 -187
- package/dist/utils/times/UnitTime.js +0 -85
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildTextChannelManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
6
|
-
const Bot_1 = require("../../../bot/Bot");
|
|
7
|
-
const Log_1 = require("../../../utils/Log");
|
|
8
|
-
class GuildTextChannelManager extends GuildChannelManager_1.GuildChannelManager {
|
|
9
|
-
static async findInGuild(guildId, channelId) {
|
|
10
|
-
const channel = await super.findInGuild(guildId, channelId);
|
|
11
|
-
return channel?.isTextBased() ? channel : null;
|
|
12
|
-
}
|
|
13
|
-
static async find(channelId) {
|
|
14
|
-
const channel = await super.find(channelId);
|
|
15
|
-
return channel?.isTextBased() ? channel : null;
|
|
16
|
-
}
|
|
17
|
-
static findAll(guildId) {
|
|
18
|
-
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
19
|
-
if (!guild) {
|
|
20
|
-
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
return Array.from(guild.channels.cache.values()).filter(c => c instanceof discord_js_1.TextChannel);
|
|
24
|
-
}
|
|
25
|
-
static async create(guildId, name, options) {
|
|
26
|
-
return await super._create(guildId, {
|
|
27
|
-
name,
|
|
28
|
-
type: discord_js_1.ChannelType.GuildText,
|
|
29
|
-
...options
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.GuildTextChannelManager = GuildTextChannelManager;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GuildChannelCreateOptions, VoiceChannel } from "discord.js";
|
|
2
|
-
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
-
export declare class GuildVoiceChannelManager extends GuildChannelManager {
|
|
4
|
-
static findInGuild(guildId: string, channelId: string): Promise<VoiceChannel | null>;
|
|
5
|
-
static find(channelId: string): Promise<VoiceChannel | null>;
|
|
6
|
-
static findAll(guildId: string): VoiceChannel[];
|
|
7
|
-
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<VoiceChannel>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=GuildVoiceChannelManager.d.ts.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildVoiceChannelManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
6
|
-
const Bot_1 = require("../../../bot/Bot");
|
|
7
|
-
const Log_1 = require("../../../utils/Log");
|
|
8
|
-
class GuildVoiceChannelManager extends GuildChannelManager_1.GuildChannelManager {
|
|
9
|
-
static async findInGuild(guildId, channelId) {
|
|
10
|
-
const channel = await super.findInGuild(guildId, channelId);
|
|
11
|
-
return channel?.isVoiceBased() ? channel : null;
|
|
12
|
-
}
|
|
13
|
-
static async find(channelId) {
|
|
14
|
-
const channel = await super.find(channelId);
|
|
15
|
-
return channel?.isVoiceBased() ? channel : null;
|
|
16
|
-
}
|
|
17
|
-
static findAll(guildId) {
|
|
18
|
-
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
19
|
-
if (!guild) {
|
|
20
|
-
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
return Array.from(guild.channels.cache.values()).filter(c => c instanceof discord_js_1.VoiceChannel);
|
|
24
|
-
}
|
|
25
|
-
static async create(guildId, name, options) {
|
|
26
|
-
return await super._create(guildId, {
|
|
27
|
-
name,
|
|
28
|
-
type: discord_js_1.ChannelType.GuildVoice,
|
|
29
|
-
...options
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.GuildVoiceChannelManager = GuildVoiceChannelManager;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GuildChannelCreateOptions, NewsChannel } from "discord.js";
|
|
2
|
-
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
-
export declare class NewsChannelManager extends GuildChannelManager {
|
|
4
|
-
static findInGuild(guildId: string, channelId: string): Promise<NewsChannel | null>;
|
|
5
|
-
static find(channelId: string): Promise<NewsChannel | null>;
|
|
6
|
-
static findAll(guildId: string): NewsChannel[];
|
|
7
|
-
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<NewsChannel>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=NewsChannelManager.d.ts.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NewsChannelManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
6
|
-
const Bot_1 = require("../../../bot/Bot");
|
|
7
|
-
const Log_1 = require("../../../utils/Log");
|
|
8
|
-
class NewsChannelManager extends GuildChannelManager_1.GuildChannelManager {
|
|
9
|
-
static async findInGuild(guildId, channelId) {
|
|
10
|
-
const channel = await super.findInGuild(guildId, channelId);
|
|
11
|
-
return channel instanceof discord_js_1.NewsChannel ? channel : null;
|
|
12
|
-
}
|
|
13
|
-
static async find(channelId) {
|
|
14
|
-
const channel = await super.find(channelId);
|
|
15
|
-
return channel instanceof discord_js_1.NewsChannel ? channel : null;
|
|
16
|
-
}
|
|
17
|
-
static findAll(guildId) {
|
|
18
|
-
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
19
|
-
if (!guild) {
|
|
20
|
-
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
return Array.from(guild.channels.cache.values()).filter(c => c instanceof discord_js_1.NewsChannel);
|
|
24
|
-
}
|
|
25
|
-
static async create(guildId, name, options) {
|
|
26
|
-
return await super._create(guildId, {
|
|
27
|
-
name,
|
|
28
|
-
type: discord_js_1.ChannelType.GuildAnnouncement,
|
|
29
|
-
...options
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.NewsChannelManager = NewsChannelManager;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GuildChannelCreateOptions, StageChannel } from "discord.js";
|
|
2
|
-
import { GuildChannelManager } from "./GuildChannelManager";
|
|
3
|
-
export declare class StageChannelManager extends GuildChannelManager {
|
|
4
|
-
static findInGuild(guildId: string, channelId: string): Promise<StageChannel | null>;
|
|
5
|
-
static find(channelId: string): Promise<StageChannel | null>;
|
|
6
|
-
static findAll(guildId: string): StageChannel[];
|
|
7
|
-
static create(guildId: string, name: string, options?: Omit<GuildChannelCreateOptions, 'type'>): Promise<StageChannel>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=StageChannelManager.d.ts.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StageChannelManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
6
|
-
const Bot_1 = require("../../../bot/Bot");
|
|
7
|
-
const Log_1 = require("../../../utils/Log");
|
|
8
|
-
class StageChannelManager extends GuildChannelManager_1.GuildChannelManager {
|
|
9
|
-
static async findInGuild(guildId, channelId) {
|
|
10
|
-
const channel = await super.findInGuild(guildId, channelId);
|
|
11
|
-
return channel instanceof discord_js_1.StageChannel ? channel : null;
|
|
12
|
-
}
|
|
13
|
-
static async find(channelId) {
|
|
14
|
-
const channel = await super.find(channelId);
|
|
15
|
-
return channel instanceof discord_js_1.StageChannel ? channel : null;
|
|
16
|
-
}
|
|
17
|
-
static findAll(guildId) {
|
|
18
|
-
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
19
|
-
if (!guild) {
|
|
20
|
-
Log_1.Log.warn(`Guild ${guildId} not found`);
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
return Array.from(guild.channels.cache.values()).filter(c => c instanceof discord_js_1.StageChannel);
|
|
24
|
-
}
|
|
25
|
-
static async create(guildId, name, options) {
|
|
26
|
-
return await super._create(guildId, {
|
|
27
|
-
name,
|
|
28
|
-
type: discord_js_1.ChannelType.GuildStageVoice,
|
|
29
|
-
...options
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.StageChannelManager = StageChannelManager;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Message, MessageCreateOptions, StartThreadOptions, ThreadChannel } from "discord.js";
|
|
2
|
-
import { SendableComponent } from "../../builder/SendableComponentBuilder";
|
|
3
|
-
export declare class ThreadChannelManager {
|
|
4
|
-
static findInGuild(guildId: string, channelId: string): Promise<ThreadChannel | null>;
|
|
5
|
-
static find(channelId: string): Promise<ThreadChannel | null>;
|
|
6
|
-
static findAll(guildId: string): ThreadChannel[];
|
|
7
|
-
static createFromChannel(parentId: string, options: StartThreadOptions): Promise<ThreadChannel>;
|
|
8
|
-
static createFromMessage(message: Message, options: StartThreadOptions): Promise<ThreadChannel>;
|
|
9
|
-
static send(channelId: string, content: string): Promise<Message>;
|
|
10
|
-
static send(channelId: string, component: SendableComponent | SendableComponent[]): Promise<Message>;
|
|
11
|
-
static send(channelId: string, options: MessageCreateOptions): Promise<Message>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=ThreadChannelManager.d.ts.map
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThreadChannelManager = void 0;
|
|
4
|
-
const GuildChannelManager_1 = require("./GuildChannelManager");
|
|
5
|
-
const GuildTextChannelManager_1 = require("./GuildTextChannelManager");
|
|
6
|
-
const SendableComponentBuilder_1 = require("../../builder/SendableComponentBuilder");
|
|
7
|
-
class ThreadChannelManager {
|
|
8
|
-
static async findInGuild(guildId, channelId) {
|
|
9
|
-
const channel = await GuildChannelManager_1.GuildChannelManager.findInGuild(guildId, channelId);
|
|
10
|
-
return channel?.isThread() ? channel : null;
|
|
11
|
-
}
|
|
12
|
-
static async find(channelId) {
|
|
13
|
-
const channel = await GuildChannelManager_1.GuildChannelManager.find(channelId);
|
|
14
|
-
return channel?.isThread() ? channel : null;
|
|
15
|
-
}
|
|
16
|
-
static findAll(guildId) {
|
|
17
|
-
const channels = GuildChannelManager_1.GuildChannelManager.findAll(guildId);
|
|
18
|
-
return channels.filter(c => c.isThread());
|
|
19
|
-
}
|
|
20
|
-
static async createFromChannel(parentId, options) {
|
|
21
|
-
const channel = await GuildTextChannelManager_1.GuildTextChannelManager.find(parentId);
|
|
22
|
-
if (!channel || !channel.isTextBased()) {
|
|
23
|
-
throw new Error('Parent must be a text-based channel');
|
|
24
|
-
}
|
|
25
|
-
const thread = await channel.threads.create(options);
|
|
26
|
-
return thread;
|
|
27
|
-
}
|
|
28
|
-
static async createFromMessage(message, options) {
|
|
29
|
-
const channel = await GuildChannelManager_1.GuildChannelManager.find(message.id);
|
|
30
|
-
if (!channel)
|
|
31
|
-
throw new Error('Message channel not found');
|
|
32
|
-
return await message.startThread(options);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Impl
|
|
36
|
-
*/
|
|
37
|
-
static async send(channelId, content_or_component_or_options) {
|
|
38
|
-
if (typeof content_or_component_or_options == 'string') {
|
|
39
|
-
return await GuildTextChannelManager_1.GuildTextChannelManager.message.send(channelId, content_or_component_or_options);
|
|
40
|
-
}
|
|
41
|
-
else if (SendableComponentBuilder_1.SendableComponentBuilder.isSendableComponent(content_or_component_or_options) || Array.isArray(content_or_component_or_options)) {
|
|
42
|
-
return await GuildTextChannelManager_1.GuildTextChannelManager.message.send(channelId, content_or_component_or_options);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
return await GuildTextChannelManager_1.GuildTextChannelManager.message.send(channelId, content_or_component_or_options);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.ThreadChannelManager = ThreadChannelManager;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { GuildMember, Collection, Guild, GuildBan, Channel } from 'discord.js';
|
|
2
|
-
import { GuildUserManager } from "./GuildUserManager";
|
|
3
|
-
import { RoleManager } from "./RoleManager";
|
|
4
|
-
import { GuildChannelList } from "./ChannelManager/GuildChannelList";
|
|
5
|
-
import { InviteManager } from "./InviteManager";
|
|
6
|
-
export declare class GuildManager {
|
|
7
|
-
static readonly role: typeof RoleManager;
|
|
8
|
-
static readonly user: typeof GuildUserManager;
|
|
9
|
-
static readonly channel: typeof GuildChannelList;
|
|
10
|
-
static readonly invite: typeof InviteManager;
|
|
11
|
-
static list(): Guild[];
|
|
12
|
-
static find(guild_id: string): Promise<Guild>;
|
|
13
|
-
/**
|
|
14
|
-
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
15
|
-
*/
|
|
16
|
-
static searchChannel(guildId: string, channelId: string): Promise<Channel | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Search guild member by ID
|
|
19
|
-
*/
|
|
20
|
-
static searchMember(memberId: string, guildId: string): Promise<GuildMember | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Check if member is still in guild
|
|
23
|
-
*/
|
|
24
|
-
static isMemberInGuild(memberId: string, guildId: string): Promise<boolean>;
|
|
25
|
-
/**
|
|
26
|
-
* Fetch all members with retry (heavy operation)
|
|
27
|
-
*/
|
|
28
|
-
static fetchAllMembers(guildId: string | Guild, MAX_ATTEMPTS?: number, RETRY_DELAY?: number): Promise<Collection<string, GuildMember>>;
|
|
29
|
-
static listban(guildId: string, limit?: number): Promise<GuildBan[]>;
|
|
30
|
-
static moveMember(memberId: string, fromChannelId: string, toChannelId: string): Promise<boolean>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=GuildManager.d.ts.map
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const Log_1 = require("../../utils/Log");
|
|
6
|
-
const UnitTime_1 = require("../../utils/times/UnitTime");
|
|
7
|
-
const GuildUserManager_1 = require("./GuildUserManager");
|
|
8
|
-
const Bot_1 = require("../../bot/Bot");
|
|
9
|
-
const GuildChannelManager_1 = require("./ChannelManager/GuildChannelManager");
|
|
10
|
-
const RoleManager_1 = require("./RoleManager");
|
|
11
|
-
const GuildChannelList_1 = require("./ChannelManager/GuildChannelList");
|
|
12
|
-
const InviteManager_1 = require("./InviteManager");
|
|
13
|
-
class GuildManager {
|
|
14
|
-
static list() {
|
|
15
|
-
return Array.from(Bot_1.Bot.client.guilds.cache.values());
|
|
16
|
-
}
|
|
17
|
-
static async find(guild_id) {
|
|
18
|
-
return await Bot_1.Bot.client.guilds.fetch(guild_id);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Search channel by ID (TextChannel, DMChannel, ThreadChannel)
|
|
22
|
-
*/
|
|
23
|
-
static async searchChannel(guildId, channelId) {
|
|
24
|
-
try {
|
|
25
|
-
return await GuildChannelManager_1.GuildChannelManager.findInGuild(guildId, channelId);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
Log_1.Log.error(`Failed to fetch channel ${channelId}: ${error}`);
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Search guild member by ID
|
|
34
|
-
*/
|
|
35
|
-
static async searchMember(memberId, guildId) {
|
|
36
|
-
try {
|
|
37
|
-
return await this.user.findInGuild(guildId, guildId);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
Log_1.Log.error(`Failed to fetch member ${memberId} in guild ${guildId}: ${error}`);
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Check if member is still in guild
|
|
46
|
-
*/
|
|
47
|
-
static async isMemberInGuild(memberId, guildId) {
|
|
48
|
-
try {
|
|
49
|
-
return await this.user.isInGuild(memberId, guildId);
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
return error.code !== 10007; // Unknown Member
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Fetch all members with retry (heavy operation)
|
|
57
|
-
*/
|
|
58
|
-
static async fetchAllMembers(guildId, MAX_ATTEMPTS = 3, RETRY_DELAY = UnitTime_1.Time.minute.MIN_05.toMilliseconds()) {
|
|
59
|
-
let guild;
|
|
60
|
-
if (guildId instanceof discord_js_1.Guild) {
|
|
61
|
-
guild = guildId;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
let tmp = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
65
|
-
if (!tmp)
|
|
66
|
-
throw new Error(`Guild ${guildId} not found`);
|
|
67
|
-
guild = tmp;
|
|
68
|
-
}
|
|
69
|
-
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
70
|
-
try {
|
|
71
|
-
Log_1.Log.info(`UserManager: Fetching ${guild.name} members (attempt ${attempt})`);
|
|
72
|
-
return await guild.members.fetch();
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
Log_1.Log.error(`UserManager: Fetch failed (attempt ${attempt}): ${error}`);
|
|
76
|
-
if (attempt < MAX_ATTEMPTS) {
|
|
77
|
-
await new Promise(r => setTimeout(r, RETRY_DELAY));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
throw new Error(`Failed to fetch members after ${MAX_ATTEMPTS} attempts`);
|
|
82
|
-
}
|
|
83
|
-
static async listban(guildId, limit) {
|
|
84
|
-
const guild = Bot_1.Bot.client.guilds.cache.get(guildId);
|
|
85
|
-
if (!guild) {
|
|
86
|
-
throw new Error(`Guild ${guildId} not found`);
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const bans = await guild.bans.fetch({ limit });
|
|
90
|
-
return Array.from(bans.values());
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
Log_1.Log.error(`Failed to list bans in guild ${guildId}: ${error}`);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
static async moveMember(memberId, fromChannelId, toChannelId) {
|
|
98
|
-
try {
|
|
99
|
-
const guild = Bot_1.Bot.client.guilds.cache.find(g => g.channels.cache.has(fromChannelId) || g.channels.cache.has(toChannelId));
|
|
100
|
-
if (!guild) {
|
|
101
|
-
throw new Error(`Guild containing channels ${fromChannelId} or ${toChannelId} not found`);
|
|
102
|
-
}
|
|
103
|
-
const member = await guild.members.fetch(memberId).catch(() => null);
|
|
104
|
-
if (!member) {
|
|
105
|
-
throw new Error(`Member ${memberId} not found in guild ${guild.id}`);
|
|
106
|
-
}
|
|
107
|
-
const fromChannel = guild.channels.cache.get(fromChannelId);
|
|
108
|
-
const toChannel = guild.channels.cache.get(toChannelId);
|
|
109
|
-
if (!fromChannel) {
|
|
110
|
-
throw new Error(`From channel ${fromChannelId} not found`);
|
|
111
|
-
}
|
|
112
|
-
if (!toChannel) {
|
|
113
|
-
throw new Error(`To channel ${toChannelId} not found`);
|
|
114
|
-
}
|
|
115
|
-
if (!(fromChannel instanceof discord_js_1.VoiceChannel || fromChannel instanceof discord_js_1.StageChannel)) {
|
|
116
|
-
throw new Error(`From channel ${fromChannelId} is not a voice/stage channel`);
|
|
117
|
-
}
|
|
118
|
-
if (!(toChannel instanceof discord_js_1.VoiceChannel || toChannel instanceof discord_js_1.StageChannel)) {
|
|
119
|
-
throw new Error(`To channel ${toChannelId} is not a voice/stage channel`);
|
|
120
|
-
}
|
|
121
|
-
if (member.voice.channelId !== fromChannelId) {
|
|
122
|
-
throw new Error(`Member ${memberId} is not in channel ${fromChannelId}`);
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
await member.voice.setChannel(toChannel);
|
|
126
|
-
Log_1.Log.info(`Moved member ${memberId} from ${fromChannelId} to ${toChannelId}`);
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
Log_1.Log.error(`Failed to move member ${memberId} from ${fromChannelId} to ${toChannelId}: ${error}`);
|
|
130
|
-
throw error;
|
|
131
|
-
}
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
Log_1.Log.error(`Failed to move member ${e}`);
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.GuildManager = GuildManager;
|
|
141
|
-
GuildManager.role = RoleManager_1.RoleManager;
|
|
142
|
-
GuildManager.user = GuildUserManager_1.GuildUserManager;
|
|
143
|
-
GuildManager.channel = GuildChannelList_1.GuildChannelList;
|
|
144
|
-
GuildManager.invite = InviteManager_1.InviteManager;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BasicUserManager } from "../direct/BasicUserManager";
|
|
2
|
-
import { BanOptions, Guild, GuildMember } from "discord.js";
|
|
3
|
-
export declare class GuildUserManager extends BasicUserManager {
|
|
4
|
-
static find(userId: string, guild: Guild | string): Promise<GuildMember | null>;
|
|
5
|
-
static rename(member: GuildMember, nickname: string, maxAttempts?: number): Promise<boolean>;
|
|
6
|
-
/**
|
|
7
|
-
* Check if user is banned from guild
|
|
8
|
-
*/
|
|
9
|
-
static isBanned(guildId: string, userId: string): Promise<boolean>;
|
|
10
|
-
/**
|
|
11
|
-
* Deconnect a member from a voice
|
|
12
|
-
*/
|
|
13
|
-
static deconnectFromVoice(guildId: string, memberId: string): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Check if a member is in voice
|
|
16
|
-
*/
|
|
17
|
-
static isInVoice(memberId: string, guildId: string): Promise<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Mute a member
|
|
20
|
-
*/
|
|
21
|
-
static mute(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Unmute a member
|
|
24
|
-
*/
|
|
25
|
-
static unmute(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Deafen a member
|
|
28
|
-
*/
|
|
29
|
-
static deafen(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Undeafen member voice
|
|
32
|
-
*/
|
|
33
|
-
static undeafen(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Timeout a member
|
|
36
|
-
*/
|
|
37
|
-
static timeout(guildId: string, memberId: string, duration: number, reason?: string): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Remove the timeout of a member
|
|
40
|
-
*/
|
|
41
|
-
static untimeout(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Kick a member
|
|
44
|
-
*/
|
|
45
|
-
static kick(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
46
|
-
static ban(guildId: string, userId: string, banOption?: BanOptions): Promise<void>;
|
|
47
|
-
static unban(guildId: string, userId: string, reason?: string): Promise<void>;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=GuildUserManager.d.ts.map
|