Skip to content

Commit

Permalink
Merge pull request #16 from Simyon264/dev
Browse files Browse the repository at this point in the history
Version 4.9.2
  • Loading branch information
Simyon264 authored Aug 3, 2022
2 parents 07b3c49 + 6328beb commit a2d598e
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 34 deletions.
11 changes: 11 additions & 0 deletions .vsls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "http://json.schemastore.org/vsls",
"gitignore": "none",
"excludeFiles": [
".gitignore"
],
"hideFiles": [
"bin",
"obj"
]
}
183 changes: 182 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DLGM-Warnbot

Join the [Discord](https://discord.gg/PAPf95aQPp)
Join the [Discord](https://discord.gg/RxzaN3jGeb)

Warn-bot for DLGM.

Expand Down Expand Up @@ -31,3 +31,184 @@ To enable one of these just have it in the args when starting the bot. So:
`node bot.js [launch options]`
These have to be seperated by spaces. So if we would want to disable colour and have all debug output put into the console we would do:
`node bot.js nocolour debug`


# Networking: Bot responses

## General

```json
{
"type": "error",
"message": "invalidData"
}
```
This gets send when invalid data is send to the server.

```json
{
"id": "123",
"type": "error",
"message": "generalError"
}
```
This gets sent when an error occures with the reqeust.
```json
{
"id": "123",
"type": "error",
"message": "typeUnknown"
}
```
This gets sent when the data type is unknown.

## AchievementCheck
```json
{
"id":"123",
"type": "achievement",
"name": "yes?",
"achievementId": 0,
"description": "yes"
}
```
This gets sent as a response to a AchievementCheck. When none is found achievementId will be -1
## GiveAchievement
```json
{
"id": "123",
"type": "giveAchievementResponse",
"wasGiven": true,
"acId": 0
}
```
## Link

```json
{
"id": "123",
"type": "error",
"message": "codeNotNew"
}
```
This happens when a code gets send for linking which is already in use.

```json
{
"id": "123",
"type": "error",
"message": "noCode"
}
```
This gets sent when no code is given.
```json
{
"id": "123",
"type": "linkSuccess",
"expiresIn": "seconds",
"code": "code"
}
```
This gets sent when a link was registered.

```json
{
"id": "123",
"type": "linkCheckResponse",
"isFound": true/false
}
```
Response for if a link is in progress.

## updateStat
```json
{
"id": "123",
"type": "error",
"message": "statNotFound"
}
```
This gets sent when the stat is not found or if the user doesn't have stats.
```json
{
"id": "123",
"type": "statUpdate",
"updated": true
}
```
This gets sent when a stat was updated.

## resetStats
```json
{
"id": "123",
"type": "resetStatsResponse",
"didReset": true
}
```
If a stat reset worked.

# Networking: What you can send to the bot

```json
{
"id": "123",
"type": "link",
"data": {
"code": "abc123"
}
}
```
This starts the linking process.

```json
{
"id": "123",
"type": "linkCheck",
"data": {}
}
```
Check if there is linking active for an ID.


```json
{
"id": "123",
"type": "achievementCheck",
"data": {
"id": 0
}
}
```
Gives you info for an achievement.

```json
{
"id": "123",
"type": "giveAchievement",
"data": {
"achievementId": 0
}
}
```
Gives an ID a achievement

```json
{
"id": "123",
"type": "updateStat",
"data": {
"name": "statname",
"value": "++1"
}
}
```
Adds to a user stat. ++Value means it should add NOT set it.
```json
{
"id": "123",
"type": "resetStats",
"data": {}
}
```
Reset all stats for an ID.
8 changes: 8 additions & 0 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ for (let index = 0; index < args.length; index++) {
console.log(colors.red("ERROR: ") + "Can't reset Warn Table.\n" + err.message)
}
})
discordDB.exec('DROP TABLE "main"."stats";DROP TABLE "main"."ac";DROP TABLE "main"."links";;', (err) => {
if (err) {
console.log(colors.red("ERROR: ") + "Can't reset Discord Table.\n" + err.message)
}
})
break;
case "createdb":
createDB = true
Expand Down Expand Up @@ -390,6 +395,9 @@ async function exit(code) {
return console.error(err.message)
}
})

close();

client.destroy()
doTick()
await f.sleep(1000)
Expand Down
2 changes: 1 addition & 1 deletion commands/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
link.idIngame = response.steamid
}

if (!response.wasFound) {
if ((!response || !response.wasFound) && args[2]) {
return message.reply("Nutzer nicht gefunden.")
}

Expand Down
4 changes: 2 additions & 2 deletions commands/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const discord = require('discord.js');
const fs = require("fs")

module.exports = {
name: 'stats',
name: 'reset',
description: f.localization("commands", "stats", "exports").description,
category: 'general',
modcommand: false,
usage: f.localization("commands", "stats", "exports").usage,
perms: '',
alias: ["stat"],
alias: [],
cooldown: 1,
run: async function (message, prefix, args, client) {
const link = await f.getLink(message.author.id)
Expand Down
22 changes: 11 additions & 11 deletions commands/song.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const f = require('../functions.js');
const discord = require('discord.js');
const fs = require("fs")
const fetch = require('node-fetch')

module.exports = {
name: 'song',
description: f.localization("commands","song","exports").description,
category: 'music',
modcommand: false,
usage: f.localization("commands","song","exports").usage,
perms: '',
alias: ["si"],
cooldown: 1,
name: 'song',
description: f.localization("commands", "song", "exports").description,
category: 'music',
modcommand: false,
usage: f.localization("commands", "song", "exports").usage,
perms: '',
alias: ["si"],
cooldown: 1,
run: function (message, prefix, args, client) {
const serverQueue = queue.get(message.channel.guild.id);
const channel = message.member.voice.channel
Expand Down Expand Up @@ -53,7 +53,7 @@ module.exports = {
.addField('Likes und dislikes', `${data.likes} :thumbsup: ${data.dislikes} :thumbsdown: `, true)
.setFooter(`Hinzugefügt von: ${songInfo.by.username}`, songInfo.by.avatarURL(true))
.setThumbnail(songInfo.raw.videoDetails.thumbnails[songInfo.raw.videoDetails.thumbnails.length - 1].url)
message.reply({content: "** **", embeds:[embed]})
message.reply({ content: "** **", embeds: [embed] })
});
}
}
}
21 changes: 17 additions & 4 deletions commands/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ module.exports = {
perms: '',
alias: ["stat"],
cooldown: 1,
/**
* @param {discord.Message} message
* @param {string} args
* @param {discord.Client} client
*/
run: async function (message, prefix, args, client) {
let link = await f.getLink(message.author.id)
if (link) {
Expand All @@ -21,10 +26,18 @@ module.exports = {
const id = args[1].split("@")[0]
response = await f.getSteamInfo(id)
link.idIngame = response.steamid
}

if (!response || !response.wasFound) {
return message.reply("Nutzer nicht gefunden.")
if ((!response || !response.wasFound)) {
let user = message.mentions.users.first()
if (user) {
link = await f.getLink(user.id)
if (!link) {
return message.reply("Dieser Nutzer hat noch keinen Link!")
}
response = await f.getSteamInfo(link.idIngame)
} else {
return message.reply("Nutzer nicht gefunden.")
}
}
}

const maxAchievements = JSON.parse(fs.readFileSync("./files/important files/achievements.json")).length
Expand Down
Loading

0 comments on commit a2d598e

Please sign in to comment.