anidiotsguide / guidebot Goto Github PK
View Code? Open in Web Editor NEWA boilerplate example bot with command handler and reloadable commands. Updated and Maintained by the Idiot's Guide Community
License: MIT License
A boilerplate example bot with command handler and reloadable commands. Updated and Maintained by the Idiot's Guide Community
License: MIT License
Currently if the output of the eval command is greater than the Discord message limit, the command errors and does not send any kind of message. If the output of the eval command is longer than the Discord message limit, the output should be logged elsewhere (maybe to console?) and a message should be sent letting the user know.
I got a settings suggestion, maybe make a setting to be able to hide a command from the help
menu. I could use it to hide owner commands, again members can't use it, but it would be more tidy if we could just hide commands from the help menu, because they just kind of take up space.
In line 24 of set.js:
if (!value) seems to be always false as u can parse "nothing".
After parsing "nothing" you can not change it back via "set edit key value" as the empty key can not be found by: if (!settings[key])
My solution for now:
if (!value && value == "")
I'm running a webhook and bot merged together, so only passing commands with prefix through the message listener is not the best option for. Editing the message.js is not the best way to achieve those different type of listeners, so the optimal way would be to have 2 message.js, one for the webhook and one for the commands with prefix.
Is there any way to do this, with the module setup?
Hello,
Is the transition to discord.js version 12 planned ?
We're starting to hear about it, but the changes seem significant...
Thank you !
This is here just for foramlity's sake. The idea has been discussed in the Discord server.
STEPS:
This suggestion is on hold
So the bot's been running fine for awhile, then i used the help command and everything stopped working.. any ideas?
Uncaught Exception: TypeError: Cannot read property 'permLevel' of undefined
at message.guild.client.commands.filter.cmd (C:\Users\Name\Desktop\guidebot\commands\help.js:16:97)
at Map.filter (C:\Users\Name\Desktop\guidebot\node_modules\enmap\src\index.js:254:11)
at Object.exports.run (C:\Users\Name\Desktop\guidebot\commands\help.js:16:56)
at module.exports (C:\Users\Name\Desktop\guidebot\events\message.js:66:7)
at emitOne (events.js:115:13)
at Client.emit (events.js:210:7)
at MessageCreateHandler.handle (C:\Users\Name\Desktop\guidebot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Name\Desktop\guidebot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\Name\Desktop\guidebot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (C:\Users\Name\Desktop\guidebot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)
shouldn't it be:
if (message.author.id === this.config.ownerID) return 10; ?
The v11 wont work after 7 days. Please update to v12.
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/dndrhead/.nvm/versions/node/v11.7.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:188:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Linux 4.15.0-43-generic
gyp ERR! command "/home/dndrhead/.nvm/versions/node/v11.7.0/bin/node" "/home/dndrhead/.nvm/versions/node/v11.7.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/dndrhead/guidebot/node_modules/leveldown
gyp ERR! node -v v11.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dndrhead/.npm/_logs/2019-01-18T15_03_39_809Z-debug.log
Any ideas?
Node version: 11.7.0
Npm version: 6.5.0
So when I change a command setting to enabled: true
to enabled: false
, I still can use the command. Or do I bypass it since I am the owner?
Sorry for the trouble. I am new to having all these new features in command handlers.
When i do npm install
this error came up
> [email protected] install C:\Mybot\guidebot\guidebot\node_modu les\integer
node-gyp rebuild
C:\Mybot\guidebot\guidebot\node_modules\integer>if not defin
ed npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modu
les\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" reb
uild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-g
yp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Program Files\Python37\python.EXE -c im
port platform; print(platform.python_version());
gyp ERR! stack Traceback (most recent call last):
gyp ERR! stack File "", line 1, in
gyp ERR! stack File "E:\Program Files\Python36-32\Lib\platform.py", line 116,
in <module
gyp ERR! stack import sys, os, re, subprocess
gyp ERR! stack File "E:\Program Files\Python36-32\Lib\re.py", line 123, in <mo
dule
gyp ERR! stack import sre_compile
gyp ERR! stack File "E:\Program Files\Python36-32\Lib\sre_compile.py", line 17
, in module
gyp ERR! stack assert _sre.MAGIC == MAGIC, "SRE module mismatch"
gyp ERR! stack AssertionError: SRE module mismatch
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:275:12)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:346:11)
gyp ERR! stack at emitOne (events.js:116:13)
gyp ERR! stack at Socket.emit (events.js:211:7)
gyp ERR! stack at Pipe._handle.close [as onclose] (net.js:557:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodej
s\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Mybot\guidebot\guidebot\node_modules\integer
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of bufferutil@^3.0.3 but none is inst
alled. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of erlpack@discordapp/erlpack but non
e is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of node-opus@^0.2.7 but none is insta
lled. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of opusscript@^0.0.6 but none is inst
alled. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of sodium@^2.0.3 but none is installe
d. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.7.3 but none
is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of uws@^9.14.0 but none is installed.
You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install:node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AppData\Roaming\npm-cache_logs\2018-09-03T04_50_25
243Z-debug.log
There is no way to make a command for DM, even if "guildOnly: false". In the console nothing shows up.
if(message.channel.type == "dm") { console.log("Dm is working") }
Hey!
So, there are the perm levels, as defined in config.js, right? What if there were perm levels that checked for individual permissions? I know this can be done with code in the command itself, but what I'm looking for is a command that will run based on if they have a certain permission as defined in the exports.conf section. I made a makeshift example that doesn't actually work.. sort of. It works in that it doesn't show up in the help command if the user doesn't have the permission defined, but it doesnt work in that the command will still be run even if the user doesn't have the permission. Here's the code:
File: config.js
// This level is actually a permission checking level. Use this for when you want to
// check if the user has a certain permission
{ level: 1,
name: `Permission Check`,
check: (message, cmd) => {
try {
if(message.member.permissions.has(cmd.conf.requires)) return true;
} catch (e) {
return false;
}
}
},
File: addemote.js
module.exports.run = (client, message, args) => {
var emojiName = args[0];
var emojiURL = args[1];
if (!emojiName) return message.channel.send(`:x: You forgot the emoji name!`);
if (!emojiURL) return message.channel.send(`:x: You forgot the emoji url!`);
message.guild.createEmoji(emojiURL, emojiName, null, `${message.author.tag} created emoji ${emojiName}`)
.then(emote => {
message.channel.send(`:white_check_mark: Emote **\`${emote.name}\`** ${emote} created!`);
})
.catch((err) => {message.channel.send(`:x: Something went wrong:\n${err}`);});
};
exports.conf = {
enabled: true,
guildOnly: true,
aliases: [`ae`, `addemoji`, `createemoji`, `createemote`],
permLevel: `Permission Check`,
requires: `MANAGE_EMOJIS`
};
exports.help = {
name: `addemote`,
description: `Adds an emoji to the server`,
usage: `addemote <name> <url>`,
category: `Server`
};
I'm not real clued in on the whole github thing, but post install configuration fails because in line 5 of setup.js it has:
let baseConfig = fs.readFileSync("./util/setup_base.txt", "utf8");
but it should be:
let baseConfig = fs.readFileSync("./installer/setup_base.txt", "utf8");
Since moving to the new friendly permission levels, when you DM the bot a command it crashes with the following error
Uncaught Exception: TypeError: Cannot read property 'owner' of null
at Object.check (C:\Users\YorkAARGH\Documents\GitHub\guidebot\config.js:45:40)
at Client.client.permlevel.message [as permlevel] (C:\Users\YorkAARGH\Documents\GitHub\guidebot\modules\functions.js:19:24)
at module.exports (C:\Users\YorkAARGH\Documents\GitHub\guidebot\events\message.js:32:24)
at emitOne (events.js:115:13)
at Client.emit (events.js:210:7)
at MessageCreateHandler.handle (C:\Users\YorkAARGH\Documents\GitHub\guidebot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\YorkAARGH\Documents\GitHub\guidebot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:102:65)
at WebSocketConnection.onPacket (C:\Users\YorkAARGH\Documents\GitHub\guidebot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:325:35)
at WebSocketConnection.onMessage (C:\Users\YorkAARGH\Documents\GitHub\guidebot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:288:17)
at WebSocket.onMessage (C:\Users\YorkAARGH\Documents\GitHub\guidebot\node_modules\ws\lib\EventTarget.js:103:16)
@eslachance
Steps to reproduce:
This also applies to the class-based branch.
So I put my id in ownerID but when I try to use an owner command it tells me
You do not have permission to use this command.
Your permission level is 0 (User)
This command requires level 10 (Bot Owner)
Any Ideas?
First section in README.md
contains a broken link to the repository which seems either has been removed or set to private.
This command handler is 98% compatible with my selfbot
Multi language support, and change the using discord.js from v11 to v12.
Hi, I tried to login to the dashboard on localhost
and when I authorized my application for oauth (i had the local host url included in the oauth section of the app) and I received an error on the /callback
page and when I try to manually authorize it from the developers page and login through there it says UNKNOWN_ERROR
. Am I able to get help on this???
I want to create a staff
role that is level 1. Right above User. I tried doing this twice and it didn't work. I tried editing the config.js file to this and it didn't work. I made a new bot, edited the config.js file to the same code, before using the conf command, and it did not work.
Could I get some assistance to how to add a new role and permission? Thanks in advance.
(node:230) UnhandledPromiseRejectionWarning: TypeError: client.loadCommand is not a function
at /home/runner/testing/index.js:26:29
at Array.forEach ()
at init (/home/runner/testing/index.js:24:12)
(node:230) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:230) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
To be honest i don't know if the problem is with the command handler, but i tried to make one using the guide, but when i try to use the command "+ping" i don't get a response
const fs = require('fs');
const Discord = require('discord.js');
const Enmap = require('enmap');
const client = new Discord.Client();
const config = require('./config.json');
client.config = config;
fs.readdir("./events/", (err, files) =>{
if(err)return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`Loading: ${eventName}`);
client.on(eventName, event.bind(null, client));
});
});
client.commands = new Enmap();
fs.readdir("./commands/", (err, files)=>{
if (err) return console.error(err);
files.forEach(file=>{
if(!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
console.log(`Loading ${commandName}`);
client.commands.set(commandName, props);
});
});
exports.run = (client,message,args)=>{
message.channel.send("Ping").catch(console.error);
};
module.exports = (client, message) => {
if (message.author.bot)return;
if(message.content.indexOf(client.config.prefix)!==0)return;
const args = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
const cmd = client.commands.get(command);
console.log("yes");
if(!cmd) return;
cmd.run(client,message,args);
};
hello, new installation. read guide, in config.js add ownerid and token, try start got that:
node index.js
/home/neoll/guidebot/index.js:9
const { promisify } = require("util");
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
This does not work on zeit.co docker NOW it chucks up a big number of errors. The website is https://zeit.co And I did it after installing discord.js
When I try to use the say command the console returns this error:
(node:10380) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): DiscordAPIError: Cannot send an empty message
(node:10380) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
even when I writte something for the bot to copy
hi there, i have just got your bot and i get this error in the console:
ERROR Unhandled rejection: TypeError: event.bind is not a function
can anyone help.
Similar issue to #64 where I am getting the following error when a user responds to a DM sent by the bot:
Uncaught Promise Error: TypeError: Cannot read property 'me' of undefined at module.exports.run (C:\Users\MarcT\WebstormProjects\Discord-Bot\events\message.js:17:55) at Bot.client.on.args (C:\Users\MarcT\WebstormProjects\Discord-Bot\index.js:191:45) at Bot.emit (events.js:159:13) at MessageCreateHandler.handle (C:\Users\MarcT\WebstormProjects\Discord-Bot\node_modules\discord.js\src\client\websocket\ packets\handlers\MessageCreate.js:9:34) at WebSocketPacketManager.handle (C:\Users\MarcT\WebstormProjects\Discord-Bot\node_modules\discord.js\src\client\websocke t\packets\WebSocketPacketManager.js:103:65) at WebSocketConnection.onPacket (C:\Users\MarcT\WebstormProjects\Discord-Bot\node_modules\discord.js\src\client\websocket \WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (C:\Users\MarcT\WebstormProjects\Discord-Bot\node_modules\discord.js\src\client\websocke t\WebSocketConnection.js:296:17) at WebSocket.onMessage (C:\Users\MarcT\WebstormProjects\Discord-Bot\node_modules\ws\lib\event-target.js:120:16) at WebSocket.emit (events.js:159:13) at Receiver._receiver.onmessage (C:\Users\MarcT\WebstormProjects\Discord-Bot\node_modules\ws\lib\websocket.js:137:47)
Which refers to the following:
// Cancel any attempt to execute commands if the bot cannot respond to the user. if (!message.channel.permissionsFor(message.guild.me).missing("SEND_MESSAGES")) return;
If I step pass this by commenting it out, the bot is then left in a state where it is unable to respond to the user, leaving no error behind either.
switch with:
const sorted = myCommands.sort((p, c) => p.help.category > c.help.category
? 1 : p.help.name > c.help.name && p.help.category === c.help.category
? 1 : -1
);
Whats the difference between this and https://github.com/AnIdiotsGuide/guidebot-class
I have recently noticed that some of my commands were not showing up in the help command list, I recently found out what was causing it. If you use a permissions number instead of its name, for example for a number "permLevel: 1" having it as a number makes the command not show up in help except the command still works fine... I fixed it by using the roles name, "permLevel: "User". Sorry if this is terribly explained...
P.S. I haven't tried much to fix this myself as it hasn't effected me to much.
hey, so I've got everything installed from the requirements and when I try to start the bot I get this how could I fix this?
Expected behavior
When running the eval
command, the output replied by the bot censors every instance of the bot token.
Actual behavior
Only the first instance is censored.
Reproducing
!eval `${client.token} ${client.token}`
This is not an issue but a question. I want to know how I can create more settings.
prefix, modLogChannel,modRole, adminRole, systemNotice, welcomeChannel, welcomeMessage, welcomeEnabled
These are the default settings for guilds. I want to add more settings. How can I do that?
I tried adding those settings in defaultSettings
in setup.js
file. But that didn't work.
Thanks in advance!
PS: The Discord Invite link in the repo's CONTRIBUTING.md
is invalid. This made me open an issue.
Hi there! How do I fetch/grab a mentioned / otherwise selected (other than the message author) user's level? I'm trying to make a dynamic whois command that shows something different for level 8,9,10 users.
Any help is greatly appreciated! Thanks!
title says it all
I noticed there is no message when you use command that doesn't exist (or misspell one that does), and I think it should be included by default. I know how to do this and would like to contribute to this project, what do you think?
I created a discord.js bot link is below
https://github.com/RootAndroid58/Azooid-bot
how can i import this web dashboard to my bot ?
copied dashboard folder and dashboard.js file how do i link it to my discord.js bot?
After upgrading and migrating to enmap v4 using the latest commits, I noticed I couldn't DM the bot anymore.
TypeError: Cannot read property 'id' of null at module.exports (/var/nodejs/guidebot/events/message.js:12:72) at emitOne (events.js:116:13) at Client.emit (events.js:211:7) at MessageCreateHandler.handle (/var/nodejs/guidebot/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34) at WebSocketPacketManager.handle (/var/nodejs/guidebot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65) at WebSocketConnection.onPacket (/var/nodejs/guidebot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (/var/nodejs/guidebot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17) at WebSocket.onMessage (/var/nodejs/guidebot/node_modules/ws/lib/event-target.js:120:16) at emitOne (events.js:116:13) at WebSocket.emit (events.js:211:7)
This led me to message.js. message.guild.id
was null, obviously since it was a DM.
const settings = message.settings = client.getSettings(message.guild.id);
It might not be the prettiest solution, and I'm totally not ruling out something wrong on my end, but this worked for me.
const settings = message.settings = client.getSettings(message.guild ? message.guild.id : "");
Navbar does not open on mobile.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.