added MemberJoin
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 536 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
@@ -0,0 +1,39 @@
|
||||
const { SlashCommandBuilder, Events } = require('discord.js')
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('simjoin')
|
||||
.setDescription('simulates a join event')
|
||||
.addMentionableOption((option) =>
|
||||
option.setName('target').setDescription('user')),
|
||||
async execute(interaction) {
|
||||
|
||||
if(!interaction.member.permissions.has("ADMINISTRATOR")){
|
||||
return await interaction.reply({
|
||||
content: "Unprivileged Access!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
let target = interaction.options.getMentionable('target')
|
||||
if(!target){
|
||||
target = interaction.member
|
||||
}
|
||||
try {
|
||||
if(target.user.username){
|
||||
interaction.client.emit(Events.GuildMemberAdd, target)
|
||||
await interaction.reply({
|
||||
content: "Done!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
await interaction.reply({
|
||||
content: "Invalid Mentionable!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'DistubeError',
|
||||
once: true,
|
||||
async execute(channel, error) {
|
||||
console.log({
|
||||
channel: channel,
|
||||
error: error
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
const { Events } = require('discord.js');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const path = require('node:path');
|
||||
require('dotenv').configDotenv();
|
||||
|
||||
module.exports = {
|
||||
name: Events.GuildMemberAdd,
|
||||
once: false,
|
||||
async execute(member, client) {
|
||||
const guild = client.guilds.cache.get(process.env.D_GuildID);
|
||||
const channel = guild.channels.cache.get(process.env.D_WelcomeID);
|
||||
console.log(`${member.user.username} joined the Server`);
|
||||
|
||||
// Create Canvas
|
||||
let canvasWidth = 600;
|
||||
let canvasHeight = 250;
|
||||
const canvas = new createCanvas(canvasWidth, canvasHeight);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Draw Initial Image
|
||||
const background = await loadImage(
|
||||
path.join(__dirname, '../assets/background.png')
|
||||
);
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
ctx.drawImage(background, x, y);
|
||||
|
||||
// Create Profile Picture
|
||||
const pfp = await loadImage(
|
||||
member.user.displayAvatarURL({
|
||||
extension: 'jpg',
|
||||
size: 64,
|
||||
})
|
||||
);
|
||||
|
||||
// Draw Profile Picture on Top of Background
|
||||
x = canvas.width / 2 - pfp.width / 2;
|
||||
y = 20;
|
||||
ctx.drawImage(pfp, x, y);
|
||||
|
||||
// Set styles for text
|
||||
ctx.font = '35px sans-serif';
|
||||
ctx.fillStyle = '#ffffff'; // White text
|
||||
ctx.strokeStyle = '#000000'; // Black outline
|
||||
ctx.lineWidth = 3; // Thickness of the outline
|
||||
|
||||
let text = `Willkommen, ${member.user.username}!`;
|
||||
let textWidth = ctx.measureText(text).width;
|
||||
let textX = canvas.width / 2 - textWidth / 2;
|
||||
let textHeight = 35; // Approximate height of the text
|
||||
|
||||
// Draw the text with black outline
|
||||
ctx.strokeText(text, textX, 60 + pfp.height);
|
||||
ctx.fillText(text, textX, 60 + pfp.height);
|
||||
|
||||
ctx.font = '30px sans-serif';
|
||||
text = `auf dem ✨Olymp✨`;
|
||||
textWidth = ctx.measureText(text).width;
|
||||
textX = canvas.width / 2 - textWidth / 2;
|
||||
textHeight = 30; // Approximate height of the text
|
||||
|
||||
// Draw the second line of text with black outline
|
||||
ctx.strokeText(text, textX, 100 + pfp.height);
|
||||
ctx.fillText(text, textX, 100 + pfp.height);
|
||||
|
||||
const banner = canvas.toBuffer();
|
||||
|
||||
channel.send({
|
||||
content: `Bitte guck einmal in die <#850491176540700703> ${member}`,
|
||||
files: [{
|
||||
attachment: banner,
|
||||
name: 'banner.png',
|
||||
description: 'a welcome banner'
|
||||
}]
|
||||
});
|
||||
}
|
||||
};
|
||||
+2
-2
@@ -8,10 +8,10 @@ module.exports = (client) => {
|
||||
const filePath = path.join(eventsPath, file)
|
||||
const event = require(filePath)
|
||||
if (event.once) {
|
||||
client.once(event.name, (...args) => event.execute(...args))
|
||||
client.once(event.name, (...args) => event.execute(...args, client))
|
||||
// added client to commomerate global usage
|
||||
} else {
|
||||
client.on(event.name, (...args) => event.execute(...args))
|
||||
client.on(event.name, (...args) => event.execute(...args, client))
|
||||
// added client to commomerate global usage
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const { Client, GatewayIntentBits, Collection, Partials } = require('discord.js')
|
||||
const { MongoClient } = require('mongodb')
|
||||
const { DisTube } = require('distube');
|
||||
const { YtDlpPlugin } = require('@distube/yt-dlp')
|
||||
require('dotenv').config()
|
||||
const mClient = new MongoClient(process.env.M_URI)
|
||||
exports.mClient = mClient;
|
||||
@@ -10,6 +8,7 @@ const fs = require('node:fs')
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildPresences,
|
||||
GatewayIntentBits.GuildMessageReactions,
|
||||
@@ -27,19 +26,8 @@ client.aliases = new Collection() // list of command aliases
|
||||
client.buttons = new Collection() // list of buttons
|
||||
client.selectMenus = new Collection() // list of selectMenus
|
||||
|
||||
// Initialize DisTube with YtDlpPlugin and request options
|
||||
const distube = new DisTube(client, {
|
||||
plugins: [
|
||||
new YtDlpPlugin(),
|
||||
],
|
||||
});
|
||||
|
||||
client.distube = distube
|
||||
|
||||
fs.readdirSync('./handlers').forEach((handler) => {
|
||||
require(`./handlers/${handler}`)(client)
|
||||
});
|
||||
|
||||
|
||||
distube.on('error', (channel, error) => {client.emit('DistubeError', (channel, error))})
|
||||
client.login(process.env.D_Token)
|
||||
Generated
+463
-965
File diff suppressed because it is too large
Load Diff
+2
-8
@@ -20,16 +20,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/DeSqBlocki/Arthonor-3#readme",
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.9.0",
|
||||
"@discordjs/voice": "^0.17.0",
|
||||
"@distube/yt-dlp": "^2.0.1",
|
||||
"canvas": "^2.11.2",
|
||||
"discord.js": "^14.15.3",
|
||||
"distube": "^5.0.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"mongodb": "^6.8.0",
|
||||
"node-pre-gyp": "^0.17.0",
|
||||
"nodemon": "^3.1.4",
|
||||
"rebuild": "^0.1.2",
|
||||
"sodium-native": "^4.1.1"
|
||||
"nodemon": "^3.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user