Skip to content

Commit

Permalink
Self-host welcome image
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Feb 23, 2024
1 parent 71fdc30 commit 41ce7e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Binary file added files/images/welcomeimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/core/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ConstantsStrings } from "@alice-localization/core/constants/ConstantsLocalization";
import { Snowflake } from "discord.js";
import { join } from "path";

/**
* Constants that are used throughout the bot.
Expand Down Expand Up @@ -58,8 +59,12 @@ export class Constants {
/**
* The link to welcome image (used to welcome new members to the server).
*/
static readonly welcomeImageLink =
"https://cdn.discordapp.com/attachments/316545691545501706/1101147416410984478/LLzteLz.jpg";
static readonly welcomeImagePath = join(
process.cwd(),
"files",
"images",
"welcomeimage.png",
);

/**
* The uid limit that is used to check if a uid from a user's input is too small.
Expand Down
13 changes: 9 additions & 4 deletions src/events/guildMemberAdd/utils/welcomeMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ActionRowBuilder,
AttachmentBuilder,
ButtonBuilder,
ButtonStyle,
GuildBasedChannel,
Expand All @@ -17,7 +18,7 @@ export const run: EventUtil["run"] = async (_, member: GuildMember) => {
}

const general: GuildBasedChannel | null = await member.guild.channels.fetch(
Constants.mainServer
Constants.mainServer,
);

if (!general?.isTextBased()) {
Expand All @@ -26,14 +27,18 @@ export const run: EventUtil["run"] = async (_, member: GuildMember) => {

const isBinded: boolean =
await DatabaseManager.elainaDb.collections.userBind.isUserBinded(
member.id
member.id,
);

const options: MessageCreateOptions = {
content: `Welcome ${isBinded ? "back " : ""}to ${
member.guild.name
}, ${member}!`,
files: [Constants.welcomeImageLink],
files: [
new AttachmentBuilder(Constants.welcomeImagePath, {
name: "welcomeimage.png",
}),
],
};

if (!isBinded) {
Expand All @@ -44,7 +49,7 @@ export const run: EventUtil["run"] = async (_, member: GuildMember) => {
.setCustomId("initialOnboarding")
.setEmoji(Symbols.wavingHand)
.setStyle(ButtonStyle.Primary)
.setLabel("Bot Introduction")
.setLabel("Bot Introduction"),
);

options.components = [row];
Expand Down

0 comments on commit 41ce7e1

Please sign in to comment.