Merge pull request #2 from Gractwo/canary

canary overwrite master & push to prod 04.10.2021
This commit is contained in:
2021-10-04 21:30:53 +02:00
committed by GitHub
18 changed files with 2837 additions and 2819 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/node_modules
.env
package-lock.json

View File

@@ -1 +1 @@
worker: node index.js
worker: node src/index.js

View File

@@ -1,93 +0,0 @@
const { Message } = require('discord.js');
module.exports = {
name: 'admin',
description: 'Ukryte rzeczy dla adminów. Tajne sprawy.',
args: false,
guildOnly: true,
execute(msg, args, Discord, config, client) {
if (msg.member.roles.cache.find((role) => role.name == 'moderacja')) {
msg.delete();
switch (args[0]) {
case 'witaj': {
const witajEmbed = new Discord.MessageEmbed()
.setTitle('Witajcie w Gractwie!')
.setDescription(
'Jesteśmy grupą ludzi, których kręcą gry. Proste, nie?\nSerwer ten miał wcześniej tematykę Team Fortressową.'
)
.setColor(config.embedColor)
.addField(
'Zasady',
'Zasady serwera są spisane na kanale `#regulamin`. Pamiętajcie, by tam zajrzeć.'
)
.addField('Gractwo WWW', '`gractwo.pl`')
.addField(
'Gractwo DISCORD',
'`gractwo.pl/discord` lub `gractwo.pl/dc` lub `discord.gg/NBXq95C`'
)
.addField(
'Gractwo FACEBOOK',
'`gractwo.pl/facebook` lub `gractwo.pl/fb` lub `facebook.com/groups/gractwo`'
)
.attachFiles('./gractwo.png')
.setFooter('#witaj', 'attachment://gractwo.png')
.setTimestamp();
msg.channel.send(witajEmbed);
break;
}
case 'rolki': {
const rolkiEmbed = new Discord.MessageEmbed()
.setTitle('Nadawanie Ról')
.setDescription(
'#rolki jest kanałem do przyznawania sobie ról.\nDostępne role: `tf2`, `liga`, `csgo`, `minecraft`, `rainbow-six`, `apex`, `genshin`.\n\nRole te służą do pingowania na poszczególnych kanałach, by zebrać ludzi chętnych do gry bądź zainteresowanych pewnym wydarzeniem.\n\nBy przydzielić sobie rolę, po prostu wpisz ją na czacie! Jest on czyszczony zaraz po. Aby pozbyć się roli, wystarczy wpisać jej nazwę jeszcze raz.'
)
.setColor(config.embedColor)
.attachFiles('./gractwo.png')
.setFooter('#rolki', 'attachment://gractwo.png')
.setTimestamp();
msg.channel.send(rolkiEmbed);
break;
}
case 'botannouncement': {
const botAnnouncementEmbed = new Discord.MessageEmbed()
.setTitle('Hej,')
.setDescription(
'W ciągu ostatnich trzech dni zostałem stworzony ja - bot Gractwa.'
)
.setColor(config.embedColor)
.addField(
'Moja funkcja',
'Zastąpiłem wiadomości na kanałach `#witaj` i `#regulamin`, serwisuję również `#rolki`.'
)
.addField(
'Zmiany',
`Wraz z moim przybyciem zostało uproszczone nasze logo, w regulaminie czekają na Was dwie nowe zasady (niezbyt restrykcyjne ;3), forma serwera została uproszczona.`
)
.addField(
'Rolki? Co?',
`Rolki To!\n\nMogą one być wykorzystywane do zbierania osób do grania/rozmów. Było to coś o co poproszono naszą administrację już dawno temu. Dziś jest to już dla Was dostępne!`
)
.attachFiles('./gractwo.png')
.setFooter(`by j4mesen`, 'attachment://gractwo.png')
.setTimestamp();
msg.channel.send(botAnnouncementEmbed);
break;
}
case 'riposta': {
msg.channel.send('mama twoja');
break;
}
case 'everyone': {
msg.channel.send(`@everyone`);
break;
}
default: {
msg.reply('nie sprecyzowałeś!');
break;
}
}
} else {
msg.reply('chyba nie masz na to wystarczających permisji.');
}
},
};

View File

@@ -1,19 +0,0 @@
module.exports = {
name: 'ping',
description: 'Pokazuje ping.',
args: false,
guildOnly: false,
execute(msg, args, Discord, config, client) {
msg.delete()
.catch(console.error);
const pingEmbed = new Discord.MessageEmbed()
.setTitle('Pong!')
.setColor(config.embedColor)
.setDescription(`Ping API wynosi ${client.ws.ping}`)
.attachFiles('./gractwo.png')
.setFooter(`Komenda wywołana przez ${msg.author.username}`, 'attachment://gractwo.png')
.setTimestamp();
msg.channel.send(pingEmbed);
console.log(`Responded to ping request by ${msg.author.username}`);
},
};

View File

@@ -1,63 +0,0 @@
module.exports = {
name: 'regulamin',
description: 'Wyświetla regulamin / pojedyńcze zasady.',
args: false,
guildOnly: true,
execute(msg, args, Discord, config){
arg0 = args[0];
msg.delete()
.catch(console.error);
regulaminEmbedTitleArray = [
'Regulamin','§1 Szacunek','§2 Spam / Trolling',
'§3 Shitposting','§4 Poprawne Kanały','§5 Memy i Gify',
'§6 Reklamy','§7 Przestrzeganie Regulaminu','§8 Obcowanie z botem',
'§9 Warunki Użytkowania Discord (ToS)'
];
regulaminEmbedContentArray = [
'Regulamin naszego serwera prezentuje się następująco:',
'Na naszym serwerze obowiązuje szacunek do innych osób podczas niesatyrycznej dyskusji.',
'Jeżeli będziesz bezużytecznie spamować lub nieprzyjmenie się zachowywać zostaniesz zbanowany.',
'Kanał #shitposting 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.',
'Rozmowy na dany temat powinny toczyć się w kanałach do tego przeznaczonych.',
'Memy i Gify nie są zbyt przyjemne dla oka bez kontekstu. Najlepiej jest nie postować ich, jeżeli nie pasują do prowadzonej aktualnie dyskusji.',
'Zakaz reklam bez zezwolenia moderatora lub administratora. Pozwolenia na reklamę muszą być wydane przed jej zamieszczeniem.',
'Przestrzeganie regulaminu jest obowiązkowe, a to że go ktoś nie przeczytał nic nie zmienia.',
'Próby intencjonalnego łamania bota nie są mile widziane, tak jak nadużywanie go w celach spamu kanałów.',
'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.'
];
const num = parseInt(args[0]);
if(num > 0 && num < regulaminEmbedTitleArray.length){
const calyRegulaminEmbed = new Discord.MessageEmbed()
.setTitle(regulaminEmbedTitleArray[num])
.setDescription(regulaminEmbedContentArray[num])
.setColor(config.embedColor)
.attachFiles('./gractwo.png')
.setFooter(`Komenda wywołana przez ${msg.author.username}`, 'attachment://gractwo.png')
.setTimestamp();
msg.channel.send(calyRegulaminEmbed);
console.log(`Responded to request for a specific rule by ${msg.author.username}`);
}else{
const calyRegulaminEmbed = new Discord.MessageEmbed()
.setTitle(regulaminEmbedTitleArray[0])
.setDescription(regulaminEmbedContentArray[0])
.setColor(config.embedColor)
.attachFiles('./gractwo.png')
.setTimestamp();
for(i = 1; i < regulaminEmbedTitleArray.length; i++){
calyRegulaminEmbed
.addField(regulaminEmbedTitleArray[i],regulaminEmbedContentArray[i]);
}
if(args[0] == 'admin' && msg.member.roles.cache.find(role => role.name == 'Moderatorzy')){
calyRegulaminEmbed
.setFooter(`Ostatnio zaktualizowany`, 'attachment://gractwo.png');
}else{
calyRegulaminEmbed
.setFooter(`Komenda wywołana przez ${msg.author.username}`, 'attachment://gractwo.png')
}
msg.channel.send(calyRegulaminEmbed);
console.log(`Responded to request for the whole ruleset by ${msg.author.username}`);
}
}
}

View File

@@ -1,29 +0,0 @@
const fs = require('fs');
module.exports = {
name: 'urusai',
description: 'Mówi jemenikowi żeby zamknął dupę (na vc).',
args: false,
guildOnly: true,
async execute(msg, args, Discord, config, client) {
if (msg.member.voice.channel) {
const connection = await msg.member.voice.channel.join();
msg.delete()
.catch(console.error);
const jzdEmbed = new Discord.MessageEmbed()
.setTitle('Chotto matte! >w<')
.setColor(config.embedColor)
.setDescription(`Mówienie jemenikowi żeby zamknął dupę...`)
.attachFiles('./gractwo.png')
.setFooter(`Komenda wywołana przez ${msg.author.username}`, 'attachment://gractwo.png')
.setTimestamp();
msg.channel.send(jzdEmbed);
const dispatcher = connection.play(fs.createReadStream('./commands/urusai.mp3'));
dispatcher.on('speaking', speaking => {
if (speaking === 0) { msg.member.voice.channel.leave() }
})
} else {
msg.reply(`Najpierw musiałbyś być na kanale głosowym...`);
}
console.log(`Responded to urusai request by ${msg.author.username}`);
},
};

Binary file not shown.

View File

@@ -1,5 +0,0 @@
{
"prefix": ".",
"embedColor":"61f2ea",
"embedColorFail":"0xfb636b"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

187
index.js
View File

@@ -1,187 +0,0 @@
require('dotenv').config();
const Discord = require('discord.js');
const config = require('./config.json');
const fs = require('fs');
const client = new Discord.Client();
client.commands = new Discord.Collection();
const commandFiles = fs
.readdirSync('./commands')
.filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log(
'-------------------------------------\nTHE BOT IS READY TO GO.\n-------------------------------------'
);
client.user.setActivity('.ping', { type: 'LISTENING' });
});
client.on('message', (message) => {
/* OMITTING THE COMMAND HANDLER TO CATCH ANY AND ALL MESSAGES IN THE '#rolki' CHANNEL
MAKING 'tf2' A VIABLE COMMAND WITHOUT A PREFIX */
if (message.channel.name == 'rolki') {
if (message.author.bot) return;
if (
message.content == 'tf2' ||
message.content == 'liga' ||
message.content == 'csgo' ||
message.content == 'minecraft' ||
message.content == 'rainbow-six' ||
message.content == 'apex' ||
message.content == 'genshin'
) {
const role = message.member.guild.roles.cache.find(
(role) => role.name == message.content
);
if (
message.member.roles.cache.find((role) => role.name == message.content)
) {
message.member.roles.remove(role);
message.delete();
console.log(
`removed ${message.author.username}'s ${message.content} role.`
);
const removeRolesEmbed = new Discord.MessageEmbed()
.setTitle(
`Odebrano Ci rangę ${message.content}, ${message.author.username}.`
)
.setColor(config.embedColor)
.attachFiles('./gractwo.png')
.setFooter('#rolki', 'attachment://gractwo.png')
.setTimestamp();
message.channel
.send(removeRolesEmbed)
.then((message) => message.delete({ timeout: 3500 }))
.catch(console.error);
} else {
message.member.roles.add(role);
message.delete();
console.log(
`added ${message.content} role to ${message.author.username}.`
);
const addRolesEmbed = new Discord.MessageEmbed()
.setTitle(
`Przyznano Ci rangę ${message.content}, ${message.author.username}.`
)
.setColor(config.embedColor)
.attachFiles('./gractwo.png')
.setFooter('#rolki', 'attachment://gractwo.png')
.setTimestamp();
message.channel
.send(addRolesEmbed)
.then((message) => message.delete({ timeout: 3500 }))
.catch(console.error);
}
} else {
if (
!message.member.roles.cache.find((role) => role.name == 'Moderatorzy')
) {
console.log(
`${message.author.username} spammed the rolki channel with a bad message`
);
message.delete();
const rolkiWrongMessageEmbed = new Discord.MessageEmbed()
.setTitle(`To nie jest kanał na pisanie, ${message.author.username}`)
.setColor(config.embedColorFail)
.attachFiles('./gractwo.png')
.setFooter('#rolki', 'attachment://gractwo.png')
.setTimestamp();
message.channel
.send(rolkiWrongMessageEmbed)
.then((message) => message.delete({ timeout: 3500 }))
.catch(console.error);
return;
}
}
}
if (message.content.toLowerCase() === '!rank')
message.channel.send({
files: [
'https://cdn.discordapp.com/attachments/281070649374670849/871103257580281876/tenor.gif',
],
});
// command handler is downward from comment
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
if (command.guildOnly && message.channel.type === 'dm') {
return message.reply("I can't execute that command inside DMs!");
}
if (command.args && !args.length) {
return message.channel.send(
`You didn't provide any arguments, ${message.author}!`
);
}
try {
command.execute(message, args, Discord, config, client);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command.');
}
});
client.login(process.env.BOT_TOKEN).then(() => getStatus());
// Funne API hehehehe
const http = require('http');
const port = process.env.PORT || 3000;
let status;
const getStatus = () => {
let totalSeconds = process.uptime();
let realTotalSecs = Math.floor(totalSeconds % 60);
let days = Math.floor((totalSeconds % 31536000) / 86400);
let hours = Math.floor((totalSeconds / 3600) % 24);
let mins = Math.floor((totalSeconds / 60) % 60);
let used = process.memoryUsage().heapUsed / 1024 / 1024;
status = {
username: client.user.username,
avatar: client.user.avatarURL(),
status: client.user.presence.status,
activity:
client.user.presence.activities.length > 0
? `${client.user.presence.activities[0].type} ${client.user.presence.activities[0].name}`
: null,
members: client.users.cache.size,
uptime: {
days,
hours,
mins,
realTotalSecs,
},
memory: `${Math.round(used * 100) / 100}MB`,
ping: `${Math.floor(client.ws.ping)}ms`,
node: process.version,
};
};
setInterval(getStatus, 30000);
http
.createServer(async (req, res) => {
res.statusCode = 200;
res.write(JSON.stringify(status));
res.end();
})
.listen(port, () => console.log(`Now listening on port ${port}`));

3649
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,24 @@
{
"name": "gractwo-bot",
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"engines": {
"node": "14.16.0"
},
"main": "index.js",
"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": "node index.js"
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jakubmanczak/gractwo-bot.git"
"url": "git+https://github.com/Gractwo/discord-bot.git"
},
"author": "j4mesen",
"license": "ISC",
"author": "github.com/jakubmanczak",
"license": "UNLICENSED",
"bugs": {
"url": "https://github.com/jakubmanczak/gractwo-bot/issues"
"url": "https://github.com/Gractwo/discord-bot/issues"
},
"homepage": "https://github.com/jakubmanczak/gractwo-bot#readme",
"homepage": "https://github.com/Gractwo/discord-bot#readme",
"dependencies": {
"@discordjs/opus": "^0.5.0",
"discord.js": "^12.5.1",
"discord.js": "^13.1.0",
"dotenv": "^10.0.0",
"ffmpeg-static": "^4.3.0",
"request": "2.81.0",
"ytdl-core": "^4.5.0"
"nodemon": "^2.0.13"
}
}

93
src/cfg.json Normal file
View File

@@ -0,0 +1,93 @@
{
"prefix": ".",
"hexBlue": "61f2ea",
"hexRed": "fb636b",
"iconurl": "https://i.imgur.com/4AmRDyX.png",
"timeout": 4000,
"rolesList": [
"tf2",
"liga",
"csgo",
"minecraft",
"rainbow-six",
"apex",
"genshin"
],
"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": "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
},
{
"name": "Gractwo FACEBOOK",
"value": "http://gractwo.pl/fb",
"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 Shitposting",
"value": "Kanał #shitposting 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:"
}
}

93
src/cmds/embed.js Normal file
View File

@@ -0,0 +1,93 @@
const { MessageActionRow, MessageButton, ButtonInteraction, Interaction, Client } = require('discord.js');
module.exports = {
name: 'embed',
execute(cl, msg, args) {
// TODO: add a permissions check here to make sure nobody can spawn msgs
// not intended outside of specific scenarios
const embed = {
color: cl.cfg.hexBlue,
timestamp: new Date(),
footer: {
text: `Komenda wywołana przez ${msg.author.tag}`,
icon_url: cl.cfg.iconurl,
},
};
switch (args[0]) {
case 'witaj':
embed.title = 'Witajcie w Gractwie!';
embed.description =
'Jesteśmy grupą ludzi których kręcą gry. Proste, nie?\nSerwer ten miał wcześniej tematykę Team Fortressową.';
embed.footer.text = '#witaj';
embed.fields = cl.cfg.embedFields.witaj;
readyMsg = { embeds: [embed] };
break;
case 'regulamin':
embed.title = 'Regulamin';
embed.description =
'Regulamin naszego serwera składa się z tego, co następuje:';
embed.footer.text = `Ostatnio zaktualizowany`;
embed.fields = cl.cfg.embedFields.regulamin;
readyMsg = { embeds: [embed] };
break;
case 'rolki':
embed.title = 'Rolki';
embed.description = '#rolki jest kanałem do przyznawania sobie ról.';
embed.footer.text = '#rolki';
// code responsible for making lists of buttons out of cl.cfg.rolesList
// & including them in the readyMsg
let i = 1,
l = 0;
let btnList = [];
while (
cl.cfg.rolesList.length / 5 +
(cl.cfg.rolesList.length % 5 != 0 ? 1 : 0) >=
i
) {
let btnRow = new MessageActionRow();
for (l; l <= 5 * i - 1 && cl.cfg.rolesList[l] != undefined; l++) {
btnRow.addComponents(
new MessageButton()
.setCustomId(cl.cfg.rolesList[l])
.setLabel(`rolka ${cl.cfg.rolesList[l]}`)
.setStyle('SECONDARY')
);
}
btnList.push(btnRow);
console.log(btnList);
i++;
}
readyMsg = { embeds: [embed], components: btnList };
break;
default:
embed.title = `zły parametr: ` + args[0];
embed.color = cl.cfg.hexRed;
readyMsg = { embeds: [embed] };
break;
}
msg.channel.send(readyMsg);
if(args[0] === "rolki")
{
cl.on('interactionCreate', inter => {
if(!inter.isButton()) return;
const role = inter.member.guild.roles.cache.find((role) => role.name == inter.customId);
if(!role) return;
if(!inter.member.roles.cache.find((role) => role.name == inter.customId))
{
inter.member.roles.add(role)
inter.reply("Gratulacje, dodalismy ci tą bezużyteczną rangę",{timeout:cl.cfg.timeout})
.then (inter.deleteReply())
}
else
{
inter.member.roles.remove(role)
inter.reply("Gratulacje, odebraliśmy ci tą bezużyteczną rangę",{timeout:cl.cfg.timeout})
.then (inter.deleteReply())
}
}
)
}
},
};

18
src/cmds/ping.js Normal file
View File

@@ -0,0 +1,18 @@
module.exports = {
name: 'ping',
execute(cl, msg) {
const embed = {
color: cl.cfg.hexBlue,
timestamp: new Date(),
footer: {
text: `Komenda wywołana przez ${msg.author.tag}`,
icon_url: cl.cfg.iconurl,
},
title: 'Pong!',
description: `Ping jednostronny wynosi ${
Date.now() - msg.createdTimestamp
}ms.`,
};
msg.channel.send({ embeds: [embed] });
},
};

16
src/cmds/pomoc.js Normal file
View File

@@ -0,0 +1,16 @@
module.exports = {
name: 'pomoc',
execute(cl, msg) {
const embed = {
color: cl.cfg.hexBlue,
timestamp: new Date(),
footer: {
text: `Komenda wywołana przez ${msg.author.tag}`,
icon_url: cl.cfg.iconurl,
},
title: 'Pomoc!',
description: cl.cfg.embedFields.pomocDesc,
};
msg.channel.send({ embeds: [embed] });
},
};

17
src/cmds/regulamin.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
name: 'regulamin',
execute(cl, msg) {
const embed = {
color: cl.cfg.hexBlue,
timestamp: new Date(),
footer: {
text: `Komenda wywołana przez ${msg.author.tag}`,
icon_url: cl.cfg.iconurl,
},
title: 'Regulamin',
description: 'Regulamin naszego serwera składa się z tego, co następuje:',
fields: cl.cfg.embedFields.regulamin,
};
msg.channel.send({ embeds: [embed] });
},
};

56
src/index.js Normal file
View File

@@ -0,0 +1,56 @@
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}`
);
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