Initial
This commit is contained in:
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Verwende die neueste LTS-Version von Node.js
|
||||||
|
FROM node:18
|
||||||
|
|
||||||
|
# Erstelle und setze das Arbeitsverzeichnis
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# Kopiere package.json und package-lock.json (falls vorhanden)
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Installiere die Abhängigkeiten
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Kopiere den Rest des Anwendungsverzeichnisses
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Definiere die Startkommandozeile für den Container
|
||||||
|
CMD [ "npm", "start" ]
|
||||||
27
index.js
Normal file
27
index.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const { Client, GatewayIntentBits, ChannelType } = require('discord.js');
|
||||||
|
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates] });
|
||||||
|
|
||||||
|
const token = process.env.BOT_TOKEN;
|
||||||
|
const joinToCreateChannelId = process.env.JOINTOCREATE_CHANNEL_ID;
|
||||||
|
|
||||||
|
client.once('ready', () => {
|
||||||
|
console.log('Ready!');
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('voiceStateUpdate', (oldState, newState) => {
|
||||||
|
if (newState.channelId === joinToCreateChannelId) {
|
||||||
|
newState.guild.channels.create({
|
||||||
|
name: `🔊 ${newState.member.displayName}'s Channel`,
|
||||||
|
type: ChannelType.GuildVoice,
|
||||||
|
parent: newState.channel.parentId,
|
||||||
|
}).then(channel => {
|
||||||
|
newState.member.voice.setChannel(channel);
|
||||||
|
}).catch(console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldState.channel && oldState.channel.members.size === 0 && oldState.channelId !== joinToCreateChannelId) {
|
||||||
|
oldState.channel.delete().catch(console.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.login(token);
|
||||||
13
package.json
Normal file
13
package.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "join2create",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Simple Discord bot with join to create feature",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"discord.js": "^14.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user