Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const express = require("express");
- const app = express()
- const dotenv = require("dotenv");
- dotenv.config();
- app.listen(3000, () => {
- console.log("project is running!");
- })
- app.get("/", (req, res) => {
- res.send("Hello world!");
- })
- const client = new Discord.Client({
- intents:
- ["GUILDS", "GUILD_MESSAGES"],
- allowedMentions: ["users"]
- });
- const fs = require("fs");
- const prefix = "~";
- client.commands = new Discord.Collection();
- const commands = fs.readdirSync("./Commands").filter(file => file.endsWith(".js"));
- for (file of commands) {
- const commandName = file.split(".")[0]
- const command = require(`./Commands/${commandName}`)
- client.commands.set(commandName, command)
- }
- client.on("messageCreate", async message => {
- if (message.content.startsWith(prefix)) {
- const args = message.content.slice(prefix.length).trim().split(/ +/g)
- const commandName = args.shift()
- const command = client.commands.get(commandName)
- if (!command) return
- try {
- command.run(client, message, args, Discord)
- } catch (err) {
- message.channel.send(`There was an error while executing the command; Error: ${err}`)
- }
- }
- })
- client.login(process.env.token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement