accept user fluxer implementation
This commit is contained in:
@@ -20,11 +20,9 @@ export class MessagesService
|
||||
async sendToUser(userInput: User, message: MessagePayload): Promise<void> {
|
||||
const user = await client.users.fetch(userInput.id);
|
||||
|
||||
if (user) {
|
||||
await user.send(message);
|
||||
} else {
|
||||
this.logger.error(`User with ID ${userInput.id} not found.`);
|
||||
}
|
||||
if (!user) this.logger.error(`User with ID ${userInput.id} not found.`);
|
||||
this.logger.info(`sending message to user with ID ${userInput.id}.`);
|
||||
await user.send(message);
|
||||
}
|
||||
|
||||
async logMessage(message: Message): Promise<void> {
|
||||
@@ -38,7 +36,6 @@ export class MessagesService
|
||||
|
||||
recipient = channel.recipient;
|
||||
}
|
||||
|
||||
let logMessage: string;
|
||||
|
||||
if (recipient) {
|
||||
@@ -57,7 +54,16 @@ export class MessagesService
|
||||
const fetchedChannel = await client.channels.fetch(channel.id);
|
||||
|
||||
if (fetchedChannel?.isTextBased() && fetchedChannel.isSendable()) {
|
||||
await fetchedChannel.send(createMessageInput);
|
||||
this.logger.info(`sending message to channel with ID ${channel.id}.`);
|
||||
const success = await fetchedChannel.send(createMessageInput);
|
||||
if (success)
|
||||
this.logger.info(
|
||||
`sending message to channel with ID ${channel.id} SUCCESS.`,
|
||||
);
|
||||
else
|
||||
this.logger.error(
|
||||
`sending message to channel with ID ${channel.id} FAILED.`,
|
||||
);
|
||||
} else {
|
||||
this.logger.error(
|
||||
`Channel with ID ${channel.id} not found or is not text-based.`,
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
import { i18nService } from "@avocadi/bot-core/lib/i18n";
|
||||
import { config } from "config";
|
||||
import { greetingService } from "features/greeting/greeting.service";
|
||||
import { logChannelService } from "features/log-channel/log-channel.service";
|
||||
import client from "lib/client";
|
||||
import { logger } from "lib/common-logger";
|
||||
|
||||
client.on("guildMemberAdd", async (member) => {
|
||||
if (member.user.bot) {
|
||||
// Don't send a welcome message for bots (sorry tom)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
greetingService.sendGreeting(member.user, member.user.username);
|
||||
logChannelService.sendLogMessage(
|
||||
`Neues Mitglied: <@${member.user.id}> (${member.user.tag}) ist dem Server beigetreten.`,
|
||||
const channel = await member.guild.channels.fetch(
|
||||
config.channelMapping.text.welcome,
|
||||
);
|
||||
|
||||
if (!channel) return;
|
||||
|
||||
greetingService.sendGreeting(member.user.id, channel);
|
||||
greetingService.sendDmGreeting(member.user);
|
||||
|
||||
// logChannelService.sendLogMessage(await i18nService.t("greeting1", "de", "greeting"), TODO
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ client.on("messageReactionAdd", async (reaction, user) => {
|
||||
|
||||
await acceptUserService.sendDmAcceptUser(messageAuthor_User);
|
||||
await logChannelService.sendLogMessage(
|
||||
`introduction of <@${messageAuthor_User.id}> (${messageAuthor_User.username}) got accepted`,
|
||||
`introduction of <@${messageAuthor_User.id}> got accepted`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user