millennium init

This commit is contained in:
2022-12-15 21:49:07 +01:00
parent de3799757b
commit 9df1e896c6
11 changed files with 3 additions and 2899 deletions

3
.gitignore vendored
View File

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

View File

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

View File

@@ -1,4 +1,5 @@
<img align="left" style="width:128px" src="https://github.com/gractwo/assets/blob/master/logo.svg" /> <img align="left" style="width:128px" src="https://github.com/gractwo/assets/blob/master/logo.svg" />
# bot # gractwo/bot
Gractwo bot is a Discord bot written in JavaScript, running with nodejs and making use of libraries such as discordjs.
The premier bot for Gractwo's discord operations.

2533
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +0,0 @@
{
"name": "discord-bot",
"version": "1.0.0",
"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"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Gractwo/discord-bot.git"
},
"author": "github.com/jakubmanczak",
"license": "UNLICENSED",
"bugs": {
"url": "https://github.com/Gractwo/discord-bot/issues"
},
"homepage": "https://github.com/Gractwo/discord-bot#readme",
"engines": {
"node": ">=16.10.0",
"npm": ">=7.24.0"
},
"dependencies": {
"discord.js": "^13.1.0",
"dotenv": "^10.0.0",
"nodemon": "^2.0.13"
}
}

View File

@@ -1,99 +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 można wywołać komendą `.regulamin`.\nZgrubsza: 'nie bądź uschłą wierzbą'. :)"
},
{
"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."
},
{
"name": "§10 Braki Legislacyjne",
"value": "W razie jakichkolwiek braków legislacyjnych lub wątpliwości w interpretacji prawa polskiego wskazane jest rozważyć precedens wpisany w scenariusz Gractwo Dating Sim."
}
],
"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."
}
}

View File

@@ -1,116 +0,0 @@
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
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;
switch (args[0]) {
case 'witaj':
embed.author = {
name: 'Witajcie w Gractwie!',
icon_url: 'https://i.imgur.com/4AmRDyX.png',
};
embed.description =
'Jesteśmy grupą ludzi których kręcą gry. Proste, nie?\nSerwer ten miał wcześniej tematykę Team Fortressową.';
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`,
icon_url: cl.cfg.iconurl,
};
embed.timestamp = new Date();
embed.fields = cl.cfg.embedFields.regulamin;
readyMsg = { embeds: [embed] };
break;
case 'rolki':
embed.author = { name: 'Rolki' };
embed.description = cl.cfg.embedFields.rolkiDesc;
embed.footer = {
text: `#witaj`,
icon_url: cl.cfg.iconurl,
};
embed.timestamp = new Date();
// 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());
}
});
}
},
};

View File

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

View File

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

View File

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

View File

@@ -1,66 +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) => {
// peak comedy
if(msg.content.toLowerCase() === "!rank" || msg.content.toLowerCase() === "!levels"){
msg.channel.send({
files: ["https://cdn.discordapp.com/attachments/281070649374670849/871103257580281876/tenor.gif"]
});
}
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