added dist

This commit is contained in:
2024-04-07 12:59:22 +02:00
parent fbc744d5c1
commit 7962ad0679
18 changed files with 467 additions and 20 deletions

View File

@@ -1,20 +0,0 @@
name: TypeScript Build
on:
push:
branches:
- main # Adjust branch name as needed
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Run TypeScript compilation
run: npm run build # Or replace with your build command

4
dist/config.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"testServer": "995670033961336862",
"devs": ["965683547723694112"]
}

38
dist/src/commands/economy/balance.js vendored Normal file
View File

@@ -0,0 +1,38 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const discord_js_1 = require("discord.js");
const User_1 = __importDefault(require("../../models/User"));
const command = {
name: "balance",
description: "Zeigt deinen Aktuellen Kontostand",
onlyServerCommand: true,
options: [
{
name: "user",
description: "Der User von dem du das Konto sehen möchtest!",
type: discord_js_1.ApplicationCommandOptionType.Mentionable,
}
],
callback: async (client, interaction) => {
await interaction.deferReply();
const userOption = await interaction.options.get("user")?.value?.toString();
let targetUser = await interaction.guild?.members.fetch(interaction.user.id);
if (userOption) {
targetUser = await interaction.guild?.members.fetch(userOption);
}
const query = {
userId: targetUser?.id,
guildId: interaction.guild?.id
};
let user = await User_1.default.findOne(query);
if (!user) {
await interaction.editReply(`${targetUser?.displayName} hat 0$ auf dem Konto!`);
}
else {
await interaction.editReply(`${targetUser?.displayName} hat ${user.balance}$ auf dem Konto!`);
}
}
};
module.exports = command;

42
dist/src/commands/economy/daily.js vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const User_1 = __importDefault(require("../../models/User"));
const dailyAmount = 1000;
const command = {
name: "daily",
description: "Sammle dein Täglichen Geld Bonus ein!",
onlyServerCommand: true,
callback: async (client, interaction) => {
try {
await interaction.deferReply();
const query = {
userId: interaction.user.id,
guildId: interaction.guild?.id,
};
let user = await User_1.default.findOne(query);
if (user) {
const lastDailyDate = user.lastDaily.toDateString();
let currendate = new Date().toDateString();
if (lastDailyDate === currendate) {
interaction.editReply("Du hast deinen Täglichen Bonus heute schon gesichtert!");
return;
}
}
else {
user = new User_1.default({
...query,
lastDaily: new Date()
});
}
user.balance += dailyAmount;
await user.save();
interaction.editReply(`Dein Täglicher Bonus von ${dailyAmount}$ wurde Gesetzt! | Kontostand: ${user.balance}`);
}
catch (error) {
console.log("Fehler bei Daily: " + error);
}
}
};
module.exports = command;

12
dist/src/commands/misc/ping.js vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
const command = {
name: "ping",
description: "Lasse die den Ping vom Bot anzeigen!",
callback: async (client, interaction) => {
await interaction.deferReply();
const reply = await interaction.fetchReply();
const ping = reply.createdTimestamp - interaction.createdTimestamp;
interaction.editReply(`Pong! Client ${ping}ms | Websocket: ${client.ws.ping}`);
}
};
module.exports = command;

View File

@@ -0,0 +1,69 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const config_json_1 = require("../../../config.json");
const getLocalCommands_1 = __importDefault(require("../../utils/getLocalCommands"));
exports.default = async (client, interaction) => {
if (!interaction.isChatInputCommand())
return;
const localCommands = await (0, getLocalCommands_1.default)();
try {
const commandObject = localCommands.find((cmd) => cmd.name == interaction.commandName);
if (!commandObject)
return;
console.log(`/${interaction.commandName} wurde von ${interaction.user.username} ausgeführt!`);
if (commandObject.devOnly) {
if (!config_json_1.devs.includes(interaction.user.id)) {
interaction.reply({
content: "Nur Developer können diesen Befehl ausführen!",
ephemeral: true,
});
return;
}
}
if (commandObject.testOnly) {
if (!(interaction.guildId === config_json_1.testServer)) {
interaction.reply({
content: "Diese Command kann bisher nur im Hauseigenden Test-Discord genutzt werden!",
ephemeral: true,
});
return;
}
}
if (commandObject.permissionsRequired?.length) {
for (const permission of commandObject.permissionsRequired) {
if (!interaction.memberPermissions?.has(permission)) {
interaction.reply({
content: "Dir fehlen die Nötigen Berechtigungen zum Ausführen dieses Commands!",
ephemeral: true,
});
return;
}
}
}
if (commandObject.botPermissions?.length) {
for (const permission of commandObject.botPermissions) {
const bot = interaction.guild?.members.me;
if (!bot?.permissions.has(permission)) {
interaction.reply({
content: "Ich habe nicht genug Rechte um dies Auszuführen! Benötigt: " + commandObject.botPermissions,
ephemeral: true,
});
return;
}
}
}
if (commandObject.onlyServerCommand) {
if (!interaction.inGuild()) {
interaction.reply("Dieser Command kann nur in einem Server ausgefürt werden!");
return;
}
}
await commandObject.callback(client, interaction);
}
catch (error) {
console.log(`Es gab einen Fehler den Comand auszuführen | ${error}`);
}
};

View File

@@ -0,0 +1,47 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const getApplicationCommands_1 = __importDefault(require("../../utils/getApplicationCommands"));
const getLocalCommands_1 = __importDefault(require("../../utils/getLocalCommands"));
const areCommandsDifferent_1 = __importDefault(require("../../utils/areCommandsDifferent"));
exports.default = async (client) => {
try {
const localCommands = await (0, getLocalCommands_1.default)();
const applicationCommands = await (0, getApplicationCommands_1.default)(client);
for (const localCommand of localCommands) {
let { name, description, options } = localCommand;
const existingCommand = (await applicationCommands).cache.find((cmd) => cmd.name === name);
if (existingCommand) {
if (localCommand.deleted) {
(await applicationCommands).delete(existingCommand.id);
console.log(`Command ${name} gelöscht!`);
continue;
}
if ((0, areCommandsDifferent_1.default)(existingCommand, localCommand)) {
(await applicationCommands).edit(existingCommand.id, {
description,
options
});
console.log(`Command ${name} Geändert!`);
}
}
else {
if (localCommand.deleted) {
console.log(`Überspringe registrierung von Command ${name}, da er auf geläscht gesetzt wurde!`);
continue;
}
(await applicationCommands).create({
name,
description,
options,
});
console.log(`Command ${name} hinzugefügt!`);
}
}
}
catch (error) {
console.log(`Es gab einen Fehler: ${error}`);
}
};

18
dist/src/events/ready/changeStatus.js vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const discord_js_1 = require("discord.js");
const status = [make_status("Slash Commands"), make_status("/help"), make_status("by Agione")];
exports.default = async (client) => {
client.user?.setActivity(status[0]);
setInterval(() => {
let random = Math.floor(Math.random() * status.length);
client.user?.setActivity(status[random]);
}, 10000);
};
function make_status(name) {
return {
name: name,
type: discord_js_1.ActivityType.Streaming,
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
};
}

5
dist/src/events/ready/consoleLog.js vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = async (client) => {
console.log(`${client.user.username} ist nun Gestartet!`);
};

44
dist/src/handlers/eventHandler.js vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const getAllFiles_1 = __importDefault(require("../utils/getAllFiles"));
exports.default = (client) => {
const eventFolders = (0, getAllFiles_1.default)(path_1.default.join(__dirname, "..", "events"), true);
for (const eventFolder of eventFolders) {
const eventFiles = (0, getAllFiles_1.default)(eventFolder);
eventFiles.sort((a, b) => a.localeCompare(b));
const eventName = eventFolder.replace(/\\/g, "/").split("/").pop();
client.on(eventName || "", async (arg) => {
for (const eventFile of eventFiles) {
let eventFunction = await Promise.resolve(`${eventFile}`).then(s => __importStar(require(s)));
await eventFunction.default(client, arg);
}
});
}
};

29
dist/src/index.js vendored Normal file
View File

@@ -0,0 +1,29 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const discord_js_1 = require("discord.js");
const eventHandler_1 = __importDefault(require("./handlers/eventHandler"));
const dotenv_1 = __importDefault(require("dotenv"));
const mongoose_1 = __importDefault(require("mongoose"));
dotenv_1.default.config();
const client = new discord_js_1.Client({
intents: [
discord_js_1.IntentsBitField.Flags.Guilds,
discord_js_1.IntentsBitField.Flags.GuildMembers,
discord_js_1.IntentsBitField.Flags.GuildMessages,
discord_js_1.IntentsBitField.Flags.MessageContent,
],
});
(async () => {
try {
await mongoose_1.default.connect(process.env.MONGODB_URI || "");
console.log("Datenbank verbindung Hergestellt!");
(0, eventHandler_1.default)(client);
client.login(process.env.TOKEN);
}
catch (error) {
console.log("Es gab einen Fehler: " + error);
}
})();

22
dist/src/models/User.js vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = require("mongoose");
const userSchema = new mongoose_1.Schema({
userId: {
type: String,
required: true,
},
guildId: {
type: String,
required: true,
},
balance: {
type: Number,
default: 0,
},
lastDaily: {
type: Date,
required: true,
}
});
exports.default = (0, mongoose_1.model)("User", userSchema);

39
dist/src/utils/areCommandsDifferent.js vendored Normal file
View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (existingCommand, localCommand) => {
const areChoicesDifferent = (existingChoices, localChoices) => {
for (const localChoice of localChoices) {
const existingChoice = existingChoices?.find((choice) => choice.name === localChoice.name);
if (!existingChoice) {
return true;
}
if (localChoice.value !== existingChoice.value) {
return true;
}
}
return false;
};
const areOptionsDifferent = (existingOptions, localOptions) => {
for (const localOption of localOptions) {
const existingOption = existingOptions?.find((option) => option.name === localOption.name);
if (!existingOption) {
return true;
}
if (localOption.description !== existingOption.description ||
localOption.type !== existingOption.type ||
(localOption.required || false) !== existingOption.required ||
(localOption.choices?.length || 0) !==
(existingOption.choices?.length || 0) ||
areChoicesDifferent(localOption.choices || [], existingOption.choices || [])) {
return true;
}
}
return false;
};
if (existingCommand.description !== localCommand.description ||
existingCommand.options?.length !== (localCommand.options?.length || 0) ||
areOptionsDifferent(existingCommand.options, localCommand.options || [])) {
return true;
}
return false;
};

20
dist/src/utils/clearSlashCommands.js vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dotenv_1 = __importDefault(require("dotenv"));
dotenv_1.default.config();
const discord_js_1 = require("discord.js");
const commands = {};
const rest = new discord_js_1.REST({ version: "10" }).setToken(process.env.TOKEN || "");
(async () => {
try {
console.log("Lösche Alle Commands!");
await rest.put(discord_js_1.Routes.applicationCommands(process.env.CLIENT_ID || ""), { body: commands });
console.log("Alle Commands wurden gelöscht!");
}
catch (error) {
console.log("Es gab einen Fehler beim Zurücksetzen aller Commands");
}
})();

2
dist/src/utils/commandInterface.js vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

25
dist/src/utils/getAllFiles.js vendored Normal file
View File

@@ -0,0 +1,25 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
exports.default = (directory, foldersOnly = false) => {
let fileNames = [];
const files = fs_1.default.readdirSync(directory, { withFileTypes: true });
for (const file of files) {
const filePath = path_1.default.join(directory, file.name);
if (foldersOnly) {
if (file.isDirectory()) {
fileNames.push(filePath);
}
}
else {
if (file.isFile()) {
fileNames.push(filePath);
}
}
}
return fileNames;
};

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = async (client) => {
const applicationCommands = await client.application.commands;
await applicationCommands.fetch();
return applicationCommands;
};

44
dist/src/utils/getLocalCommands.js vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const path_1 = __importDefault(require("path"));
const getAllFiles_1 = __importDefault(require("./getAllFiles"));
module.exports = async (exceptions = []) => {
let localCommands = [];
const commandCategories = (0, getAllFiles_1.default)(path_1.default.join(__dirname, "..", "commands"), true);
for (const commandCategorie of commandCategories) {
const commandFiles = (0, getAllFiles_1.default)(commandCategorie);
for (const commandFile of commandFiles) {
let commandObject = await Promise.resolve(`${commandFile}`).then(s => __importStar(require(s)));
if (exceptions.includes(commandObject.name)) {
continue;
}
localCommands.push(commandObject);
}
}
return localCommands;
};