chore(lint): reduce warning debt across core adapters and model clients
This commit is contained in:
@@ -85,7 +85,7 @@ export class DiscordAdapter implements ChannelAdapter {
|
||||
async connect(): Promise<void> {
|
||||
this._status = 'connecting';
|
||||
|
||||
this.client = new Client({
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
@@ -93,23 +93,24 @@ export class DiscordAdapter implements ChannelAdapter {
|
||||
GatewayIntentBits.DirectMessages,
|
||||
],
|
||||
});
|
||||
this.client = client;
|
||||
|
||||
// ── Ready handler — resolve connect() when the bot is online ──
|
||||
const readyPromise = new Promise<void>((resolve) => {
|
||||
this.client!.on(Events.ClientReady, () => {
|
||||
console.log(`Discord bot ready as ${this.client!.user?.tag}`);
|
||||
client.on(Events.ClientReady, () => {
|
||||
console.log(`Discord bot ready as ${client.user?.tag}`);
|
||||
this._status = 'connected';
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
// ── Message handler — route inbound messages ──
|
||||
this.client.on(Events.MessageCreate, (message: DiscordMessage) => {
|
||||
client.on(Events.MessageCreate, (message: DiscordMessage) => {
|
||||
void this.handleMessage(message);
|
||||
});
|
||||
|
||||
// Log in and wait for the ready event
|
||||
await this.client.login(this.config.botToken);
|
||||
await client.login(this.config.botToken);
|
||||
await readyPromise;
|
||||
}
|
||||
|
||||
@@ -162,8 +163,11 @@ export class DiscordAdapter implements ChannelAdapter {
|
||||
name: attachment.filename ?? 'attachment',
|
||||
});
|
||||
}
|
||||
if (!attachment.url) {
|
||||
throw new Error('Attachment must include data or url');
|
||||
}
|
||||
// URL-based attachment
|
||||
return new AttachmentBuilder(attachment.url!, {
|
||||
return new AttachmentBuilder(attachment.url, {
|
||||
name: attachment.filename ?? 'attachment',
|
||||
});
|
||||
}
|
||||
@@ -180,9 +184,8 @@ export class DiscordAdapter implements ChannelAdapter {
|
||||
// ── Guild/channel filtering ──
|
||||
if (!isDM) {
|
||||
// Check allowed guild IDs
|
||||
if (
|
||||
!isAllowedByAllowlist(message.guild!.id, this.config.allowedGuildIds)
|
||||
) {
|
||||
const guildId = message.guild?.id;
|
||||
if (!guildId || !isAllowedByAllowlist(guildId, this.config.allowedGuildIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -223,7 +226,7 @@ export class DiscordAdapter implements ChannelAdapter {
|
||||
// Send typing indicator (lasts 10 seconds, no need for interval)
|
||||
try {
|
||||
if ('sendTyping' in message.channel) {
|
||||
(message.channel as any).sendTyping();
|
||||
await (message.channel as { sendTyping: () => Promise<unknown> }).sendTyping();
|
||||
}
|
||||
} catch { /* ignore typing errors */ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user