WeeskyBDW
WeeskyBDW
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by WeeskyBDW on 6/2/2024 in #djs-questions
[opinion needed] Splitting data fetching to repositories
👋 ⚠️ I post that here because it a way related to djs but isn't a problem with djs itself, more a reflexion of structuration. Feel free to told me if it's I was wondering if it would be usefull/not overkill to split data fecthing (from an DB using an ORM, external REST API using a librairy etc) and slash command code ? for example a commands/test.js that handle /test slash command and thus test.js use repositories/testRepository.js file (wich are a class/collection functions that use an lib to call external api) I'm open to any opinion and suggestion ! Thx
3 replies
SIASapphire - Imagine a framework
Created by WeeskyBDW on 5/6/2024 in #sapphire-support
Custom logger transport
Hello is they a way to set custom logger transport (like what winston allow to do) with sapphire logger (plugin logger) ? I saw other ppls also want similar things/support with winston
24 replies
SIASapphire - Imagine a framework
Created by WeeskyBDW on 4/22/2024 in #sapphire-support
Are command instance recreated every time someone use the associate slash command ?
Hello I was wondering : imagine i have a simple ping slash command who return "pong". Will sapphire recreate an instance of my Ping class (who register the command) every time do /ping or not ?
7 replies
SIASapphire - Imagine a framework
Created by WeeskyBDW on 3/30/2024 in #sapphire-support
Should i acquire every command or only once
Hello I just got interest to Sapphire and when i was reading advanced doc for registering commands outside of classes (in my case in a yml file) i saw that acquire a registry is necessary but i was wondering if i have to acquire multiple registry or not ? and also what registry id would be usefull for ? Thx
31 replies
DIAdiscord.js - Imagine an app
Created by WeeskyBDW on 1/23/2023 in #djs-questions
Package/lib for easly mocking djs ?
Hi Do you know an nodejs package that simplify mocking of djs things ? thx
25 replies
DIAdiscord.js - Imagine an app
Created by WeeskyBDW on 8/29/2022 in #djs-questions
Can't access Message.content
My bot (it is in one guild and all intents enable in ddev panel) can't acess message content after message is create Code
import {
Attachment, EmbedBuilder, GuildMember, Message, TextChannel, ThreadAutoArchiveDuration,
} from 'discord.js';
import { Settings } from '@config/settings';
import { container } from 'tsyringe';
import { BotLogger } from '@app/core/BotLogger';

export async function createSuggestion(member: GuildMember, suggestion: string, attachment? :Attachment): Promise<void | Message> {
const logger: BotLogger = container.resolve(BotLogger);
const nickname: string = member.nickname ? `(aka ${member.nickname})` : '';
const embed: EmbedBuilder = new EmbedBuilder({
title: `Suggestion de ${member.user.tag} ${nickname}`,
color: 0xed4245,
description: suggestion,
footer: { text: `${member.user.id}` },
image: { url: attachment && attachment.contentType === 'image' ? attachment.url : undefined },
});

console.log(`debug : ${suggestion.substring(0, 80)}`); // debug : lorem ipsum
const channel: TextChannel = member.guild.channels.resolve(Settings.channels.suggestion) as TextChannel;
try {
const message: Message = await channel.send({ embeds: [embed] });
console.log(`debug 2 : ${message.content}`); // debug 2 :
await message.react('👍');
await message.react('👎');
await message.startThread({
name: 'Test : ' + message.content.substring(0, 70),
reason: `Suggestion de ${member.user.tag}`,
autoArchiveDuration: ThreadAutoArchiveDuration.OneWeek,
});
return await Promise.resolve();
} catch (e: unknown) {
logger.error('Impossible de faire une suggestion', e);
return Promise.reject();
}
}
import {
Attachment, EmbedBuilder, GuildMember, Message, TextChannel, ThreadAutoArchiveDuration,
} from 'discord.js';
import { Settings } from '@config/settings';
import { container } from 'tsyringe';
import { BotLogger } from '@app/core/BotLogger';

export async function createSuggestion(member: GuildMember, suggestion: string, attachment? :Attachment): Promise<void | Message> {
const logger: BotLogger = container.resolve(BotLogger);
const nickname: string = member.nickname ? `(aka ${member.nickname})` : '';
const embed: EmbedBuilder = new EmbedBuilder({
title: `Suggestion de ${member.user.tag} ${nickname}`,
color: 0xed4245,
description: suggestion,
footer: { text: `${member.user.id}` },
image: { url: attachment && attachment.contentType === 'image' ? attachment.url : undefined },
});

console.log(`debug : ${suggestion.substring(0, 80)}`); // debug : lorem ipsum
const channel: TextChannel = member.guild.channels.resolve(Settings.channels.suggestion) as TextChannel;
try {
const message: Message = await channel.send({ embeds: [embed] });
console.log(`debug 2 : ${message.content}`); // debug 2 :
await message.react('👍');
await message.react('👎');
await message.startThread({
name: 'Test : ' + message.content.substring(0, 70),
reason: `Suggestion de ${member.user.tag}`,
autoArchiveDuration: ThreadAutoArchiveDuration.OneWeek,
});
return await Promise.resolve();
} catch (e: unknown) {
logger.error('Impossible de faire une suggestion', e);
return Promise.reject();
}
}
call in a messageCreate event
11 replies
DIAdiscord.js - Imagine an app
Created by WeeskyBDW on 8/25/2022 in #djs-questions
Why Textchannel.send allow string as option parameter
is a easy way from ppls that come from really old version of djs (when we were allowed to use a simple string for message content) ?
5 replies