Coder Social home page Coder Social logo

discord.js-bot-development's Introduction

Discord.js-Bot-Development

discord.js-bot-development's People

Contributors

stanbarkmeijer avatar the-sourcecode 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

discord.js-bot-development's Issues

Kick and Ban command not working

Kick and Ban commands are not working when we use kick or ban command the console says :
(node:72728) UnhandledPromiseRejectionWarning: TypeError: promptMessage is not a function
at C:\Users\Husnain-Ayesha jatoi\Desktop\Nain Bot\commands\Moderators\kick.js:76:33
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.run (C:\Users\Husnain-Ayesha jatoi\Desktop\Nain Bot\commands\Moderators\kick.js:74:9)
(node:72728) 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(). (rejection id: 2)
(node:72728) [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.
Please Fix this

Changing promptMessage to respond to text instead of reactions

I have been trying to alter the promptMessage function to work when a user responds by message instead of by an emoji reaction. I feel like I have done pretty much everything right except it keeps telling me that message isn't defined in the function.

To give more specifics, I dont have the kick/ban command in it anymore or the rps command. The command that uses this is loosely based on the rps command but is asking for answers from an array.

Any help would be greatly appreciated!

TypeError: Cannot read property 'toLowerCase' of undefined - Episode 2

I'm extremely new to JavaScript and Node.js so this could just be me being unaware of something but I am having an issue with the say command. When ever I try to use the command, the command message deletes fine but the bot doesn't send a message at all. When checking the logs, I have this error.

I have tried checking over the code for the bot and even gone as far as copying the code from this repo but to no avail so if someone knows what I may be doing wrong or needs some more info then let me know :)

Prefix Error (SOLVED!)

The following part ;-
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;

let prefix = botconfig.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);

let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot,message,args);

});
contains "cmd.slice(prefix.length)" due to which no matter what you type within the length of actual prefix the command always works. This happens because my prefix length is equal to (any random two characters).
Consider an example ;- "t!ping instead of x!ping("x!" is my prefix), the command will still work with "t!").
Any idea on what can be used instead of that so if i use other bot my bot doesn't respond due to same prefix problem?

seperate

Why not seperate all the code into different branches?

My bot responds to any prefix???

const Discord = require('discord.js');
const bot = new Discord.Client();

const token = '(token taken out for obvious reasons)';

const PREFIX = '.';

var version = '0.420.69'

bot.on('ready', () =>{
console.log('Slurp Bot is now online!');
})

bot.on('message', message=>{

let args = message.content.substring(PREFIX.length).split(" ");

switch(args[0]){
    case 'website':
        message.channel.send('https://www.coolmathgames.com/')
        break;
    case 'info':
        message.channel.send('Version ' + version);
        break;
    case 'purge':
        if(!message.member.hasPermission("PRIORITY_SPEAKER", explicit = true)) return message.channel.send('You do not have permission to execute this command!')
        if(!args[1]) return message.channel.send('Please send an amount of messages to delete!')
        message.channel.bulkDelete(args[1]);
        break;
    

}

})

bot.login(token);


Okay, so my bot responds to any prefix... The prefix I use is "." so I should do .(command) for it to work right? no. I can do anything; f(command) y(command) ?(command). Any help? I am a complete noob to this.

(For the screenshot, Slurp-Bot's prefix is ";" and Slurp-Test-Bot's prefix is ".")
poop

why

ur code sucks so do u cuz u banned me from the sourcecode but why let the let command is fing sucks cuz when i tried it aint know wha it is

pay.js episode 16

Paying yourself allows for infinite coin duplication, resulting in a broken economy. Fix: Add the line if(pUser === message.author.id) return message.reply("You can't do that! That's ILLEGAL")

Edit: Also there is a typo in console.log . It says cosole.log not console.log

Fortnite command just won't work ;-;

**PS C:\Users\AsrieltheGoat\Desktop\bot> node index.js
.---------------------------.

Commands
Command
-------------
fortnite.js
hmm.js
love.js
meme.js
rps.js
help.js
info.js
ping.js
whois.js
ban.js
clear.js
kick.js
report.js
say.js
'---------------------------'
Hi, A********* is now online!
(node:6532) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toLowerCase' of undefined
at Object.run (C:\Users\AsrieltheGoat\Desktop\bot\commands\experiment\fortnite.js:19:21)
at Client.<anonymous> (C:\Users\AsrieltheGoat\Desktop\bot\index.js:51:17)
at Client.emit (events.js:210:5)
at MessageCreateHandler.handle (C:\Users\AsrieltheGoat\Desktop\bot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\AsrieltheGoat\Desktop\bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (C:\Users\AsrieltheGoat\Desktop\bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\AsrieltheGoat\Desktop\bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\AsrieltheGoat\Desktop\bot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:210:5)
at Receiver.receiverOnMessage (C:\Users\AsrieltheGoat\Desktop\bot\node_modules\ws\lib\websocket.js:789:20)

(node:6532) 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(). (rejection id: 1)
(node:6532) [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.**

Here the error message
I think there is something wrong with ur code ;-;
I spend a day to troubleshooting ur code but nothing change ;-;

Tutorial 4 - Some errors in console when user with no rights try to kick someone

Hi. Im usually testing some cases when or after i watch your videos. One of the cases is when user without .hasPermission('MANAGE_MESSAGES') try to kick someone the line
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.search('No can do pal!');
does not return message in the channel. Instead of it prints out message at console:

(node:12024) DeprecationWarning: TextBasedChannel#search: userbot methods will be removed
(node:12024) UnhandledPromiseRejectionWarning: DiscordAPIError: Bots cannot use this endpoint
at item.request.gen.end (C:\Users\xxxx\Desktop\DiscordBots\Project2501DiscordBot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:79:15)
at then (C:\Users\xxxx\Desktop\DiscordBots\Project2501DiscordBot\node_modules\snekfetch\src\index.js:215:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:12024) 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(). (rejection id: 2)
(node:12024) [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.

idea kinda

just make them all like the same so we get it like in the tutorial videos

Addrole command.It's giving a role,but not writing a message when it's given

Code is:
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("Sorry pal, you can't do that.");
let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if(!rMember) return message.reply("Couldn't find that user, yo.");
let role = args.join(" ").slice(22);
if(!role) return message.reply("Specify a role!");
let gRole = message.guild.roles.find(name, role);
if(!gRole) return message.reply("Couldn't find that role.");
if(rMember.roles.has(gRole.id)) return message.reply("They already have that role.");
await(rMember.addRole(gRole.id));
try{
await rMember.send(Congrats, you have been given the role ${gRole.name})
}catch(e){
message.channel.send(Congrats to <@${rMember.id}>, they have been given the role ${gRole.name}. )
}
}
module.exports.help = {
name: "addrole"
}

i cant find

i canot find the xp commands nor the xp and i would love to have it

[ERROR]: (node:1632) UnhandledPromiseRejectionWarning: RangeError: RichEmbed field values may not be empty.

Index.js in .txt arrached.

Using this code(episode_4_code) i'm getting a error when trying to for example kick another user:

(node:1632) UnhandledPromiseRejectionWarning: RangeError: RichEmbed field values may not be empty.
at RichEmbed.addField (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\discord.js\src\structures\RichEmbed.js:165:34)
at Client.bot.on (E:#DeathKillerNOR Discord Bots\DeathKillerBot\index.js:86:6)
at Client.emit (events.js:187:15)
at MessageCreateHandler.handle (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (E:#DeathKillerNOR Discord Bots\DeathKillerBot\node_modules\ws\lib\websocket.js:137:47)
(node:1632) 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(). (rejection id: 1)
(node:1632) [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.
index.txt

Ep_15 Missing

You didn't add 15th Episode's codes! I need your Evaluation command to use it for implementation to my Discord.js bot!

Events, ep 10

You never added the code from ep 10 about events.

Package

pls add package.json and package.json thing.cause people are confuse

promptMessage function in episode 8 doesn't work

The rest of the source code seems to work fine, but upon caller the rps command, an UnhandledPromiseRejectionWarning runtime error is thrown. "promptMessage is not defined."
I'm not sure what other function would work in its place, or if it was defined somewhere else that I'm overlooking.

message.guild.channels.find is not a function

(node:24744) UnhandledPromiseRejectionWarning: TypeError: message.guild.channels.find is not a function

const { MessageEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");

module.exports = {
name: "report",
category: "moderation",
description: "Reports a member",
usage: "<mention | id>",
run: async (client, message, args) => {
if (message.deletable) message.delete();

    let rMember = message.mentions.members.first() || message.guild.members.get(args[0]);
    if (!rMember)
        return message.reply("Couldnt find that person").then(m => m.delete(5000));

    if(rMember.hasPermission("BAN_MEMBERS") || rMember.user.bot)
        return message.reply("Can't report that member").then(m => m.delete(5000));

    if(!args[1])
        return message.channel.send("Please provide a reason for the report!").then(m => m.delete(5000));
    
    const channel = message.guild.channels.find(c => c.name === "reports")

    if(!channel)
        return message.channel.send("I cound not find a `#reports` channel").then(m => m.delete(5000));

    const embed = new MessageEmbed()
        .setColor("#FF0000")
        .setFooter(message.guild.name, message.guild.iconURL())
        .setThumbnail(member.user.displayAvatarURL())
        .setAuthor("Reported member", rMember.user.displayAvatarURL())
        .setDescription(stripIndents`**> Member:** ${rMember} (${rMember.id})
        **> Reported by:** ${message.member} (${message.member.id})
        **> Reported In:** ${member.channel}
        **> Reason:** ${args.slice(1).join(" ")}`)
        .setTimestamp();

    return channel.send(embed);
}

}

Nodejs v12 Updates

I have come across the YT videos and Github information but using Nodejs V12. There are quite a few areas where I ran into debugging issues with command changes in the versions.
It would be nice if these were updated for future people to minimize confusion.

24th epesoide.

Ik its probably out or smth but I just need some few functions of it.. why isnt it in deprecaded code or a normal epesoide?

Error in warnlevel.js

If there are no warnings in warnings.json then there will be an error in the console.
To fix this change the warnlevel.js into this:
`
const Discord = require("discord.js");
const fs = require("fs");
const ms = require("ms");
let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));

module.exports.run = async (bot, message, args) => {

if(!warns.warns) {
message.channel.send(new Discord.RichEmbed()
.setDescription("There are no warnings")
);
return;
};
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply("You can't do that.");
let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if(!wUser) return message.reply("Couldn't find them yo");
let warnlevel = warns[wUser.id].warns;

message.channel.send(new Discord.RichEmbed()
.setDescription("Warning Information")
.setColor("#c40000")
.addField("Member", <@${wUser.id}>)
.addField("Amount of Warns", warnlevel)
);
}

module.exports.help = {
name: "warnlevel"
}
`

episode 4 is online but when i write command....

(node:3056) UnhandledPromiseRejectionWarning: ReferenceError: arg is not defined
at Client. (/Users/studio_1/Desktop/discorbots/ban/index.js:37:17)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (/Users/studio_1/Desktop/discorbots/ban/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/studio_1/Desktop/discorbots/ban/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/studio_1/Desktop/discorbots/ban/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/Users/studio_1/Desktop/discorbots/ban/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/Users/studio_1/Desktop/discorbots/ban/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/Users/studio_1/Desktop/discorbots/ban/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (/Users/studio_1/Desktop/discorbots/ban/node_modules/ws/lib/websocket.js:801:20)
(node:3056) 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:3056) [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.

Embed color doesn't change from black to white.

I used part of the code that was used for the embed color in the whois.js file in episode 4,

member.displayHexColor === '#000000' ? '#ffffff' : member.displayHexColor

but it doesn't seem to do anything at all, it just keeps the gray-ish color on the embed. How do I make it so it actually changes the color to white?

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.