trixxy-welcome
v1.0.0
Published
A Discord.js package for sending customizable welcome messages with images.
Downloads
7
Maintainers
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-welcomeRequired 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 tokenTrixxyWelcome Class
constructor(client, options)
Initializes the TrixxyWelcome handler.
client(required): The Discord.jsClientinstance.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 nowelcomeImageis 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
GuildMembersintent enabled in the Discord Developer Portal and in yourClientinitialization. - The bot must have permissions to
View ChannelandSend Messagesin the specifiedchannelId. - For
canvasto 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.
