Package Exports
- trixxy-welcome
- trixxy-welcome/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (trixxy-welcome) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
trixxy-welcome
trixxy-welcome
is a Discord.js package designed to send customizable welcome messages with dynamically generated images to new members joining your Discord server. It leverages discord.js
for Discord API interaction and canvas
for image manipulation, allowing you to create personalized welcome banners.
Features
- Customizable Welcome Messages: Define your own welcome text with placeholders for user and guild names.
- Dynamic Welcome Images: Generate welcome images with the new member's avatar, custom background, and text.
- Easy Integration: Simple to set up and integrate into your existing Discord.js bot.
Installation
To install the package, use npm:
npm install trixxy-welcome
Required Dependencies:
discord.js
(v14.x or higher)canvas
(v2.x or higher)
Make sure you have canvas
and its dependencies properly installed. Refer to the node-canvas documentation for platform-specific installation instructions.
Usage
Here's how to use TrixxyWelcome
in your Discord.js bot:
const { Client, GatewayIntentBits } = require('discord.js');
const TrixxyWelcome = require('trixxy-welcome');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
],
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
// Initialize TrixxyWelcome
const welcomeHandler = new TrixxyWelcome(client, {
channelId: 'YOUR_WELCOME_CHANNEL_ID', // Replace with your welcome channel ID
welcomeMessage: 'Welcome, {user}! Enjoy your stay in {guild}!',
welcomeImage: 'https://example.com/your-custom-background.png', // Optional: URL to a background image
backgroundColor: '#2c2f33', // Optional: Hex color for background
textColor: '#ffffff', // Optional: Hex color for text
font: '40px Arial', // Optional: Font style for text
avatarSize: 150, // Optional: Size of the user's avatar on the image
avatarBorderColor: '#7289da', // Optional: Color of the avatar border
avatarBorderWidth: 7 // Optional: Width of the avatar border
});
// You don't need to call any methods explicitly after initialization.
// The package automatically listens for 'guildMemberAdd' events.
});
client.login('YOUR_BOT_TOKEN'); // Replace with your bot token
TrixxyWelcome
Class
constructor(client, options)
Initializes the TrixxyWelcome
handler.
client
(required): The Discord.jsClient
instance.options
(optional): An object containing configuration options:channelId
(string): The ID of the channel where welcome messages should be sent. Required for functionality.welcomeMessage
(string): The message to display. Use{user}
for the new member's username and{guild}
for the guild name. Default:'Welcome {user} to {guild}!'
.welcomeImage
(string): A URL or local path to an image to use as the background for the welcome banner. Default:null
(uses solid color background).backgroundColor
(string): Hex color code for the background if nowelcomeImage
is provided. Default:'#1a1a1a'
.textColor
(string): Hex color code for the welcome message text. Default:'#ffffff'
.font
(string): CSS-like font string for the welcome message text (e.g.,'30px sans-serif'
). Default:'30px sans-serif'
.avatarSize
(number): The size (width and height) of the user's avatar on the welcome image in pixels. Default:128
.avatarBorderColor
(string): Hex color code for the border around the user's avatar. Default:'#00b0f0'
.avatarBorderWidth
(number): The width of the avatar border in pixels. Default:5
.
Important Notes
- Ensure your bot has the
GuildMembers
intent enabled in the Discord Developer Portal and in yourClient
initialization. - The bot must have permissions to
View Channel
andSend Messages
in the specifiedchannelId
. - For
canvas
to work correctly, you might need to install additional system dependencies. Please refer to the node-canvas documentation for detailed instructions specific to your operating system.
License
This project is licensed under the ISC License.