Jonny
Jonny
Explore posts from servers
SIASapphire - Imagine a framework
Created by Jonny on 6/16/2024 in #sapphire-support
No subcommand was matched with the provided command.
No description
4 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
No description
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/5/2024 in #sapphire-support
Precondition not throwing errors.
I've setup this precondition to make sure the user is in a voice channel, when the user is in a voice channel it runs perfectly fine. But if one of the conditions is not met the error is not thrown and the command does not respond.
import { Precondition } from "@sapphire/framework";
import { CommandInteraction, GuildMember, VoiceChannel } from "discord.js";
import SailorMoon from "../classes/Client";

export class InVoicePrecondition extends Precondition {

public override async chatInputRun(interaction: CommandInteraction) {
return this.checkVoiceChannel(interaction.member as GuildMember);
}

private async checkVoiceChannel(member: GuildMember) {
const voiceChannel = member.voice.channel as VoiceChannel;
console.log(voiceChannel)
if (!voiceChannel) {
return this.error({ message: 'You need to be in a voice channel to use this command.' });
}

if (!voiceChannel.joinable || !voiceChannel.speakable) {
return this.error({ message: 'I cannot join or speak in that voice channel.' });
}

const client = member.client as SailorMoon;
const player = client.lavalink.players.get(member.guild.id);
if (player && !player.paused && voiceChannel.id !== member.guild.members.me?.voice.channel?.id) {
return this.error({ message: 'You need to be in my voice channel.' });
}

return this.ok();
}
}

declare module '@sapphire/framework' {
interface Preconditions {
InVoice: never;
}
}
import { Precondition } from "@sapphire/framework";
import { CommandInteraction, GuildMember, VoiceChannel } from "discord.js";
import SailorMoon from "../classes/Client";

export class InVoicePrecondition extends Precondition {

public override async chatInputRun(interaction: CommandInteraction) {
return this.checkVoiceChannel(interaction.member as GuildMember);
}

private async checkVoiceChannel(member: GuildMember) {
const voiceChannel = member.voice.channel as VoiceChannel;
console.log(voiceChannel)
if (!voiceChannel) {
return this.error({ message: 'You need to be in a voice channel to use this command.' });
}

if (!voiceChannel.joinable || !voiceChannel.speakable) {
return this.error({ message: 'I cannot join or speak in that voice channel.' });
}

const client = member.client as SailorMoon;
const player = client.lavalink.players.get(member.guild.id);
if (player && !player.paused && voiceChannel.id !== member.guild.members.me?.voice.channel?.id) {
return this.error({ message: 'You need to be in my voice channel.' });
}

return this.ok();
}
}

declare module '@sapphire/framework' {
interface Preconditions {
InVoice: never;
}
}
8 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/4/2024 in #sapphire-support
Property 'getUser' does not exist
No description
19 replies
DIAdiscord.js - Imagine an app
Created by Jonny on 5/12/2024 in #djs-questions
Connection Timed Out
Just uploaded my bot to a vps after rewriting it entirely in ts. Not a single issue locally but now on the vps I get this error.
/root/Sailor-Moon/node_modules/undici/lib/core/connect.js:190
util.destroy(socket, new ConnectTimeoutError(message))
^
ConnectTimeoutError: Connect Timeout Error (attempted addresses: 162.159.137.232:443)
at onConnectTimeout (/root/Sailor-Moon/node_modules/undici/lib/core/connect.js:190:24)
at /root/Sailor-Moon/node_modules/undici/lib/core/connect.js:133:46
at Immediate._onImmediate (/root/Sailor-Moon/node_modules/undici/lib/core/connect.js:174:9)
at processImmediate (node:internal/timers:478:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
[nodemon] app crashed - waiting for file changes before starting...
/root/Sailor-Moon/node_modules/undici/lib/core/connect.js:190
util.destroy(socket, new ConnectTimeoutError(message))
^
ConnectTimeoutError: Connect Timeout Error (attempted addresses: 162.159.137.232:443)
at onConnectTimeout (/root/Sailor-Moon/node_modules/undici/lib/core/connect.js:190:24)
at /root/Sailor-Moon/node_modules/undici/lib/core/connect.js:133:46
at Immediate._onImmediate (/root/Sailor-Moon/node_modules/undici/lib/core/connect.js:174:9)
at processImmediate (node:internal/timers:478:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
[nodemon] app crashed - waiting for file changes before starting...
2 replies