Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Commit

Permalink
Djs V13 Bot
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLeLoup committed Dec 17, 2021
0 parents commit 407c80a
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<h3 align="center">Discord Bot Base</h3>

<div align="center">

[![Support](https://img.shields.io/static/v1?label=Support&message=Actif&color=vert)](https://discord.gg/95vq89mfvS)
[![Discord](https://img.shields.io/discord/832296913695932428?label=Discord)](https://discord.gg/95vq89mfvS)

</div>

---

<p align="center"> 🤖 Vous cherchez une base de bot pour faire le vôtre ?
<br>
</p>

## 📝 Sommaire

- [Infos](#about)
- [Comment marche t'il ?](#working)
- [Usage](#usage)
- [Auteur](#authors)

## 🧐 Infos <a name = "about"></a>

Cette base de bot contient tout ce qu'il faut pour faire un bot parfait !

## 💭 Comment marche t'il ? <a name = "working"></a>

Commencer par télécharger le bot.

Une fois que vous l'avez téléchargé et extrais vous n'avez qu'à marquer :
```
npm i
npm run dev/npm start
```

## 🎈 Usage <a name = "usage"></a>

Le bot ne contient qu'une commande :

```
!test
```

## ✍️ Auteur <a name = "authors"></a>

- [@OwOMax](https://github.com/OwOMax)
14 changes: 14 additions & 0 deletions commands/Test/TestCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { MessageEmbed } = require("discord.js");

module.exports.run = (bot, message, args) => {
message.channel.send('Teste !')
};

module.exports.help = {
name: 'vocal',
aliases: ['vc'],
category: 'stats',
description: 'Renvoie les infos sur les personnes en vocal.',
cooldown: 5,
usage: '',
}
4 changes: 4 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
TOKEN: "T0K3N",
PREFIX: "!"
}
3 changes: 3 additions & 0 deletions events/logs/ready.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = bot => {
console.log(`${bot.user.tag} est en ligne !`)
};
49 changes: 49 additions & 0 deletions events/message/messageCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { Collection } = require('discord.js');
const { PREFIX } = require('../../config/config.js');

module.exports = (bot, message) => {
if (message.channel.type === "dm") return;
if (!message.content.startsWith(PREFIX) || message.author.bot) return;

const args = message.content.slice(PREFIX.length).split(/ +/);
const commandName = args.shift().toLowerCase();
const user = message.mentions.users.first();

const command = bot.commands.get(commandName) || bot.commands.find(cmd => cmd.help.aliases && cmd.help.aliases.includes(commandName));
if (!command) return;

if (command.help.permissions && !message.member.hasPermission('BAN_MEMBERS')) return message.reply("tu n'as pas les permissions pour taper cette commande !");

if(command.help.args && !args.length) {
let noArgsReply = `Il nous faut des arguments pour cet commande, ${message.author} !`

if (command.help.usage) noArgsReply += `\nVoici comment utiliser la commande: \`${PREFIX}${command.help.name} ${command.help.usage}.\``
return message.channel.send(noArgsReply);
}

if (command.help.isUserAdmin && !user) return message.reply("il faut mentionner un utilisateur !");

if (command.help.isUserAdmin && message.guild.member(message.mentions.users.first()).hasPermission('BAN_MEMBERS')) return message.reply("tu ne peux pas utiliser cette commande sur cet utilisateur !");

if (!bot.cooldowns.has(command.help.name)) {
bot.cooldowns.set(command.help.name, new Collection());
}

const timeNow = Date.now();
const tStamps = bot.cooldowns.get(command.help.name);
const cdAmount = (command.help.cooldown || 5) * 1000;

if (tStamps.has(message.author.id)) {
const cdExpirationTime = tStamps.get(message.author.id) + cdAmount;

if (timeNow < cdExpirationTime) {
timeLeft = (cdExpirationTime - timeNow) / 1000;
return message.reply(`merci d'attendre ${timeLeft.toFixed(0)} seconde(s) avant de ré-utiliser la commande \`${command.help.name}\``);
}
}

tStamps.set(message.author.id, timeNow);
setTimeout(() => tStamps.delete(message.author.id), cdAmount);

command.run(bot, message, args);
}
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { Client, Collection } = require('discord.js');
const { loadCommands, loadEvents } = require("./util/loader.js")
const { TOKEN } = require('./config/config.js');

const bot = new Client();
["commands", "cooldowns"].forEach(x => client[x] = new Collection());

loadCommands(bot);
loadEvents(bot);

bot.login(TOKEN);
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "djs-bot",
"version": "1.0.0",
"description": "Base de bot fais par ✞ 🅼🅰🆇#0667 ! https://discord.gg/95vq89mfvS :wink:",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "✞ 🅼🅰🆇#0667",
"license": "ISC",
"dependencies": {
"discord.js": "^13.2.0",
"fs": "0.0.1-security"
}
}
31 changes: 31 additions & 0 deletions util/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { readdirSync } = require("fs");

const loadCommands = (bot, dir = "./commands/") => {
readdirSync(dir).forEach(dirs => {
const commands = readdirSync(`${dir}/${dirs}/`).filter(files => files.endsWith(".js"));

for (const file of commands) {
const getFileName = require(`../${dir}/${dirs}/${file}`);
bot.commands.set(getFileName.help.name, getFileName);
console.log(`Commande chargée: ${getFileName.help.name}`);
};
});
};

const loadEvents = (bot, dir = "./events/") => {
readdirSync(dir).forEach(async dirs => {
const events = readdirSync(`${dir}/${dirs}/`).filter(files => files.endsWith(".js"));

for (const event of events) {
const evt = require(`../${dir}/${dirs}/${event}`);
const evtName = event.split(".")[0];
bot.on(evtName, evt.bind(null, bot));
console.log(`Evenement chargé: ${evtName}`);
};
});
};

module.exports = {
loadCommands,
loadEvents,
};

0 comments on commit 407c80a

Please sign in to comment.