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.
close
4 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
I use sapphire tho
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
Yeah I have no idea.
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
There are times when I start my bot those logs will not be sent, and then any deferred message or any message I try to edit just hangs with 0 errors.
26 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/11/2024 in #sapphire-support
Issues with sending messages.
I send all logs using this webhook right.
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
I have a webhook class setup that send my logs.
import { container } from '@sapphire/framework';
import { WebhookClient, EmbedBuilder } from 'discord.js';

export default class Logging {
private webhookClient: WebhookClient;

constructor(webhookURL: string) {
this.webhookClient = new WebhookClient({ url: webhookURL });
}

public logError(title: string, error: Error) {
const embed = new EmbedBuilder()
.setTitle(title)
.setColor('#FF0000')
.setTimestamp()
.setDescription(`\`\`\`${error.stack}\`\`\``);

if (container.client.user) {
embed.setThumbnail(container.client.user.displayAvatarURL());
embed.setAuthor({ name: container.client.user.tag, iconURL: container.client.user.displayAvatarURL() })
}

this.webhookClient.send({ embeds: [embed] }).catch(console.error);
}

public logWarning(title: string, warning: string) {
const embed = new EmbedBuilder()
.setTitle(title)
.setColor('#FFFF00')
.setTimestamp()
.setDescription(warning);

if (container.client.user) {
embed.setThumbnail(container.client.user.displayAvatarURL());
embed.setAuthor({ name: container.client.user.tag, iconURL: container.client.user.displayAvatarURL() })
}

this.webhookClient.send({ embeds: [embed] }).catch(console.error);
}

public logInfo(title: string, info: string) {
const embed = new EmbedBuilder()
.setTitle(title)
.setColor('#00FF00')
.setTimestamp()
.setDescription(info);

if (container.client.user) {
embed.setThumbnail(container.client.user.displayAvatarURL());
embed.setAuthor({ name: container.client.user.tag, iconURL: container.client.user.displayAvatarURL() })
}

this.webhookClient.send({ embeds: [embed] }).catch(console.error);
}
}
import { container } from '@sapphire/framework';
import { WebhookClient, EmbedBuilder } from 'discord.js';

export default class Logging {
private webhookClient: WebhookClient;

constructor(webhookURL: string) {
this.webhookClient = new WebhookClient({ url: webhookURL });
}

public logError(title: string, error: Error) {
const embed = new EmbedBuilder()
.setTitle(title)
.setColor('#FF0000')
.setTimestamp()
.setDescription(`\`\`\`${error.stack}\`\`\``);

if (container.client.user) {
embed.setThumbnail(container.client.user.displayAvatarURL());
embed.setAuthor({ name: container.client.user.tag, iconURL: container.client.user.displayAvatarURL() })
}

this.webhookClient.send({ embeds: [embed] }).catch(console.error);
}

public logWarning(title: string, warning: string) {
const embed = new EmbedBuilder()
.setTitle(title)
.setColor('#FFFF00')
.setTimestamp()
.setDescription(warning);

if (container.client.user) {
embed.setThumbnail(container.client.user.displayAvatarURL());
embed.setAuthor({ name: container.client.user.tag, iconURL: container.client.user.displayAvatarURL() })
}

this.webhookClient.send({ embeds: [embed] }).catch(console.error);
}

public logInfo(title: string, info: string) {
const embed = new EmbedBuilder()
.setTitle(title)
.setColor('#00FF00')
.setTimestamp()
.setDescription(info);

if (container.client.user) {
embed.setThumbnail(container.client.user.displayAvatarURL());
embed.setAuthor({ name: container.client.user.tag, iconURL: container.client.user.displayAvatarURL() })
}

this.webhookClient.send({ embeds: [embed] }).catch(console.error);
}
}
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
No just no response or error. And this only happens sometimes.
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
Yes I call deferreply. But I get no error.
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
Just thinking with no errors
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/11/2024 in #sapphire-support
Issues with sending messages.
Correct
26 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/5/2024 in #sapphire-support
Precondition not throwing errors.
I was setting it up wrong
8 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/5/2024 in #sapphire-support
Precondition not throwing errors.
(ignore, i figured it out.)
8 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/5/2024 in #sapphire-support
Precondition not throwing errors.
Slight problem, I added the listener that was on that page and its still not returning the error. src/preconditions/InVoice.ts
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) {
const client = this.container.client as SailorMoon;
return this.checkVoiceChannel(interaction.member as GuildMember, client);
}

private async checkVoiceChannel(member: GuildMember, client: SailorMoon) {
const voiceChannel = member.voice.channel as VoiceChannel;
const player = client.lavalink.players.get(member.guild.id);

if (!voiceChannel) {
return this.error({ message: 'You need to be in a voice channel to use this command.' });
} else if (!voiceChannel.joinable || !voiceChannel.speakable) {
return this.error({ message: 'I cannot join or speak in that voice channel.' });
} else 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.' });
} else 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) {
const client = this.container.client as SailorMoon;
return this.checkVoiceChannel(interaction.member as GuildMember, client);
}

private async checkVoiceChannel(member: GuildMember, client: SailorMoon) {
const voiceChannel = member.voice.channel as VoiceChannel;
const player = client.lavalink.players.get(member.guild.id);

if (!voiceChannel) {
return this.error({ message: 'You need to be in a voice channel to use this command.' });
} else if (!voiceChannel.joinable || !voiceChannel.speakable) {
return this.error({ message: 'I cannot join or speak in that voice channel.' });
} else 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.' });
} else return this.ok();
}
}

declare module '@sapphire/framework' {
interface Preconditions {
InVoice: never;
}
}
/src/listeners/ChatInputCommandDenied.ts
import { Events, Listener, type ChatInputCommandDeniedPayload, type UserError } from '@sapphire/framework';

export class ChatInputCommandDenied extends Listener<typeof Events.ChatInputCommandDenied> {
public run(error: UserError, { interaction }: ChatInputCommandDeniedPayload) {
const isSilent = Reflect.get(Object(error.context), 'silent');

if (interaction.deferred || interaction.replied) {
return interaction.editReply({ content: isSilent ? '\u200b' : error.message });
}

return interaction.reply({ content: isSilent ? '\u200b' : error.message, ephemeral: true });
}
}
import { Events, Listener, type ChatInputCommandDeniedPayload, type UserError } from '@sapphire/framework';

export class ChatInputCommandDenied extends Listener<typeof Events.ChatInputCommandDenied> {
public run(error: UserError, { interaction }: ChatInputCommandDeniedPayload) {
const isSilent = Reflect.get(Object(error.context), 'silent');

if (interaction.deferred || interaction.replied) {
return interaction.editReply({ content: isSilent ? '\u200b' : error.message });
}

return interaction.reply({ content: isSilent ? '\u200b' : error.message, ephemeral: true });
}
}
8 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/5/2024 in #sapphire-support
Precondition not throwing errors.
Oh duh I forgot to implement that. Thanks.
8 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/4/2024 in #sapphire-support
Property 'getUser' does not exist
I ended up restaing VSC and the error just went away. Don't know how that makes any sense.
19 replies
SIASapphire - Imagine a framework
Created by Jonny on 6/4/2024 in #sapphire-support
Property 'getUser' does not exist
i sent the code
19 replies