fixed bug welcomeCommand

This commit is contained in:
moriese 2025-01-09 22:57:50 +01:00
parent 62b3eb070b
commit b8365abce8
3 changed files with 24 additions and 17 deletions

View File

@ -36,24 +36,29 @@ export class DmService {
} }
async forward(message: OmitPartialGroupDMChannel<Message<boolean>>) { async forward(message: OmitPartialGroupDMChannel<Message<boolean>>) {
if (message.channel.isDMBased()) {
const author = message.author.id;
const recipient = message.channel.recipient?.id;
console.log("forward message"); console.log("forward message");
let context = "";
const context = `<@${message.author.id}> hat geschrieben: " ${message.content} "`; if (message.author.bot) {
context = `<@${author}> hat an <@${recipient}> geschrieben:\n"${message.content}"`;
console.log(context); }
else {
context = `<@${author}> hat geschrieben:\n"${message.content}"`;
}
try { try {
const channels = client.channels; const channels = client.channels;
const channel = channels.cache.get(config.discord.channelIdNotification); const channel = channels.cache.get(config.discord.channelIdNotification);
if (channel?.isTextBased() && channel?.isSendable()) { if (channel?.isTextBased() && channel?.isSendable()) {
await channel.send(context); await channel.send(context);
} }
} catch (error) { } catch (error) {
console.error("error while forwarding a welcome msg:", error); console.error("error while forwarding a msg:", error);
}
} }
//client.users.send(config.discord.myId, context);
} }
async acceptDm(member: GuildMember) { async acceptDm(member: GuildMember) {

View File

@ -247,11 +247,14 @@ export class GreetingService {
try { try {
const channels = client.channels; const channels = client.channels;
const channel = channels.cache.get(config.discord.channelIdWelcome); const channel = channels.cache.get(config.discord.channelIdBot);
if (channel?.isTextBased() && channel?.isSendable()) { if (channel?.isTextBased() && channel?.isSendable()) {
await channel.send(welcomeContent); await channel.send(welcomeContent);
} }
await this.dmService.welcomePrivate(member);
} catch (error) { } catch (error) {
console.error("error while sending a welcome command msg:", error); console.error("error while sending a welcome command msg:", error);
} }

View File

@ -54,7 +54,6 @@ export default class DiscordController extends EventEmitter {
client.on("messageCreate", async (message) => { client.on("messageCreate", async (message) => {
console.log(message.id) console.log(message.id)
if (message.channel.type === ChannelType.DM if (message.channel.type === ChannelType.DM
&& message.author.id !== config.discord.botId
) { ) {
console.log("got msg"); console.log("got msg");
this.dmService.forward(message); this.dmService.forward(message);