#development
1 messages ยท Page 1015 of 1
clearly
i really dont understand what you mean
if your code is fine, and your token is fine, then there should be no problem
Test bot
dont use glitch or heroku
My internet is shit
My internet is shit
unless its on 100+ servers you wont be struggling on internet
Test bots you run on 1 or 2 servers max, i cant see you capping your internet at all regardless of how shit it is
Ah glitch just blocked my project
cuz its shit
bottom line, dont use heroku or glitch
You cant force them to do anything
Bottom line is im using it for testing purposes
im not forcing you to use anything, im telling you a fact. glitch is shit
Everyone has their own views
@small prairie glitch is aggressively trying to stop people from hosting bots on it
Whats "client.user.setPresence({game:{name:status}});" for v12?
that's why it blocked http pingers
you can't host bots on glitch. the app isn't crashing cuz "its shit"
clearly its working out for u, using glitch
^^
@low phoenix setActivity
https://discord.js.org/#/docs/main/stable/class/ClientUser?scrollTo=setActivity
both clearly state in their introduction that they aren't for bots
^
if your bot doesnt need a lot of ram or cpu power, google has the f1 micro free thingies
1 year for free on google
and im still not sure if anyones used one yet
you could just stop before a year and renew it
the f1 micro is always free
Wait wait but theres....
hours are calculated off resource usage i think
so maxing a cpu for an hour, probably counts as more than an hour
but there's only 24 hours in a day how do you get 4 extra hours lmao
seems they run off traffic.
if you have a lot of traffic, it might spawn another instance and start handling requests
which is bad for bots
and whats change "message.reactions.get" to v12 i dont find it in Documation.
which is bad for bots
Not really Discord intents exist to cut traffic by a lot
running your bot twice
someone doing a command, would give you two command responses
im wondering if the 9 hours a day for the b instances applies to all their instances
@low phoenix message.reactions should already list all reactions
in the reaction manager
Hey guys on discord.py how would I set a command which means that owners can set their own prefix + Also set the bot in a specific channel of choice
prob need a database to save configs and do a per/guild check
You would have to code that yourself and use a database to keep track of guild data
Aight tnx
@opal plank "message.reactions.get" i find not it for the v12
@low phoenix its much easier if you tell me what you want to do with that get
you want to filter?
@opal plank i have a Vote Bot and it get the reactions for the winner
reactions.cache iirc
i just dont see why you would use cache instead of a collector
reaction collectors would be much better for what you are trying to do @low phoenix
@summer torrent @opal plank thanks
๐
message.channel.message.fetch?
yes
i think your missing a letter ๐ค
wait
your fetching a message
of the id
of the message you currently have
yes
why fetch what you already have
anyway, doing it this way sends extra queries. gets you closer to the query limit of discord
using a collector would save you some queries
precisely why i recommended reading this @low phoenix https://ptb.discordapp.com/channels/264445053596991498/272764566411149314/728351938617278494
how do i make a link in a msg!
example :
Click Here
that would redirect to a linl
how?
If you want to make the text clickable, you need to send it in an embed (or use a webhook) with the syntax [text here](url here)
For example, [Google](https://google.com/)
with the [] and ()?
yes
in a .setURL as welll?
.setURL is for the embed title. That's not the same thing.
Do you want to make the field title clickable, or field value clickable (aka the text under the field title)
i want the embed description, i changed my mind
Then you can use the syntax I showed above.
thank u
https://hasteb.in/asuqozih.php why spam the bot the else?
Whenever any user (including bots) sends a message, if the message content does not equal simple!invite, it reports that.
So if it does any of the cases, it's going to emit a new message created saying that same error, do it again and again.
That's called recursion.
that wont work at all
thats a great way to create a spam bot actually lmao
also to get ratelimited and banned
also .setColor requires i string if i recall
i may be wrong tho
nope, i was right
The way they've done it is fine.
which part of that will work?
the .setColor(0x<...>) or .setColor("<...>") are both fine.
interesting
also
you on v11?
cuz syntax for embed is Discord.MessageEmbed()
oh, right, its the guy who was trying to port his code
or how can i send a error messages when not work the command?
like i did an :hover css styling
I tried to delete the command and it's still here
like Working
@low phoenix why would the command not work?
its a simple send message event
check for permission
thats the only way it'd error
@opal plank when the bot not have permission to send in this channel crash the bot.
then check for permission before sending
@opal plank and how can i do that?
Why ist hasPermission not a function?
If client is an instance of Client, it's because it's not a method. If you want to check if the client has permission in a guild, use guild.me.hasPermission instead.
so or what do you mean?
prob not the best approach
while it works, it wont work all the time
that'll get you the permission it has on the guild
you'd wanna check for final channel permissions before it sends, in case of overwrites @low phoenix
also before "client.on('message', message => {"
I don't get it ๐ฉ
message doesnt exists before its emitted
@low phoenix
it has to be used after the event is emitted
const job = new CronJob("0 * * * *", function() {})
this should do something at 00 of every hour right?
My js bot is saying the guild has no channels in cache, how do i fix that?
Hi does anyone have good docker knowledge that could assist me real fast?
Getting this issue https://i.txj69.com/gEv6UjgNkf.png
any ideas?
@earnest phoenix wdym ideas
nvm lol forgot to pass in ctx
@earnest phoenix wdym ideas
@empty owl why it isnt working
but i forgot to pass in ctx in the async
Did you define ctx
isn't ctx supposed to be in the lightgreyhoodie();
@earnest phoenix I suggest a message handler not he less
isn't ctx supposed to be in the lightgreyhoodie();
@umbral estuary did it
i have a another prob now lol
@earnest phoenix dont hardcode your token on the bot, thats a -1000iq play
making it a variavle is too long
seen enough of tokens being leaked around cuz people hardcode their token
oh yeah
like what should i do?
can someone show me and example of putting it in a json file? im sorry im just new to this
Google "json files with python"
how can i fix no channels being in my discordjs bot cache
@warm cloud Uh?
Uh?
Uh?
uh
hi, does anyone know how I can remove the blue line when I click on it?
with css or html or something idk
that's :focus, try that
:foces
kk, lemme try
if border doesn't work, try outline

what did you put
hopefully it's not foces
outline works :D
yes netail, i dont like frontend web dev at all
i done css input:focus { outline: none;
and that works
That's basic stuff tho
i've only worked on frontend once before this, that time i gave up tho
frontend is cancer
๐ค apparently i bought my ryzen vps before they enabled cpu passthrough.
@quartz kindle
i bought it before it went public
you should be able to request it, i had to do the same on galaxygate
i opened a ticket and they enabled it for me
ill get a benchmark when it gets added
AES performance should be minimum 500mb/s
i dont really understand any of it.
im hoping its a magic performance increase for canvas
how are your disk speeds btw?
they are proportional to how much storage you have
i dont think it will impact canvas, AES is for cyptography, used in SSL and whatnot
shoot
ah not bad at all
someone on the 4gb plan was getting like 30% more speed
hm, I have this: ```html
<table class="table">
<thead>
<tr>
</tr>
</thead>
<tbody>
<div class="boxer">
<tr>
<th>
</th>
</tr>
</div>
</tbody>
</table>``` and for some reason, the table isn't going in the middle of the page ๐ค any ideas?
on galaxygate you get ~400mb/s, on contabo you get 100, on google compute engine you get 30 lmao
bruh
so 200+ is already better than many vps's out there
?
you want the table itself to be centered on a page?
give it display:block and margin:0 auto
the table
kk
that does this
css: css table { text-align: center; display: block; margin: 0 auto; } .boxer { display: inline-block; }
what
.boxer = div; table = white thing
idk jeremy about it being amazing, its pretty simple if u've got half an idea about what ur doing 
So this is hard for me to explain through text but I have an sqlite database with currency, I have a baltop command to show the top 5 global users in that database. I want to be able to do that serverwise (Discord.py) but I do not want to scan the entirety of the server.
you dont have a guild id column in the database? or any sort of per-guild data?
no, because the currency is global so I would have to have multiple if they are in multiple servers
then there is not much you can do
either you scan the database and try fetching each user to see if they exist in a guild, or fetch all members in a guild and check if they exist in the database
User A is in guild 1
User A is in guild 2
you'd have 2 A entries with different guilds, merge them into an array so you have users being in multiple shared severs,
SQL usually has methods for finding and dealing with duplicates
im assuming thats the reason why you arent using your database with guildid on it
no need for duplicates, you can have a relational table
yeah, I think it would take a while to scan the entire server for id's for servers like this and also I think it might break the api limits because it is scanning so much
relation tables work too
NoSQL > SQL
hm tim any ideas?
PostgresSQL >
@digital ibex do you want the table to be full width? because tables have 100% width by default
PostgresSQL >
@opal plank That's still SQL
then you need to manually set width
@ebon kelp im well aware
ah, that fixed it :D thanks
Postgres is the way to go
I prefer MongoDB
You can use JSONB to mimic NoSQL
mongo db is nosql
Which is what do for some stuff I store
is this moral support for coding or something?
yeah, thats why im confused
MongoDB = NoSQL, so what's confusing?
what u said, nosql > sql but then u say u prefer mongodb, and in my head. nosql > sql means 'sql is better than no sql' is how i interpreted it as
wat
Hek
> stand for bigger than
nvm lol, im just confusing myself
nosql bigger than sql
wtf is this chat
ya, im getting more confused
NoSQL > SQL
= I prefer NoSQL over SQL
= I prefer MongoDB (For example) over MySQL (For Example)
cool
It's not that hard to understand
idk man, i tend to confuse myself a lot
NoSQL is Json in most cases
you inverted bigger than and smaller than in your head
tim wym?
the simbols < and >
x > y
x is better/bigger than y
^
y < x
y is lesser/smaller than x
Hi, i'm making a role reaction system, and i save all the role reactions like this :
"MESSAGEID":{
"channelId":"messageChannelId",
"emojiRoleMap":{
"emojiName":["roleID"]
}
}```And i made a commande to create the role reaction, that saves temporarely the data as the name of "config". At the end of the command i add the reaction role to the role react storage file like this :
```js
reactionRoles[config.message] = {
channelId: config.channel,
emojiRoleMap:{
}
}```But as seen in the role react save example, the variable is supposed to have the name of the emoji. So how can i create a line in the "emojiRoleMap" property that has the name of the emoji (that i accesible on config.emoji) ?
You interpreted "nosql > sql" as "sql is better than nosql"
yeah
^
ooohh
Lol

anyone knows ?
xD
const Discord = require('discord.js')
module.exports = {
name: 'ban',
description: "this is a ban command!",
async execute(Discord, bot, message, args){
let member = message.mentions.members.first();
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
await member.ban(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
}
}
Hi, i'm making a role reaction system, and i save all the role reactions like this :
"MESSAGEID":{ "channelId":"messageChannelId", "emojiRoleMap":{ "emojiName":["roleID"] } }```And i made a commande to create the role reaction, that saves temporarely the data as the name of "config". At the end of the command i add the reaction role to the role react storage file like this : ```js reactionRoles[config.message] = { channelId: config.channel, emojiRoleMap:{ } }```But as seen in the role react save example, the variable is supposed to have the name of the emoji. So how can i create a line in the "emojiRoleMap" property that has the name of the emoji (that i accesible on config.emoji) ?
please...

hm, css table { text-align: center; display: block; margin: 0 auto; width: 50%; height: 130px; border-radius: 10px; background-color: black; } the background colour of the table doesn't change, any ideas?
thats me trying for 6 hours to make a good looking ban command
the rest of the css works
@digital ibex this isn't a server for css
@spare mirage no, make ur own.
chill
@digital ibex use HEX color code
it's for development
its related to bot development
@spare mirage whats the issue?
"no make ur own" lol ive been trying for 6 hours
There's a site that's called Stacks Overflow, which is really helpful @digital ibex
HTML and CSS are supported here too
@digital ibex use HEX color code
@hasty lotus y
guys
please
Hi, i'm making a role reaction system, and i save all the role reactions like this :
"MESSAGEID":{
"channelId":"messageChannelId",
"emojiRoleMap":{
"emojiName":["roleID"]
}
}```And i made a commande to create the role reaction, that saves temporarely the data as the name of "config". At the end of the command i add the reaction role to the role react storage file like this :
```js
reactionRoles[config.message] = {
channelId: config.channel,
emojiRoleMap:{
}
}```But as seen in the role react save example, the variable is supposed to have the name of the emoji. So how can i create a line in the "emojiRoleMap" property that has the name of the emoji (that i accesible on config.emoji) ?
holy shit this bump
i send 2 times...
ok, im gonna go over ๐ for now
@hasty lotus dont spam
You don't really need to repost your question multiple times
can anyone answer me ? ๐ฆ
not if you keep spamming
If someone knows an answer, they will help you

i'll purposefully ignore people spamming, just chill and we'll eventually get to yours
so uh cough
u dont need to always use the hex colour, u can just provide the colour name and it'll use that
btw
well try with hex
its not gonna change anything
@spare mirage whats the error that you're getting?
syntax errors
send error
different error now
u dont need to always use the hex colour, u can just provide the colour name and it'll use that
@digital ibex HEX, RGB, RGBA, Names
๐ edwin
@spare mirage use message.mentions.users.first()
?
insthead of message.mentions.members
ok
coding 100
RBG -> RGB xd
@spare mirage start using debugger, it'll send you to where the error is
how does debugger work?
im confused
server = ["1", "2", "3"]
sql = ["1", "2", "4"]
both = []
for x in server:
if x in sql:
both.append(x)
print(both)
This is what I came up with for the server rich and I think it is what I will stick with lol
@spare mirage https://code.visualstudio.com/docs/editor/debugging
this is an unevaluable tool for devs
imo thats useless
Wait, thats a secret
i've never used it because i've never had to use it
then you are doing it wrong
for me
would this work?```js
let member = message.mentions.users.first();
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
await member.ban(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
Someone's starting a war
well, i've just never had a reason to use it
server = ["1", "2", "3"]
sql = ["1", "2", "4"]
both = []
for x in server:
if x in sql:
both.append(x)
print(both)This is what I came up with for the server rich and I think it is what I will stick with lol
@zenith gazelle what's that supposed to do in your case?
is all im saying
Dev wars
console.logging everything im guessing, then try and error?
when you can use step debugging?
it checks the sql userids and the servers userids and if they match sets it to a both so that it will mark all users that are in the server and have money with my bot
and then it will sort by richest
I guess
is it discord.py?
I mentioned myself xD
@zenith gazelle how is your data actually stored?
any ideas ?
in an sqlite database
For some reason, message.mentions is undefined
but why xD
Start console logging things till you find out ๐ค
I think there is something wrong with my args const
const args = message.content.slice(PREFIX.length).split(/ +/);
add g
no
.split(/ +/g)
you don't need g for something like split
and still anyone for my question ? ๐ข
in an sqlite database
What was your question, again?
I think there is something wrong with my args const
const args = message.content.slice(PREFIX.length).split(/ +/);
@spare mirage this is ok
I was just trying to make a way to get the top 5 people based on balance in each server exclusively and not global
Pretty sure you can just sort when you query the database
doesnt it make
!ban @pale vessel REASON
!ban -@pale vessel - REASON
!ban - @ flazepe REASON
Oh, I think I'm starting to understand
Just console log and see what it makes @spare mirage
how? xD Im so tired
So, let's say, you have users 1 to 5 in server A, and users 25 to 30 in server B
If baltop is used in server A, leaderboard of users 1-5 is shown, but not users 25-30?
Why not query only balances for that guild?
I get the same error all the time...
Data is stored globally
O
I forget some people don't have balances guild by guild
well in this case juste make a forEach and if the user is a guild member add id, else skip
yes @slender thistle sorry for late response
Do you store currency in cache?
either you scan the database and try fetching each user to see if they exist in a guild, or fetch all members in a guild and check if they exist in the database
Well, Tim's message applies. The way I'd do it without caching is fetch all data and iterate over data entries, create a list of users, sort it, and then take the 5 highest entries
up
yup*
databaseids = []
serverids = []
bothids = []
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
cursor.execute("SELECT userid FROM main")
result = cursor.fetchall()
for x in result:
x = x.split(",")[0]
x = x.split("(")[1]
databaseids.append(x)
db.commit()
cursor.close()
db.close()
for x in ctx.guild.members:
x = x.id
serverids.append(x)
for x in databaseids:
if x in serverids:
both.append(x)
print(both)```this is what I am doing so far
Is that in your command
yes
Why are you creating a new connection with each command usage ๐ค
bot.commands.get('ban').execute(PREFIX, args, Discord, bot, message);
TypeError: Cannot read property 'execute' of undefined
why am I getting this error
Because the command ban is undefined
Dunno can't really see anything from that
Have you tried logging bot.commands.get('ban')
bot.commands.get('ban').run
That's not what the error is
what?
bot.commands.get('ban') is undefined
undefined
ahh
Does the key exist?
bot.commands.get('ban').run(PREFIX, args, Discord, bot, message);
}```
U mean this?
Yes, show how you add the commands to the collection
?
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}```
in index.js
do you even know your command file structure
I think that fixed it
Does every command file have the same structure?
no
config: { name: "ping"},
run:
Every command file needs:
module.exports = {
config: {
"name": <Name>
},
run: <Function>
}
what a mess
const Discord = require('discord.js')
module.exports = {
name: 'stats',
description: "this is a stats command!",
execute(Discord, bot, message, args){```
ayy fixed it
btw add, instead of instant adding to the collection
if (file.config.name) {
bot.commands.set(file.config.name, file);
} else {
console.log(`${file} is missing a name or is not string.`)
continue;
}
That's a different error
Hope someone else can help, cuz I'm going
gn
hi
So I have a bot with a point system and a coinflip command - how would one go to combine these two mechanics?
So that when you win a coin flip it gives you points?
you can give or take points
You'd need a database, then if it's heads add points to the user, if it's tails take them away
would a point system be considered a database?
yes
The points would be stored in the database, yes.
what would be the command to addor remove points
You'd have to write one.
I dont know how ur point system works
Do you use any type of database?
hey guys,
does anyone know how to disable fastforward in the youtube api?
not just hide controls
idk
I know how to hide it but not completely disable fastforward
hold on I have an example somewhere
if its a command make the command author only
as in
if message.author.id=="urUSEDid"))```
what
? then what are u making
Im using the youtube api to show a youtube video but I want to know how to prevent fast forward
so users must watch the video completely
I dont think this is the right place to ask this tbh
well on the plus side
im using this and using a discord application and then sending info to the bot
@spare mirage this channel isnt only for bot development
@winter basalt I know but this is mostly used for bots xD
okay so i trie to make a mute command. but it doesent reply anything or not showing any error. any helps?
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("message", (message) => {
const args = message.content.slice(prefix.length).split(' ');
module.exports = {
name: 'mute',
description: "this is a moderation command. it mutes members.",
execute(message){
var person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]));
if(!person) return message.reply("I CANT FIND THE USER " + person)
const mainrole = message.guild.roles.cache.find(role => role.name === "Members");
const role = message.guild.roles.cache.find(role => role.name === "Muted");
if(!role) return message.reply("Couldn't find the mute role.")
const time = args[2];
if(!time){
return message.reply("You didnt specify a time!");
}
person.roles.remove(Members)
person.roles.add(Muted);
message.channel.send(`@${person.user.tag} has now been muted for ${ms(ms(time))}`)
setTimeout(function(){
person.roles.add(mainrole.id)
person.roles.remove(role.id);
console.log(role.id)
message.channel.send(`@${person.user.tag} has been unmuted.`)
}, ms(time));
}
}})
i dont understand whats going on in this code bow
mute command
why is there a client.on in a command file
ok should i remove that
you have a command handler correct?
yes
then yes
ok done
you dont need any of it, client.on message, defining args outside the export
discord being required and the new client
umm ok
u just need to give them a role muted wich the bot makes
this is the code now
module.exports = {
name: 'mute',
description: "this is a moderation command. it mutes members.",
execute(message){
var person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]));
if(!person) return message.reply("I CANT FIND THE USER " + person)
const mainrole = message.guild.roles.cache.find(role => role.name === "Members");
const role = message.guild.roles.cache.find(role => role.name === "Muted");
if(!role) return message.reply("Couldn't find the mute role.")
const time = args[2];
if(!time){
return message.reply("You didnt specify a time!");
}
person.roles.remove(Members)
person.roles.add(Muted);
message.channel.send(`@${person.user.tag} has now been muted for ${ms(ms(time))}`)
setTimeout(function(){
person.roles.add(mainrole.id)
person.roles.remove(role.id);
console.log(role.id)
message.channel.send(`@${person.user.tag} has been unmuted.`)
}, ms(time));
}
}
you can define args in your command handler, and pass it like you pass message
execute(message,args)
like in the main code?
yeah
handeler
and in this code
does anyone know how to add a bot to a groupchat ๐
no
you cant
lol
Boeing
why not working
unless the bot accepting your friend request
Can you come in DMS
no
Ok
@delicate shore we actually need code to solve something xD
any error?
oh lol
just show the code ๐ฉ
we cant like solve the code from a message
ur message collector or whatever it is not working
ur message collector or whatever it is not working
@restive pebble
Yes I think so
it is
if(!message.member.hasPermission("BAN_MEMBERS") || !message.guild.owner) return errors.noPerms(message, "BAN_MEMBERS");
if(!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return errors.lack(message.channel, "BAN_MEMBERS");
let cmd = message.content.split(" ")[0].replace(PREFIX, ''); //used because command aliases
if (args[0] === "help") return message.channel.send(usage.fullHelp(bot, cmd));
let bUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!bUser) return errors.cantfindUser(message.channel);
if(bUser.id === bot.user.id) return errors.botuser(message, "ban"); //if bot return with function botUser()
let bReason = args.join(" ").slice(22);
if(!bReason) bReason = 'No reason given';
if(bUser.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return errors.equalPerms(message, bUser, "BAN_MEMBERS");
let banEmbed = new MessageEmbed()
.setDescription("~Ban~")
.setColor("#bc0000")
.addField("Banned user", `${bUser} with ID ${bUser.id}`)
.addField("Banned By", `<@${message.author.id}> with ID ${message.author.id}`)
.addField("Banned In", message.channel)
.addField("Time", message.createdAt)
.addField("Reason", bReason);
try {
bUser.ban(bReason);
message.channel.send(banEmbed);
} catch(e) {
let id = second.getError(e.message);
message.channel.send(`Unfortunately, an error occurred. Error ID: ${id}`);
if(!message.member.hasPermission("BAN_MEMBERS") || !message.guild.owner) return errors.noPerms(message, "BAN_MEMBERS");
TypeError: Cannot read property 'hasPermission' of undefined
i remember you having some issues with consistency.
Are you sure your sending params correctly?
yes
message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
what is this lol
ie
execute(discord, bot, message, args)
in index
and
execute(message, bot, discord,args)
message.mentions.members.first() || message.guild.members.cache.get(args[0])
only this
ok
promo for?
annnddd how is this related to development
The bot
bot.. promo code?
๐ค
Like this one
uh what
I dont see any errors here though
The icon is so like the same
message.mentions.members.first()||message.guild.members.cache.get(args[0])
whats wrong with that
it says undifined
how do I fix like bruh this command has taken me 9 hours
instead of?
let bUser =message.mentions.members.first()||message.guild.members.cache.get(args[0])
ok
if(!message.member.hasPermission("BAN_MEMBERS") || !message.guild.owner) return errors.noPerms(message, "BAN_MEMBERS");
^
TypeError: Cannot read property 'hasPermission' of undefined
using message.mentions can be unreliable
it means message.member is undefined. was the message sent in a guild?
no
lol
lets see that command handler ๐ค
oh I also just realized execute(Discord, bot, message, args)
let commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
let command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}```
a few of his commands are in other orders too
thats the command loader
not the command handler
if(message.content.startsWith(PREFIX + "ping")) {
bot.commands.get('ping').execute(Discord, bot, message, args);
}else if(message.content.startsWith(PREFIX + "image")) {
bot.commands.get('image').execute(Discord, bot, message, args);
}else if(message.content.startsWith(PREFIX + "stats")) {
bot.commands.get('stats').execute(Discord, bot, message, args);
}else if(message.content.startsWith(PREFIX + "purge")) {
bot.commands.get('purge').execute(Discord, bot, message, args);
}else if(message.content.startsWith(PREFIX + "ban")) {
bot.commands.get('ban').execute(Discord, bot, message, args);```
oh god
you must have copy pasted other bot commands
why would execute() work when you set the execute function as run()
someone can gimme idea for economy command ?
this is my economy command
@hazy sparrow just gimme idea like make roulette command or something
@marble geode betting
you could make a blackjack command
ok thanks for idea i will make that command after my bot approved :D
case'search':
if (!msg.member.voice.channel) {
return msg.channel.send('You need to be in a voice channel to search for music')
} else {
msg.channel.send(`Please choose a song (1-10)\n\n${VIDEOS.map(v => ++index + v.title).join('\n\n')}`)
}
try {
var response = await msg.channel.awaitMessages(m => m.content > 0 && m.content < 11, {
max: 1,
time: 30000,
errors: ['time']
})
} catch {
return msg.channel.send('Invalid search number or video')
}
const videoIndex = parseInt(response.first().content)
var newPlay = await searchYT(videoIndex - 1)
var pl = newPlay[0]
var ay = pl.url
msg.channel.send(newPlay)
break;```
im so done with my ban command
whats the discord web panel thing called again?
discord.dev
discord develeoper
just search that
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
discord developer portal
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
pls hekp with search command
or carl
-_-
whats the issue @delicate shore
dashboard ?
yes thank you!
whats the issue @delicate shore
@solemn latch
This
uh so laggy
It's not playing
I'm not very good at command handler
So can you see if there is a mistake with that
I'm not able to spot
@delicate shore we need code!
you need to do .then after awaitMessages
so it should be awaitMessages.then?
๐ค actually you can use await, i think you just have some things out of place
okk
i think all the stuff after the catch, and before the break need to be in the try statement
after awaitmessages
ye
lemme see
ok
can someone help me?
rn, your codes a mess imo
@solemn latch ```js
case'search':
if (!msg.member.voice.channel) {
return msg.channel.send('You need to be in a voice channel to search for music')
} else {
msg.channel.send(Please choose a song (1-10)\n\n${VIDEOS.map(v => ++index + v.title).join('\n\n')})
}
try {
var response = await msg.channel.awaitMessages(m => m.content > 0 && m.content < 11, {
max: 1,
time: 30000,
errors: ['time']
})
} catch {
try{
return msg.channel.send('Invalid search number or video')
}
const videoIndex = parseInt(response.first().content)
var newPlay = await searchYT(videoIndex - 1)
var pl = newPlay[0]
var ay = pl.url
msg.channel.send(newPlay) }
catch{
console.error(e);
}
break;```
just move
const videoIndex = parseInt(response.first().content)
var newPlay = await searchYT(videoIndex - 1)
var pl = newPlay[0]
var ay = pl.url
msg.channel.send(newPlay) }
into the first try
ok
after response
thnx
case'search':
if (!msg.member.voice.channel) {
return msg.channel.send('You need to be in a voice channel to search for music')
} else {
msg.channel.send(`Please choose a song (1-10)\n\n${VIDEOS.map(v => ++index + v.title).join('\n\n')}`)
}
try {
var response = await msg.channel.awaitMessages(m => m.content > 0 && m.content < 11, {
max: 1,
time: 30000,
errors: ['time']
})
} catch {
return msg.channel.send('Invalid search number or video')
}
try{
const videoIndex = parseInt(response.first().content)
var newPlay = await searchYT(videoIndex - 1)
var pl = newPlay[0]
var ay = pl.url
msg.channel.send(newPlay)
}
break;```
leme test this
@solemn latch it says missing catc
ye
catch or final cause
it would
there is
can someone help me?

ay thats pretty cool
just put it in the first one that was already made
@solemn latch Wait so i need to extend the first catch till the ed?
end*
oh
It is inside try
@strange trout ur lucky ur stuff works D:;
my brain
i am not getting anyhting
case'search':
if (!msg.member.voice.channel) {
return msg.channel.send('You need to be in a voice channel to search for music')
} else {
msg.channel.send(`Please choose a song (1-10)\n\n${VIDEOS.map(v => ++index + v.title).join('\n\n')}`)
}
try {
var response = await msg.channel.awaitMessages(m => m.content > 0 && m.content < 11, {
max: 1,
time: 30000,
errors: ['time']
})
} catch {
return msg.channel.send('Invalid search number or video')
}
try{
const videoIndex = parseInt(response.first().content)
var newPlay = await searchYT(videoIndex - 1)
var pl = newPlay[0]
var ay = pl.url
msg.channel.send(newPlay)
}
break;```
this is code
so you want me to
end the first try
after newPlay'
?
get rid of the second try you added
take the things that was inside that try
and copy it, then delete it
and paste it inside the original try
Ok
So
Final code must be this
Wait
@solemn latch then it will give same resrurn response
the issue is scope
Ok
@solemn latch will this work better?
const discord = require("discord.js");
module.exports = {
name: "ban",
category: "moderation",
description: "Ban anyone with one shot whithout knowing anyone xD",
usage: "ban <@user> <reason>",
run: async (client, message, args) => {
if(!message.member.hasPermission("BAN_MEMBERS")) {
return message.channel.send(`**${message.author.username}**, You do not have perms to ban someone`)
}
if(!message.guild.me.hasPermission("BAN_MEMBERS")) {
return message.channel.send(`**${message.author.username}**, I am do not have perms to ban someone`)
}
const target = message.mentions.members.first();
if(!target) {
return message.channel.send(`**${message.author.username}**, Please mention the person who you want to ban.`)
}
if(target.id === message.author.id) {
return message.channel.send(`**${message.author.username}**, You can not ban yourself!`)
}
if(!args[1]) {
return message.channel.send(`**${message.author.username}**, Please Give Reason To ban Member`)
}
let embed = new discord.MessageEmbed()
.setTitle("Action : Ban")
.setDescription(`Banned ${target} (${target.id})`)
.setColor("#ff2050")
.setThumbnail(target.avatarURL)
.setFooter(`Banned by ${message.author.tag}`);
message.channel.send(embed)
target.ban(args[1])
}
}
@solemn latch ```js
case'search':
if (!msg.member.voice.channel) {
return msg.channel.send('You need to be in a voice channel to search for music')
} else {
msg.channel.send(Please choose a song (1-10)\n\n${VIDEOS.map(v => ++index + v.title).join('\n\n')})
}
try {
var response = await msg.channel.awaitMessages(m => m.content > 0 && m.content < 11, {
max: 1,
time: 30000,
errors: ['time']
})
const videoIndex = parseInt(response.first().content)
var newPlay = await searchYT(videoIndex - 1)
var pl = newPlay[0]
var ay = pl.url
msg.channel.send(newPlay)
}
catch {
return msg.channel.send('Invalid search number or video')
}
break;```
try it @spare mirage
node:7428) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hasPermission' of undefined im getting an hasPermission error all the time
should work. your message collector responds to number
@solemn latch why is my code not working
wdym
console.log(message)
where do I put it
Yeh

woo why don't you put your bot ot top.gg
you are very good at ciding
coding
but its really just a proof of concept
I get this HUGEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE error https://hastebin.com/kicaduvuqa.rb
lol
it appears, your sending client in the position of message
?
if (!message.member.hasPermission("BAN_MEMBERS))
console.log(bot)```
@marble geode ?
if(!message.member.hasPermission("BAN_MEMBERS"))
I already have that
woo i changed the code
why you put this execute(client, message, args, bot)
for @solemn latch
client = bot
F:\Users\Edwin\Desktop\Banana\commands\ban.js:11
if(!message.member.hasPermission("BAN_MEMBERS")) {```
i told him to set it to bot, just until we figure out the order
the order shouldnt matter
oo
name: "ban",
category: "moderation",
description: "Ban anyone with one shot whithout knowing anyone xD",
usage: "ban <@user> <reason>",
execute(client, message, args, bot) {``` but im expoting right?
hey @solemn latch this has made my bot slow af
in executing of a function it does
possibly ๐ค
so now what shiuld i do ?/
or could be because of awaiting
oh
i cant go out of caps lmao
lmao
๐คทโโ๏ธ
that was weird
maybe discord decided to throw a fit
oh wait nvm
only search command is not working
as we have not done any return repsond
we have just logged it
lol
at i (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:6156)
at r (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1591)
at new Promise (<anonymous>)
at i (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1565)
at t.exports (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:12159)
at Client.<anonymous> (/app/index.js:481:24)
at Client.emit (events.js:196:13)
at MessageCreateAction.handle (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
(node:1055) 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: 3)
(node:1055) [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.```
ye
this is the error
@delicate shore you remake music bot from Zhycorp ?
no
F:\Users\Edwin\Desktop\Banana\commands\ban.js:11
if(!message.member.hasPermission("BAN_MEMBERS")) {``` woo the console logs this
ooo
yes
why not use YT_API ?
because ny bot is in 78 servers
you need links for ytapi
ooo
Music bots are really complicated
at i (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:6156)
at r (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1591)
at new Promise (<anonymous>)
at i (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1565)
at t.exports (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:12159)
at Client.<anonymous> (/app/index.js:481:24)
at Client.emit (events.js:196:13)
at MessageCreateAction.handle (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
(node:1055) 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: 3)
(node:1055) [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.``` @solemn latch
error
modules.export? i don't have a command handler
why tf is it saying that
everything uses modules in js
what does this even mean
[ '@spare mirage' ]
F:\Users\Edwin\Desktop\Banana\commands\ban.js:11
if(!message.member.hasPermission("BAN_MEMBERS")) {
^
TypeError: Cannot read property 'hasPermission' of undefined```
and
when you logged message, it was your client before
did you fix that
@solemn latch this is real error
at i (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1721)
at r (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1591)
at new Promise (<anonymous>)
at i (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:1565)
at t.exports (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/yt-search/dist/yt-search.min.js:1:12159)
at Client.<anonymous> (/app/index.js:653:33)
at processTicksAndRejections (internal/process/task_queues.js:88:5)```
console log your message again then
If you log message.member it'll log undefined
message.author?
^^^
nah I think I will ban myself
No, the issue comes from message not having the member property
Hence why it logs undefined
๐ค
ยฏ_(ใ)_/ยฏ
got the docs for the library your using @delicate shore i dont have it on hand
what part xD
Where you're running the command
the handler
u mean }else if(message.content.startsWith(PREFIX + "ban")) { bot.commands.get('ban').execute(Discord, bot, message, args);
disocrd.js
this?
discord.js i am using this
๐ค
you want docs ? @solemn latch
Issue is very obvious
my?\

