Update from Git Manager GUI
This commit is contained in:
12
events/botping.js
Normal file
12
events/botping.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export default {
|
||||||
|
name: "messageCreate",
|
||||||
|
|
||||||
|
async execute(client, message) {
|
||||||
|
if (message.author?.bot) return;
|
||||||
|
if (!message.mentions.users.has(client.bot.user.id)) return;
|
||||||
|
|
||||||
|
message.channel.send(
|
||||||
|
`<@${message.author.id}> Für Informationen, tippe \`${client.config.prefix}help\``
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
58
events/interactionCreate.js
Normal file
58
events/interactionCreate.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
export default {
|
||||||
|
name: "interactionCreate",
|
||||||
|
|
||||||
|
async execute(client, interaction) {
|
||||||
|
// Handle slash commands
|
||||||
|
if (interaction.isChatInputCommand()) {
|
||||||
|
const command = client.commands.get(interaction.commandName);
|
||||||
|
if (!command) return;
|
||||||
|
|
||||||
|
// Build args array from slash command options
|
||||||
|
const args = [];
|
||||||
|
if (interaction.options) {
|
||||||
|
for (const option of interaction.options.data) {
|
||||||
|
if (option.type === 7 /* CHANNEL */) {
|
||||||
|
args.push(option.channel);
|
||||||
|
} else {
|
||||||
|
args.push(String(option.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build a ctx object compatible with prefix command handlers
|
||||||
|
const ctx = {
|
||||||
|
isSlash: true,
|
||||||
|
interaction,
|
||||||
|
guild: interaction.guild,
|
||||||
|
author: interaction.user,
|
||||||
|
member: interaction.member,
|
||||||
|
channel: interaction.channel,
|
||||||
|
mentions: { channels: { first: () => args.find(a => typeof a === "object") } },
|
||||||
|
reply: async (opts) => {
|
||||||
|
if (interaction.replied || interaction.deferred) {
|
||||||
|
return interaction.followUp(opts);
|
||||||
|
}
|
||||||
|
return interaction.reply(opts);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await command.execute(client, ctx, args);
|
||||||
|
} catch (e) {
|
||||||
|
client.logger.error(e);
|
||||||
|
const errMsg = { content: "Ein Fehler ist beim Ausführen des Befehls aufgetreten.", ephemeral: true };
|
||||||
|
if (interaction.replied || interaction.deferred) {
|
||||||
|
await interaction.followUp(errMsg);
|
||||||
|
} else {
|
||||||
|
await interaction.reply(errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle button interactions (e.g. from add.js confirmation)
|
||||||
|
if (interaction.isButton()) {
|
||||||
|
// Button collectors handle their own interactions via awaitMessageComponent
|
||||||
|
// Nothing to do here globally
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
85
events/message.js
Normal file
85
events/message.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
export default {
|
||||||
|
name: "messageCreate",
|
||||||
|
|
||||||
|
async execute(client, message) {
|
||||||
|
if (message.author.bot || !message.guild) return;
|
||||||
|
|
||||||
|
if (message.content === `<@${client.bot.user.id}>`)
|
||||||
|
return message.reply(`Mein Prefix ist: \`${client.config.prefix}\``);
|
||||||
|
|
||||||
|
if (!message.content.startsWith(client.config.prefix)) return;
|
||||||
|
|
||||||
|
const args = message.content
|
||||||
|
.slice(client.config.prefix.length)
|
||||||
|
.trim()
|
||||||
|
.split(" ");
|
||||||
|
const commandName = args.shift().toLowerCase();
|
||||||
|
const command =
|
||||||
|
client.commands.get(commandName) ||
|
||||||
|
client.commands.get(client.aliases.get(commandName));
|
||||||
|
|
||||||
|
if (
|
||||||
|
!command ||
|
||||||
|
(!command.guild.includes("all") &&
|
||||||
|
!command.guild.includes(message.guild.id))
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Cooldown check
|
||||||
|
if (client.cooldowns.has(`${message.guild.id}-${message.author.id}`)) {
|
||||||
|
if (
|
||||||
|
command.name ===
|
||||||
|
client.cooldowns.get(`${message.guild.id}-${message.author.id}`)
|
||||||
|
)
|
||||||
|
return message.reply(
|
||||||
|
`Bitte warte ${command.cooldown} Sekunde(n) bevor du diesen Befehl erneut verwendest!`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// NSFW check
|
||||||
|
if (command.nsfw && !message.channel.nsfw)
|
||||||
|
return message.reply(
|
||||||
|
"Dieser Befehl ist als NSFW markiert. Bitte verwende ihn in einem NSFW-Kanal!"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Args check
|
||||||
|
if (command.args_required > 0 && args.length < command.args_required) {
|
||||||
|
if (!command.args_usage)
|
||||||
|
return message.reply("Du hast nicht genug Argumente für diesen Befehl angegeben!");
|
||||||
|
else
|
||||||
|
return message.reply(
|
||||||
|
`Du hast nicht genug Argumente für diesen Befehl angegeben! Korrekte Nutzung: \`${client.config.prefix}${command.name} ${command.args_usage}\``
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// User permissions check
|
||||||
|
if (command.user_permissions?.length > 0) {
|
||||||
|
if (!message.member.permissions.has(command.user_permissions))
|
||||||
|
return message.reply(
|
||||||
|
`Du hast keine Berechtigung diesen Befehl auszuführen! \`${command.user_permissions.join("` `")}\``
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bot permissions check
|
||||||
|
if (command.bot_permissions?.length > 0) {
|
||||||
|
if (!message.guild.members.me.permissions.has(command.bot_permissions))
|
||||||
|
return message.reply(
|
||||||
|
`Ich habe nicht die erforderlichen Berechtigungen! \`${command.bot_permissions.join("` `")}\``
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark as prefix command
|
||||||
|
message.isSlash = false;
|
||||||
|
|
||||||
|
command.execute(client, message, args);
|
||||||
|
client.logger.info(
|
||||||
|
`[cmd] [${message.guild.name}] [#${message.channel.name}] (${message.author.username}) ${message.content}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update cooldowns
|
||||||
|
client.cooldowns.set(`${message.guild.id}-${message.author.id}`, command.name);
|
||||||
|
setTimeout(() => {
|
||||||
|
client.cooldowns.delete(`${message.guild.id}-${message.author.id}`);
|
||||||
|
}, command.cooldown * 1000);
|
||||||
|
},
|
||||||
|
};
|
||||||
47
events/ready.js
Normal file
47
events/ready.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { ActivityType } from "discord.js";
|
||||||
|
|
||||||
|
const typeMap = {
|
||||||
|
Playing: ActivityType.Playing,
|
||||||
|
Watching: ActivityType.Watching,
|
||||||
|
Listening: ActivityType.Listening,
|
||||||
|
Competing: ActivityType.Competing,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "clientReady",
|
||||||
|
|
||||||
|
async execute(client) {
|
||||||
|
client.logger.info(
|
||||||
|
`Logged in as ${client.bot.user.tag} on ${client.bot.guilds.cache.size} guilds`
|
||||||
|
);
|
||||||
|
|
||||||
|
var members = 0;
|
||||||
|
client.bot.guilds.cache.forEach((guild) => {
|
||||||
|
members += guild.memberCount;
|
||||||
|
});
|
||||||
|
client.logger.info(
|
||||||
|
`Serving ${members} users in ${client.bot.channels.cache.size} channels`
|
||||||
|
);
|
||||||
|
|
||||||
|
client.bot.user.setStatus("online");
|
||||||
|
|
||||||
|
const messages = client.config.statusMessages;
|
||||||
|
const intervalSec = client.config.statusInterval ?? 30;
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
|
const updatePresence = () => {
|
||||||
|
const { type, text } = messages[index % messages.length];
|
||||||
|
client.bot.user.setPresence({
|
||||||
|
activities: [{
|
||||||
|
name: text,
|
||||||
|
type: typeMap[type] ?? ActivityType.Playing,
|
||||||
|
}],
|
||||||
|
status: "online",
|
||||||
|
});
|
||||||
|
index++;
|
||||||
|
};
|
||||||
|
|
||||||
|
setInterval(updatePresence, intervalSec * 1000);
|
||||||
|
updatePresence();
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user