Skip to content

Commit

Permalink
Merge pull request #14 from Simyon264/dev
Browse files Browse the repository at this point in the history
Update 4.9.0
  • Loading branch information
Simyon264 authored Jul 13, 2022
2 parents 6812bb2 + 797d1f6 commit 0f7db7e
Show file tree
Hide file tree
Showing 29 changed files with 1,936 additions and 697 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ token.txt
package-lock.json
/files/cache/*.*
/files/warns/*.*
/files/important files/config.json
/files/important files/config.json
/files/important files/discord.db
/slashcommands/ranganfrage.js
424 changes: 67 additions & 357 deletions bot.js

Large diffs are not rendered by default.

431 changes: 431 additions & 0 deletions client.js

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions commands/achievement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const f = require('../functions.js');
const discord = require('discord.js');
const fs = require("fs")

module.exports = {
name: 'achievement',
description: f.localization("commands", "achievement", "exports").description,
category: 'general',
modcommand: false,
usage: f.localization("commands", "achievement", "exports").usage,
perms: '',
alias: ["ac"],
cooldown: 1,
run: async function (message, prefix, args, client) {
if (args.length > 1) {
let id = parseInt(args[1])
let achievement = f.getAchievement(id)
let valid = false
if (achievement) {
if (achievement.id != -1) valid = true
}
if (valid) {
const embed = new discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(achievement.name)
.setDescription(achievement.description)
.addField("Kategorie:", achievement.category)
.setFooter({ text: "ID: " + achievement.id })
message.reply({ embeds: [embed] })
} else {
args.splice(0, 1)
args = args.join(" ")
valid = false
const achievements = JSON.parse(fs.readFileSync("./files/important files/achievements.json"))
for (let index = 0; index < achievements.length; index++) {
const element = achievements[index];
if (element.name.toLowerCase() == args.toLowerCase()) {
achievement = element
valid = true;
}
}
if (!valid) return message.reply("Achievement nicht gefunden.")
const embed = new discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(achievement.name)
.setDescription(achievement.description)
.addField("Kategorie:", achievement.category)
.setFooter({ text: "ID: " + achievement.id })
message.reply({ embeds: [embed] })
}
} else {
message.reply("Bitte gebe eine Achievement an.")
}
}
}
66 changes: 66 additions & 0 deletions commands/achievements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const f = require('../functions.js');
const discord = require('discord.js');
const fs = require("fs")

module.exports = {
name: 'achievements',
description: f.localization("commands", "achievements", "exports").description,
category: 'general',
modcommand: false,
usage: f.localization("commands", "achievements", "exports").usage,
perms: '',
alias: ["acs"],
cooldown: 1,
run: async function (message, prefix, args, client) {
let page = 1
if (args[1]) {
let int = parseInt(args[1])
if (int) {
if (int > 1) {
page = int
}
}
}

const achievements = JSON.parse(fs.readFileSync("./files/important files/achievements.json"))

const maxItemsForPage = 5
const maxpages = Math.ceil(achievements.length / maxItemsForPage)
if (page > maxpages) page = maxpages;

const link = await f.getLink(message.author.id)
let achievementsLink = []
if (link) {
achievementsLink = await f.getAchievements(link.idIngame)
if (achievementsLink.length !== 0) {
achievementsLink = JSON.parse(achievementsLink[0].data)
}
}

const embed = new discord.MessageEmbed()
.setTitle("Alle Achievements")
.setColor("RANDOM")
.setFooter({ text: `${achievements.length} Achievements insgesammt. Seite ${page} von ${maxpages}` })

let items = 0
let count = maxItemsForPage * (page - 1)
for (let index = 0; index < achievements.length; index++) {
if (items !== maxItemsForPage) {
if (count < index || count == index) {
items++
const element = achievements[index];
if (achievementsLink.includes(element.id)) {
embed.addField(element.name, `Beschreibung: ${element.description}\nKategorie: ${element.category}\nID: ${element.id}\n**Du hast dieses Achievement.**\n`)
} else {
embed.addField(element.name, `Beschreibung: ${element.description}\nKategorie: ${element.category}\nID: ${element.id}\n`)
}
}
} else {
index = achievements.length
}
}
message.reply({
embeds: [embed]
})
}
}
Loading

0 comments on commit 0f7db7e

Please sign in to comment.