25 Commits

Author SHA1 Message Date
Stanislaw
eabe9c9f95 prosma hotfix 2022-07-02 17:43:12 +02:00
Stanislaw
94650da46e prisma fix 2022-07-02 17:20:56 +02:00
Stanislaw
e22045b69a prod database implementation 2022-07-02 17:10:49 +02:00
Stanislaw
911ad50602 docker network 2022-07-01 23:03:11 +02:00
Stanislaw
918e498ac3 canvas fix 2022-07-01 22:51:06 +02:00
Stanislaw
8ec2b4dca2 test webhook 2022-06-21 14:44:16 +02:00
Stanislaw
d0ed5f7e00 canvas error on hold 2022-06-21 14:13:49 +02:00
Stanislaw
7e3e7ecbf8 python hotfix 3 2022-06-16 21:43:18 +02:00
Stanislaw
efaee7d035 node hotfix 2 2022-06-16 21:22:29 +02:00
Stanislaw
e1c499328a Python fix 2022-06-16 21:15:43 +02:00
Stanislaw
f7ba8187fe Node fix 2022-06-16 21:12:41 +02:00
Stanislaw
be4106b262 Prisma hotfix 2022-06-16 21:08:44 +02:00
Stanislaw
9364c1767a add dockerfile 2022-06-15 22:33:33 +02:00
Stanislaw
089e13b9ff add workflows 2022-06-15 22:28:18 +02:00
Stanislaw
ffc034dbdd dependencies update 2022-04-29 01:05:52 +02:00
Stanislaw
a2c8e1cfee class implementation with fixes and prisma schema changes 2022-04-29 00:43:24 +02:00
Stanislaw
f308503816 orm and profile first implementation 2022-04-20 15:20:22 +02:00
Stanislaw
4f11342db8 Badges download 2022-03-29 22:00:05 +02:00
Stanislaw
4af3c0adfa add leveling 2022-03-15 12:10:15 +01:00
Stanislaw
f2371974cd Postgres is alive 2022-03-11 21:16:45 +01:00
Stanislaw
5d5efa884d Redis appeared 2022-03-11 12:45:33 +01:00
Stanislaw
8a3f9bb03c Mee6discord przygotowania 2022-03-10 22:59:33 +01:00
Stanislaw
60bf216d71 new play changes 2021-12-27 21:36:50 +01:00
Stanislaw
cee3c07409 yt link download 2021-12-27 10:31:47 +01:00
Stanislaw
481a1f3f25 Voice connection shitfest edition
No działa tylko na papierze syf że szkoda gadać
2021-12-27 10:08:19 +01:00
23 changed files with 3317 additions and 2723 deletions

20
.github/workflows/deploy.yaml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Deploy
on:
push:
branches: ["canary"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build -t ${{ github.repository }} .
- name: Deploy image
run: |
docker stop ${{ github.event.repository.name }} || true
docker rm ${{ github.event.repository.name }} || true
docker run -d -e "DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}" -e "REDIS_TOKEN=${{ secrets.REDIS_TOKEN }}" -e "DATABASE_URL=${{ secrets.DATABASE_URL }}" --restart always --network BOT --name ${{ github.event.repository.name }} ${{ github.repository }}

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/node_modules
.env
package-lock.json
/src/badges

10
Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
# syntax=docker/dockerfile:1
FROM node:16.10.0
WORKDIR /app
COPY ./ ./
RUN apt-get -y update
RUN apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
RUN npm install --build-from-source canvas
RUN npm install
CMD ["npx", "prisma", "db", "push"]
CMD ["node", "index.js"]

View File

@@ -1,3 +1,4 @@
# gractwo-bot
gractwo-bot is a Discord bot written in JavaScript, using node.js and discord.js.
<b>gractwo-bot</b> is a Discord bot written in JavaScript, using node.js and discord.js.
It has been created for and only serves the Gractwo Discord server. It is hosted using Heroku.

95
cfg.json Normal file
View File

@@ -0,0 +1,95 @@
{
"prefix": "&",
"hexBlue": "61f2ea",
"hexRed": "fb636b",
"iconurl": "https://i.imgur.com/4AmRDyX.png",
"timeout": 4000,
"rolesList": [
"tf2",
"liga",
"csgo",
"minecraft",
"rainbow-six",
"apex",
"genshin",
"valorant"
],
"embedFields": {
"witaj": [
{
"name": "Zasady",
"value": "Zasady serwera są spisane na kanale `regulamin`. Pamiętajcie, by tam zajrzeć."
},
{
"name": "Gractwo WWW",
"value": "http://gractwo.pl",
"inline": true
},
{
"name": "Gractwo DISCORD",
"value": "http://gractwo.pl/discord",
"inline": true
},
{
"name": "DISCORD bezpośredni",
"value": "discord.gg/NBXq95C",
"inline": true
},
{
"name": "Gractwo TWITTER",
"value": "http://gractwo.pl/twitter",
"inline": true
},
{
"name": "Gractwo YOUTUBE",
"value": "http://gractwo.pl/youtube",
"inline": true
},
{
"name": "Gractwo GITHUB",
"value": "http://gractwo.pl/github",
"inline": true
}
],
"regulamin": [
{
"name": "§1 Szacunek",
"value": "Na naszym serwerze obowiązuje szacunek do innych osób podczas niesatyrycznej dyskusji."
},
{
"name": "§2 Spam / Trolling",
"value": "Jeżeli będziesz bezużytecznie spamować lub nieprzyjmenie się zachowywać zostaniesz zbanowany."
},
{
"name": "§3 Bagno",
"value": "Kanał #bagno jest najbardziej wyluzowanym kanałem na naszym serwerze. Nie oznacza to jednak, że nie jest monitorowany. Jeżeli czujesz, że rzecz którą chcesz tam umieścić jest nadzwyczajnie kontrowersyjna, zastanów się dwa razy przed wciśnięciem Enter."
},
{
"name": "§4 Poprawne Kanały",
"value": "Rozmowy na dany temat powinny toczyć się w kanałach do tego przeznaczonych."
},
{
"name": "§5 Memy i Gify",
"value": "Memy i Gify nie są zbyt przyjemne dla oka bez kontekstu. Najlepiej jest nie postować ich, jeżeli nie pasują do prowadzonej aktualnie dyskusji."
},
{
"name": "§6 Reklamy",
"value": "Zakaz reklam bez zezwolenia moderatora lub administratora. Pozwolenia na reklamę muszą być wydane przed jej zamieszczeniem."
},
{
"name": "§7 Przestrzeganie Regulaminu",
"value": "Przestrzeganie regulaminu jest obowiązkowe, a to że go ktoś nie przeczytał nic nie zmienia."
},
{
"name": "§8 Obcowanie z botem",
"value": "Próby intencjonalnego łamania bota nie są mile widziane, tak jak nadużywanie go w celach spamu kanałów."
},
{
"name": "§9 Warunki Użytkowania Discord (ToS)",
"value": "Nasz serwer, jak każdy inny, musi przestrzegać zasad zapisanych w warunkach użytkowania Discorda. Przypominamy o nich, bo choć nie są zbyt restrykcyjne, nie pozwalają na kilka określonych rzeczy."
}
],
"pomocDesc": "Komenda objaśniająca bota i jego zastosowanie, a także dostępne komendy.\n\nBot Gractwa funkcjonuje jako własne rozwiązanie na problemy z administrowaniem serwera Discord. Umożliwia między innymi samo-nadawanie rolek od gier, lub odsłuchiwanie muzyki.\n\nPoniżej znajduje się lista dostępnych komend:",
"rolkiDesc": "Poniżej widnieją przyciski służące do przyznawania bądź odejmowanie sobie ról powiązanych z grami. Służą one do oznaczania wszystkich zainteresowanych daną grą na określonym kanale."
}
}

95
index.js Normal file
View File

@@ -0,0 +1,95 @@
const discordjs = require("discord.js");
const fs = require("fs");
const redis = require("./src/functions/redis");
const { Postgres } = require("./src/functions/postgres");
const { createClient } = require("redis");
const colors = require("colors");
colors.setTheme({
prompt: "grey",
info: "green",
warn: "yellow",
debug: "blue",
error: "red",
});
require("dotenv").config();
const cl = new discordjs.Client({
intents: [
discordjs.Intents.FLAGS.GUILDS,
discordjs.Intents.FLAGS.GUILD_MESSAGES,
discordjs.Intents.FLAGS.GUILD_VOICE_STATES,
],
});
//redis connect
const redisConnection = createClient({
url: process.env.REDIS_TOKEN,
});
redisConnection
.connect()
.then(() => console.log("✔️ redis connected".info))
.catch((err) => console.error(err.stack.red));
//postgres connection
const client = new Postgres();
cl.cfg = require("./cfg.json");
cl.cmds = new discordjs.Collection();
//cmds handler
const cmdsFls = fs
.readdirSync(`./src/cmds`)
.filter((file) => file.endsWith(`.js`));
for (const Fl of cmdsFls) {
const cmd = require(`./src/cmds/${Fl}`);
console.log(`command: ` + cmd.name);
cl.cmds.set(cmd.name, cmd);
}
//command execution
cl.on("messageCreate", async (msg) => {
if (msg.author.bot) return;
//exp
if (!msg.content.startsWith(cl.cfg.prefix)) {
client.messageCount(msg.author.id, msg.channel.id);
if (await redis.expCheck(msg.author.id, redisConnection)) {
client.addExp(msg.author.id, 10, 25);
}
} else {
//client.messageCount(msg.author.id);
}
const args = msg.content.slice(cl.cfg.prefix.length).trim().split(/ +/);
const cmdName = args.shift().toLowerCase();
if (!cl.cmds.has(cmdName)) return;
const cmd = cl.cmds.get(cmdName);
try {
cmd.execute(cl, msg, args, client);
} catch (error) {
console.error(
`msgCommand error: ${cmdName} with args ${args} by ${msg.author.tag}\n--\n${error}\n--`
);
msg.reply(
`An error occured while trying to execute ${cmdName} with args ${args}`
);
console.log(error);
return;
}
console.log(`msgCommand: ${cmdName + args} by ${msg.author.tag}`);
});
//client
cl.once("ready", () => {
console.log(`bot ready; logged in as ${cl.user.tag}\n--`.info);
cl.user.setActivity(".pomoc", { type: "LISTENING" });
});
cl.login(process.env.TOKEN); // here comes the boooy
// hello boy
// welcome
// there he is
// he is here

777
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
"description": "gractwo-bot is a Discord bot written in JavaScript, using node.js and discord.js.\r It has been created for and only serves the Gractwo Discord server. It is hosted using Heroku.",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "nodemon"
},
"repository": {
"type": "git",
@@ -21,8 +21,13 @@
"npm": ">=7.24.0"
},
"dependencies": {
"discord.js": "^13.1.0",
"@prisma/client": "^3.12.0",
"colors": "^1.4.0",
"daemon": "^1.1.0",
"discord.js": "^13.6.0",
"dotenv": "^10.0.0",
"nodemon": "^2.0.13"
"nodemon": "^2.0.16",
"prisma": "^3.13.0",
"redis": "^4.0.4"
}
}

48
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,48 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["linux-musl"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model badges {
badge_id Int @id
badge_name String
badge_description String
badge_visibility Boolean @default(true)
badge_type Int @default(0)
givenbadges givenbadges[]
}
model givenbadges {
user_id String
badge_id Int
date_of_confer DateTime @id @db.Date
badges badges @relation(fields: [badge_id], references: [badge_id], onDelete: NoAction, onUpdate: NoAction, map: "badge_id")
users users @relation(fields: [user_id], references: [user_id], onDelete: NoAction, onUpdate: NoAction, map: "user_id")
@@index([badge_id], map: "fki_badge_id")
@@index([user_id], map: "fki_user_id")
}
model users {
user_id String @id(map: "user_pkey")
exp Int @default(0)
voice_time Int @default(0)
lvl Int @default(0)
givenbadges givenbadges[]
sendmessages sendmessages[]
}
model sendmessages {
id Int @id @default(autoincrement())
user_id String
date DateTime @db.Date
channel String
msg_count Int
users users @relation(fields: [user_id], references: [user_id], onDelete: NoAction, onUpdate: NoAction, map: "user_id")
}

View File

@@ -1,95 +0,0 @@
{
"prefix": ".",
"hexBlue": "61f2ea",
"hexRed": "fb636b",
"iconurl": "https://i.imgur.com/4AmRDyX.png",
"timeout": 4000,
"rolesList": [
"tf2",
"liga",
"csgo",
"minecraft",
"rainbow-six",
"apex",
"genshin",
"valorant"
],
"embedFields": {
"witaj": [
{
"name": "Zasady",
"value": "Zasady serwera są spisane na kanale `regulamin`. Pamiętajcie, by tam zajrzeć."
},
{
"name": "Gractwo WWW",
"value": "http://gractwo.pl",
"inline": true
},
{
"name": "Gractwo DISCORD",
"value": "http://gractwo.pl/discord",
"inline": true
},
{
"name": "DISCORD bezpośredni",
"value": "discord.gg/NBXq95C",
"inline": true
},
{
"name": "Gractwo TWITTER",
"value": "http://gractwo.pl/twitter",
"inline": true
},
{
"name": "Gractwo YOUTUBE",
"value": "http://gractwo.pl/youtube",
"inline": true
},
{
"name": "Gractwo GITHUB",
"value": "http://gractwo.pl/github",
"inline": true
}
],
"regulamin": [
{
"name": "§1 Szacunek",
"value": "Na naszym serwerze obowiązuje szacunek do innych osób podczas niesatyrycznej dyskusji."
},
{
"name": "§2 Spam / Trolling",
"value": "Jeżeli będziesz bezużytecznie spamować lub nieprzyjmenie się zachowywać zostaniesz zbanowany."
},
{
"name": "§3 Bagno",
"value": "Kanał #bagno jest najbardziej wyluzowanym kanałem na naszym serwerze. Nie oznacza to jednak, że nie jest monitorowany. Jeżeli czujesz, że rzecz którą chcesz tam umieścić jest nadzwyczajnie kontrowersyjna, zastanów się dwa razy przed wciśnięciem Enter."
},
{
"name": "§4 Poprawne Kanały",
"value": "Rozmowy na dany temat powinny toczyć się w kanałach do tego przeznaczonych."
},
{
"name": "§5 Memy i Gify",
"value": "Memy i Gify nie są zbyt przyjemne dla oka bez kontekstu. Najlepiej jest nie postować ich, jeżeli nie pasują do prowadzonej aktualnie dyskusji."
},
{
"name": "§6 Reklamy",
"value": "Zakaz reklam bez zezwolenia moderatora lub administratora. Pozwolenia na reklamę muszą być wydane przed jej zamieszczeniem."
},
{
"name": "§7 Przestrzeganie Regulaminu",
"value": "Przestrzeganie regulaminu jest obowiązkowe, a to że go ktoś nie przeczytał nic nie zmienia."
},
{
"name": "§8 Obcowanie z botem",
"value": "Próby intencjonalnego łamania bota nie są mile widziane, tak jak nadużywanie go w celach spamu kanałów."
},
{
"name": "§9 Warunki Użytkowania Discord (ToS)",
"value": "Nasz serwer, jak każdy inny, musi przestrzegać zasad zapisanych w warunkach użytkowania Discorda. Przypominamy o nich, bo choć nie są zbyt restrykcyjne, nie pozwalają na kilka określonych rzeczy."
}
],
"pomocDesc": "Komenda objaśniająca bota i jego zastosowanie, a także dostępne komendy.\n\nBot Gractwa funkcjonuje jako własne rozwiązanie na problemy z administrowaniem serwera Discord. Umożliwia między innymi samo-nadawanie rolek od gier, lub odsłuchiwanie muzyki.\n\nPoniżej znajduje się lista dostępnych komend:",
"rolkiDesc": "Poniżej widnieją przyciski służące do przyznawania bądź odejmowanie sobie ról powiązanych z grami. Służą one do oznaczania wszystkich zainteresowanych daną grą na określonym kanale."
}
}

0
src/cmds/batch.js Normal file
View File

37
src/cmds/dodajodznake.js Normal file
View File

@@ -0,0 +1,37 @@
module.exports = {
name: "dodajodznake",
async execute(cl, msg, args) {
const { get } = require("https");
const { createWriteStream, access } = require("fs");
if (msg.member.permissions.has(0x20)) {
if (msg.attachments.at(0) != null) {
console.log("attachmentadded");
msg.attachments.each((x) => {
if (x.contentType.startsWith("application/json")) {
access(`src/badges/json/${x.name}`, (e) => {
if (!e) {
const file = createWriteStream(`src/badges/json/${x.name}`);
get(x.url, (res) => {
res.pipe(file);
});
} else {
msg.channel.send("Taka odznaka już istnieje");
}
});
} else if (x.contentType.startsWith("image/")) {
exists(`src/badges/img/${x.name}`, (e) => {
if (!e) {
const file = createWriteStream(`src/badges/img/${x.name}`);
get(x.url, (res) => {
res.pipe(file);
});
} else {
msg.channel.send("Taka odznaka już istnieje");
}
});
}
});
}
}
},
};

View File

@@ -13,11 +13,6 @@ module.exports = {
// not intended outside of specific scenarios
let embed = {
color: cl.cfg.hexBlue,
// timestamp: new Date(),
// footer: {
// text: `Komenda wywołana przez ${msg.author.tag}`,
// icon_url: cl.cfg.iconurl,
// },
};
let readyMsg;

6
src/cmds/odznaki.js Normal file
View File

@@ -0,0 +1,6 @@
module.exports = {
name: "odznaki",
execute(cl, msg) {
},
};

View File

@@ -1,5 +1,5 @@
module.exports = {
name: 'ping',
name: "ping",
execute(cl, msg) {
const embed = {
color: cl.cfg.hexBlue,
@@ -8,7 +8,7 @@ module.exports = {
text: `Komenda wywołana przez ${msg.author.tag}`,
icon_url: cl.cfg.iconurl,
},
title: 'Pong!',
title: "Pong!",
description: `Ping jednostronny wynosi ${
Date.now() - msg.createdTimestamp
}ms.`,

56
src/cmds/profile.js Normal file
View File

@@ -0,0 +1,56 @@
module.exports = {
name: "profile",
async execute(cl, msg, args, connect) {
const { roundRect, expThreshold } = require("../functions/tools");
const canvas = require("canvas");
await connect
.profile(msg.author.id)
.then((user) => {
canvas.registerFont("./src/fonts/Lexend-Bold.ttf", {
family: "LexendBold",
});
canvas.registerFont("./src/fonts/Lexend-Thin.ttf", {
family: "LexendThin",
});
const canva = canvas.createCanvas(1024, 256);
let context = canva.getContext("2d");
context.fillStyle = "#484848";
roundRect(context, 0, 0, 1024, 256, 25);
context.fill();
context.font = '48px "LexendBold"';
context.fillStyle = "#FFFFFF";
context.fillText(msg.author.tag, 244, 24 + 48);
context.fillText("Lvl " + user.lvl, 850, 24 + 48);
context.font = '25px "LexendThin"';
context.fillText(user.msg_count + " messages sent", 244, 72 + 25);
context.font = '24px "LexendThin"';
context.fillText(expThreshold(user.lvl + 1) + " exp", 810, 164 + 24);
context.fillText(user.exp + " exp", 250, 164 + 24);
context.fillStyle = "#242424";
roundRect(context, 244, 200, 700, 30, 50);
context.fill();
context.fillStyle = "#61F2EA";
roundRect(
context,
244,
200,
700 *
((user.exp - expThreshold(user.lvl)) / expThreshold(user.lvl + 1)),
30,
50
);
context.fill();
roundRect(context, 34, 34, 188, 188, 100);
canvas
.loadImage(msg.author.avatarURL({ format: "png" }))
.then((image) => {
context.clip();
context.drawImage(image, 34, 34, 188, 188);
msg.reply({
files: [canva.toBuffer()],
});
});
})
.catch((err) => console.error(err.stack));
},
};

4
src/cmds/ranking.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = {
name: "ranking",
execute(cl, msg) {},
};

BIN
src/fonts/Lexend-Bold.ttf Normal file

Binary file not shown.

BIN
src/fonts/Lexend-Thin.ttf Normal file

Binary file not shown.

94
src/functions/postgres.js Normal file
View File

@@ -0,0 +1,94 @@
const { lvl, randomExp } = require("./tools");
const { PrismaClient } = require("@prisma/client");
class Postgres {
constructor() {
this.client = new PrismaClient();
}
async messageCount(userID) {
return await this.client.users.update({
where: {
user_id: userID,
},
data: {
msg_count: {
increment: 1,
},
},
});
}
async profile(userID) {
return await this.client.users.findUnique({
where: {
user_id: userID,
},
});
}
async msg_state(userID) {
return await this.client.users.findUnique({
where: {
user_id: userID,
},
});
}
async addExp(userID, min, max) {
await this.#ifUserExist(userID).then(async () => {
const rExp = randomExp(min, max);
return await this.client.users.update({
where: {
user_id: userID,
},
data: {
exp: {
increment: rExp,
},
lvl: lvl(
(
await this.client.users.findUnique({
where: {
user_id: userID,
},
select: {
exp: true,
},
})
).exp
),
},
});
});
}
async #ifUserExist(userID) {
if ((await this.profile(userID)) == null) {
console.log("Account");
await this.client.users.create({
data: {
user_id: userID,
lvl: 0,
exp: 0,
},
});
}
}
async #ifMsgsExist(userID, channelID) {
if ((await this.profile(userID)) == null) {
console.log("Account");
await this.client.users.create({
data: {
user_id: userID,
lvl: 0,
exp: 0,
},
});
}
}
//addBadge: async function (args) {},
//giveBadge: async function (args) {},
}
module.exports.Postgres = Postgres;

19
src/functions/redis.js Normal file
View File

@@ -0,0 +1,19 @@
module.exports = {
expCheck: async function (userID, connect) {
date = new Date();
const user = await connect.get(userID);
if (user == null) {
await connect.set(userID, date.getTime());
return true;
} else {
date = await connect.get(userID);
const currentDate = new Date();
if (currentDate.getTime() - date > 60000) {
await connect.set(userID, currentDate.getTime());
return true;
} else {
return false;
}
}
},
};

23
src/functions/tools.js Normal file
View File

@@ -0,0 +1,23 @@
module.exports = {
lvl: function (exp) {
return Math.floor(Math.sqrt(exp) / 5);
},
expThreshold: function (lvl) {
return Math.floor(lvl * lvl * 25);
},
randomExp: function (min, max) {
return Math.floor(Math.random() * (max - min)) + min;
},
roundRect: function (ctx, x, y, width, height, radius) {
if (width < 2 * radius) radius = width / 2;
if (height < 2 * radius) radius = height / 2;
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.arcTo(x + width, y, x + width, y + height, radius);
ctx.arcTo(x + width, y + height, x, y + height, radius);
ctx.arcTo(x, y + height, x, y, radius);
ctx.arcTo(x, y, x + width, y, radius);
ctx.closePath();
return ctx;
},
};

View File

@@ -1,57 +0,0 @@
const discordjs = require('discord.js');
const fs = require('fs');
require('dotenv').config();
const cl = new discordjs.Client({
intents: [
discordjs.Intents.FLAGS.GUILDS,
discordjs.Intents.FLAGS.GUILD_MESSAGES,
],
});
cl.cfg = require('./cfg.json');
cl.cmds = new discordjs.Collection();
const cmdsFls = fs
.readdirSync(`./src/cmds`)
.filter((file) => file.endsWith(`.js`));
for (const Fl of cmdsFls) {
const cmd = require(`./cmds/${Fl}`);
console.log(`command: ` + cmd.name);
cl.cmds.set(cmd.name, cmd);
}
cl.on('messageCreate', (msg) => {
if (!msg.content.startsWith(cl.cfg.prefix) || msg.author.bot) return;
const args = msg.content.slice(cl.cfg.prefix.length).trim().split(/ +/);
const cmdName = args.shift().toLowerCase();
if (!cl.cmds.has(cmdName)) return;
const cmd = cl.cmds.get(cmdName);
try {
cmd.execute(cl, msg, args);
} catch (error) {
console.error(
`msgCommand error: ${cmdName} with args ${args} by ${msg.author.tag}\n--\n${error}\n--`
);
msg.reply(
`An error occured while trying to execute ${cmdName} with args ${args}`
);
console.log(error);
return;
}
console.log(`msgCommand: ${cmdName + args} by ${msg.author.tag}`);
});
cl.once('ready', () => {
console.clear();
console.log(`bot ready; logged in as ${cl.user.tag}\n--`);
cl.user.setActivity('.pomoc', { type: 'LISTENING' });
});
cl.login(process.env.token); // here comes the boooy
// hello boy
// welcome
// there he is
// he is here