#development
1 messages · Page 777 of 1
Yep, was readded on the 20th, so you'll likely be waiting about a week to find out
why await
that code will check how many cached members (that aren't bots) each guild has and add them all together
which indeed could have the same user multiple times
What exactly do you want to do and why
I will get the total number of users on all servers. Then I will show this in the bot with setActivity
string.length()
Yeah all cached users oare on <Client>.users
@quartz hill ^
Alternatively you can use reduce on <Client>.guilds by their member count
Or any other loop
Reduce just came to mind
I mentioned 2 possible issues
If you simply use the size of the users you will cancel out the user dupe issue
But it's still cache only
If you use the membercounts of guilds you cancel out the cache issue
But you'll still have multiple users multiple times
The membercount will also include bots which isn't what you wanted originally
Either way, ask yourself why you want this
It's just a meaningless statistic
To get it accurate would probably require "wasting" resources in some way
which isn't worth it?
If you're not making it accurate, it becomes even more meaningless
there's really no point at all
I dont think someone cares if their count is inflated tbh
Looping through each user of each guild to check if it's a duplicate or bot is simply too inefficient for a large bot to get any real benefit
Can also be inaccurate at times
I've had it loop through before and duplicate guilds

Java Eclipse
I am following the 3rd option(Jar set up).
I have been using this website for help: https://github.com/DV8FromTheWorld/JDA/wiki/2)-Eclipse-Setup
I ran into a problem I ran into is, what file do I add the JDA-withDependencies-x.x.x_xxx.jar.
To module or classpath file?
Hi, how can I edit channel permissions for @eveyone role? discord.js
Help, please
Help, please, i really need
there should be a editPermission function
@neat vapor I would recommend using a package manager (Gradle/Maven) and not using the JAR
Gradle is amazing imo
I also used to dislike maven, but since I'm using it I started to like it a lot
After multiple days, I'm still getting this error:
https://canary.discordapp.com/channels/264445053596991498/272764566411149314/669999201777745923
What is the "best" data store for storing e.g. config? NodeJS orientated.
what kind of config
normal config or guild settings
guild settings, I would recommend using MongoDB
normal config, I would recommend YAML or JSON
Guild config
{ prefix, embed, etc... }
kinda stuff
Seems overkill using mysql database for this.
If the data is manageable, use a database (sqlite, mongo, rethinkdb) not including json. if it's constant, use json
@floral bloom if you do curl -I https://discordapp.com/api/v7/gateway in the terminal/command line your bot uses, does it say 200 OK?
don't you need to do -H'Authorization: Bot <token>' also?
nope
oh
at least not for that endpoint if it's just a get request
@sudden geyser Yes, it does. HTTP/1.1 200 OK
Okay, how are you connecting to the gateway (source code and stack trace)?
and what library are you using (along with version)
Discord.js v11.5.1
Okay, how are you connecting to the gateway (source code and stack trace)?
What do you mean? All I'm doing with the bot is logging in and trying to send a message.
I mean the source code where you call .login() (assuming it's logged in before you try sending a message). Are you sure you're using the client token and not the client secret
@sudden geyser I have the message function above the login function, however, I have never had a problem with it.
I use client.login(process.env.TOKEN); to login, and yes, I'm using the token.
I just don't know the problem, I'm doing everything the same as I normally do.
yeah you won't have an issue with the event listener being above or below
does logging process.env.TOKEN log your exact token to the console?
As far as I know, yes, but I will double check.
Yes, it does.
Ohhhhhhhh, I think I found the problem!
what was the issue?
client.user = require(`./users/${message.author.id}.json`);
client.user can't be written to, only read. 🤦♂️

Wouldn't it throw an error if you tried logging in (e.g. login is not a function)
also I tried that snippet now and I can't use my bot anymore so gg
No, because it logs it, but since I can't write to client.user it gives the 401 unauthorized error.
That's at the top of my message function, so no command works.
Now it works. 😂
Thanks for the help anyway. 🙂
excuse me are you making a json file for every user
@BotObject.bot.event
async def on_shard_ready(shard_id):
print(
f"[Client Running] - Shard: [{shard_id}] [Online] - Ping: {math.ceil(BotObject.bot.latency * 1000)}ms | {BotObject.bot.user.name} ({BotObject.bot.user.id})")```
actually less stable than discord
like
i just want it to fire
on shard ready
this was supposed to be patched
but noooooooooo
we cant possibly have it work for every bot token
only some
👏 👏
F
excuse me are you making a json file for every user
@mossy vine Yes.
JESUS CHRIST
WHY
you know how much fucking storage and Reads and writes that will use
jesus christ
tried a diffrent DB
and if you dont understand how
learn
cuz fuck me that is too far
I've tried MongoDB, SQL, SQLite, MySQL, RethinkDB, and others.
i think you might wanna try again

😞
Ok so my bot now consistently takes less than 1% cpu at all times with 880 shards... it’s all thanks to the upcoming gateway intents feature of discord api
880 shards. how big is your bot?
I just need to put some pretty interface on the intents stuff in aegis discord lib and I can submit a pr so all aegis users can benefit
Sorry, 880 guilds
Typoed
I hate using iPhone... the keyboard sucks compared to android gboard
If I had 880 shards it would be one shard per server lol, I have ten shards because it costs me no more CPU or ram than one shard, not noticeably any way
not all guilds will go on their own shard FYI
cuz discord dont do big balanace
Why should it
Each shard is limited to 2500
If it can balance well enough under that limit it'll be fine
yh
you have a spelling error
Ah lol
cosnt
np lol
Wtf is that unicode
🏝️ hmm palmtree
?
wow the unicode version looks terrible lol
Yup lol
Discord allows it by default
Wait how would I go about a delete message if swears command like I have a tempmute command and am creating a warn and music commands
don't bother with word filters
Wdym
I could just use a codelyon video I've gotten recomended videos by him but cant be bothered to watch them as i already know how to code
there's an insanely huge number of ways to bypass a filter with a 2000 char limit
its very satisfying having a command handler you built for memes work first time
Nice
Can Any Developer Who Is Good At Node,js Contact Me
I need help with mine
Plz
i need helop
Ok
So u have cmr
what
Cmd
https://www.npmjs.com/package/noswearing is this going to work in node.js/visual studio code
I want to copy there code into my bot
ok lol
Can Someone Help Plz
show the full error
You didn't install the module
lmao
@earnest phoenix you sent a link and I tried it and I tried to load my bot Umi Bot and I coppied full text and;
you didn't install the module
it literally tells you why
copypaste devs 
"MODULE_NOT_FOUND"
@earnest phoenix why does your bot request administrator perms 0_o
hmm
i also didn't provide the link to the filter package; I provided a message that tells you that no filter will ever be accurate in discord with over a billion different combinations
Oh
turtle > admin > *
guys i am getting this error while installing forever
https://i.imgur.com/K0LvLj5.png
run npm with sudo
sudo npm i forever @queen bone
fs doesn't need to be installed
It's a default package
oh wait I'm fucking blind
I Am A New Developer
Alright so I tried creating this code and I have a error
So Idk Much About This Things
I jsut want like a basic one that censors normal things like fck and sh*t
fuck
don't
Why thought I doubt anyone would go so far to use unicode just to swear
if you really want to have a filter don't let it do anything on it's own
instead notify a human and let them decide
npm i -g npm@latest @queen bone
context > static checks in filters
Honestly I want to try and block zalgo but like heck everything fails
was checking my code and found but it failed uswell half my code fails idk even why I have that ^^ must have been a second attempt that I didnt see lol
anyone know how to make a succsefull blocker for zalgo
@topaz fjord ah that helped, thank you so much 😘
^
imgur
Tbh the more restrictions you put in place on a chat app the more ways people will find to bypass it
I actually want to run a test to see how people finds ways around it
anyway I deleted my code for that and am forcing myself to finish my ban command thanks everyone
wait ... so bot won't detect blocked words if i strike them
bruh
that's also technically api abuse
the more restrictions and matches you try to find the more issues you may run into (e.g. normal words being blocked). just make it match exactly
amazing
Turtle
?
that makes no sense
you dont code to make it seem cool
you code to make it practical
Ask it here and someone will help
Ok
Do u know how to code like really good
@earnest phoenix pick up good habits and write performant yet clean code
is that not what you were asking
Nope
then what
What I was ment to say was is anyone professional at coding
are you searching for a collaborator on your project
we are discord bot developers, not professionals
He means like my code 
I'm like trying to get like a tutor
anyways what are you looking for
ohhhh
have you first tried googling things like "how to do x in y language"
or do you want to learn the fundamentals of coding
Funder mental of coding a discord bot ik how to code some things like websites
But I'm not that good at it
well man to be brutally honest, a lot of people are usually really unfriendly towards beginners but let me see
don't worry, i'm a no one but I like it 
definitely google will be your first step
so if something is unclear on anything you find while searching google, you can ask here
he is more like a frontend guy
on an additional note, cf8's code actually looks really wack because
- the console's first portion is repeating itself across all lines that log to the console (redundancy)
- its super blurry but your entire bot is in one file, which "good" code is across multiple files
and yes i saw that, he just wants to get started with some backend stuff
imho making a discord bot is a fairly ok way to get started learning about rest apis maybe, dont take my word on it
cog
command_handler
atom is just meh
¯_(ツ)_/¯
i prefer pycharm
same
What make this code great is the syntax highlighting.
atom is a text editor therefore less powerful smh
has anyone tried streaming music files from google drive ?
it is lagging for me
its pretty good for clojure
but pycharm & other jetbrains ides eat ram for breakfast
yh
so does chrome
Is pyphon good for coding vysion
atom themes are pretty notorious as well
oh yeah it is
i hear python is a pretty good beginner language
Ok
Ruby is beginner friendly too.
its pretty easy to get the basic idea of problem solving thinking with python
ruby is incredibly slow
it is easier but to feel it easier you have to learn a little difficult language
additionally it's for fast prototyping
but it does make people over-estimate their skill going from a basic project to an actual one
most devs start with javascript but python is somewhat median difficulty
@valid frigate Ruby is slow yes. But still beginner friendly lol.
once you get the hang of python you can dive into languages like c++ or c#
most devs start with javascript but python is somewhat median difficulty
why quote? it's true
thats how i started
I started with Visual basic.
vb is old so if you're older that would be the case
@valid frigate python and Clike languages are VEEEERYYYY different
That's 8 years ago.
CrunchyBot
just drag n drop files into cogs
n thats bout it
and yes
this bot is not called crunchy
but for some reason i name any running files <botname>bot
I am new to this and since invite manager is down I need help making a bot that tracks invites for my company server
any of these:
- wait for it to come back (if it does)
- check if there's an alternative on the website that offers the same feature
- or make your own by caching all the server invites, then checking which one is incremented upon member join to see which invite was used
Does anyone know the code to track invites
Well right now I am following this
NodeJS: https://nodejs.org/en/
Visual Studio Code: https://code.visualstudio.com/
Discord Developer Portal: https://discordapp.com/developers/
Permissions Calculator: https://discordapi.com/permissions.html
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
A small calculator that generates Discord OAuth invite links
seriously tho
wtf
why does this keep happening
servers randomly get dropped and re added all the time
it sucks because all of those servers then get spammed with the welcome messages
again and again
or they are spamming joining + leaving 
nah it always happens in batches
well, my best bet would be Discord
@rotund lance you need to check if the server is going unavailable
I would recommend having the guildUnavaliable/guildAvaliable events handy
no since my bot isn't big and doesn't get unavaliable events
The guild object should have an isavailable bool
well it does
in discord.js & eris, there is Guild#avaliable
in JDA there is Guild#isAvaliable iirc
ok so i have a text file and i want it to sat txt at the end how do i trn it on like the pic
it's just so annoying that discord drops the bots when a server goes unavailable
and then re-fires the server join event when the server is back
and it happens quick
like someone flicking the lights on and off
i hate this lol
I would recommend checking if the guild is avaliable then run your shit, else don't do anything

-Cd into your directory
-python3 [filename]
let everyone = message.guild.defualtRole
channel.overwritePermissions(everyone, {
VIEW_CHANNEL: false
Supplied parameter was neither a User nor a Role.
used to work
ig
whats the new way to deny @ everyone view channel
discord.js
"defualtRole"
channel.overwritePermissions(message.guild.id, {
VIEW_CHANNEL: false
})```
message.guild.id = everyone role
okay
how can i get the "BOT DEVELOPER" role?
I am busy with reading a JSON file, where there at the moment 8 items in it, the problem is i have a for loop now, but it doesn't count till 8 items, what is the problem im encountering?
var importedJSON = JSON.parse(body);
for(i = 0; i < importedJSON.length; i++){```
wait for approval
@pallid aspen what is the json structure like?
if the base key is posts then it should be importedJSON.posts.length
Yes i noticed, so dumb.... xD
:)
Thanks for the help 😛
Last little question, how can i do this command every 10 mins for example?
Cause to execute this command, i need to enter a message before it executes, but i'd like to execute it every 10 mins
is there any good ways to handle reading a string, then construct a regex and store it in a collection for caching with alot of regexes within a short time in node.js without the node process exceeding it's heap limit?
You do not have node.js installed?
I do
do node -v
Ok on node?
What?
On your console
Type node -v into your console
???
Command Promt?
Ok
What does node -v show then or what version are you on?
I've seen a friend of mine have that issue, and it was resolved by either restarting the computer (though I'd avoid that) or adding it to path or something. I'll search it up
Edit: is this useful? https://stackoverflow.com/a/28821955/11389072
What do you guys think about my bot description so far?
shouldn't it be will delete all roles
"Creating an Apex legends discord server never been that easy" could be, "Creating an Apex Legends Discord server has never been this easy."
Thanks.
Shall I restart all again?
@tiny tinsel Your bot description is a way better than some other bots I've seen, really good job so far :)
You should probably save your css/description somewhere just incase too since your bot is not approved yet :/
^
Thanks and I will save it right now.
jeeeez.... gateway intents are awesome
check out my cpu usage and bandwidth usage over the past half hour: https://sporks.gg/stats.html
if your library adds support for gateway intents, i suggest you make use of them ASAP.
my cpu usage is currently showing as 0% but the graph takes some time to settle
After retrying it, The bot still aint going online
@green kestrel what do you use for that
the graphs? users, channels, messages and guilds are done via chewey bot stats
cpu is done via a shell script and a mysql table
bandwidth is done by MRTG/SNMP
facts learned comes directly from the bot
theyre all drawn via chart.js
https://sourceb.in/74ef918f48
why is this not working right?
its suppose to create a transcript of a ticket
thank you
are you using handlers?
yes
it would be great to know what I messed up
We don't allow spoon feeding here
Xig one step ahead
That is true Xig
And just a fair warning don't say you'll only help someone if you get something in return
It's scummy
never asked to be spoon fed
I was told this is the best place to come to for this issue
thats why I am here
(node:6128) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received 'utf8'
The error says your problem right there: A function is requesting a callback function but you're passing a string to it
nevermind guys you are the best 😄
Or, we can say that the callback value should be a function and not a string
^
Yes I was just thinking that
so a CALL BACK to a FUNCTION
Is that to much info?
Lmao
That was me when I was noob
What language you code?
Same
Let's move to #memes-and-media
ty
Np I knew you were gonna say that
Does anyone know the coding used to track invites
So like this members has 4 invites
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
can someone help me i want to make a bot same as like luca
how do ye setup custom prefix for each guild??
database
no, using a real database
um?
mysql, mariadb, postgres, mongodb, cassandra are example of database
ooo thanks
sqlite is also a database if you dont want setting up a database server, but I would not recommend it if you plan to scale your bot
okie thanks!
If you wanna go even simpler, I got started using an INI file and the python.config module
If you bot will only ever hold small, trivial preferences for servers, I'd argue a simple INI or JSON file isn't a bad idea
hi can anyone confirm if the most recent patch of jda (100) is causing login issues
ive seriously tried just rebuilding my bot from a new gradle project in intellij completely but either way doesnt work
jda..?
no issues like that are reported on its github
d.js version?
12 dev
oh okay
They do
yes it's starting at 0 but you can add 1 (with + 1)
But what's the point
or you could do /1 instead of /2
Is it possible to add an anti spam for like a level system? If so, how?
@earnest phoenix what lib
discord.js
Okay, how about you log their last message
And save their date.now
and the next time they send a message
check if that the current date.now minus the saved date.now is greater or less than like 5000(5 seconds)
if that is true, continue with the process
@earnest phoenix
ok thx
your welcome
Sounds like you aren't checking if the object exist or not.
Why not send the line or two of code where it errored at?
Right
how are you running the command?
You are checking if it's undefined but also checking if there is a first element.
in your main file
You want to do if(!args.length)
^ cant read length of undefined
By checking the length, we can see if it has nothing inside the array.
Oh. Hmm
I guess they could be passing nothing.
I'm too used to TS at this point. 😦
if(!args) should be fine then
you have no args
You give it no args there.
Yes.
help me
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Lmao
did you only now find out that message links are a thing
One message removed from a suspended account.
One message removed from a suspended account.
no
One message removed from a suspended account.
if the redirect url dont have http or https it wont work
No.
I dont have 2FA active (yes im lazy to enable it), but still i can add my bot admin permission in oath2
auth
i mean my bot has admin perm too(no extra roles) and no 2FA enabled for me
so its not required.
@sage bobcat how i do it
let prefix = guild.prefix;
if(message.guild.id === '264445053596991498') prefix = "nep!"
const args = message.content.slice(prefix.length).trim().split(/ +/g);``` gives me `TypeError: Cannot read property 'length' of undefined`
prefix is not defined
is sharing only working with a index.js file?
is there a way to check if user has blocked dms?
Google exists
1-2 weeks
okey
so i started out with just a live and dev mode in my bot... so i can run with live or dev token.
i decided that if i needed to stress test i needed more than the 3 guilds the dev bot is in so i added a separate test mode.
test mode runs the bot with the live token but squelches all outbound messages and responses unless the message came from a test server, identified by its id.
can anyone think of any issues with that i may have missed? in short, when im running both test and live side by side no users can tell, because the test instance never answers them so i dont get double replies.
it does mean the bot double-replies on the test server, but the only one there is me and the bot
you can have a prefix as long as you like
personally i have mine as !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:missingSarcasmEmoji:
Brain could you share your code // examples of what you're doing? Is the bot replying twice to every message or something
edit: preferable a link
Just don't have common prefix
you can have one, it'll just be muted here for people who don't care
2 instances of the bot are running
@sudden geyser no its not, apart from where i tell it it can. im more seeking feedback on if this may be a bad idea for another reason. basically i made a way to run the live bot in a test mode so i can run it twice, but squelch the messages to stop multiple replies.
this works, and it doesnt reply twice
but i wanted to know if there are any gotchas from this approach, it was a convenient way to run a test bot on 880 guilds
without disrupting users
i already have another bot, with another token, but the dev bot is only on 3 guilds
so if i want to see how a change affects cpu usage on many more servers, i temporarily run in test mode instead
actually scratch that (what I just deleted)
so over at ovh, live sporks runs, 880 servers, replies to messages anywhere its addressed. in my cupboard, test sporks runs, 880 servers, replies to messages only on test but shares its token with live
theres a separate dev token i use when im not bothered about giving it a real world user load
make sense now?
kind of hard to explain
what i do is make the test script only answer to me
by checking my user id
i also give it a different prefix
ah
the only other thing i can think of thats bad is, if i do a booboo and get stuck in a loop, any bans etc will apply to live too as they share a token
so i have to be careful
basically test becomes step 2 in a 3 step process.... dev environment, there may be fundamental breakage... test environment, it shouldnt break... production environment
yes
why prefix.json
you literially can if prefix == prefix1 || prefix2
(thats not formatted right)
yes
bruh
you cant do prefix == prefix1 || prefix2
message content startswith i meant
unless prefix1 is something that may not exist, and prefix2 is the fallback
Tim you comfortable with gnome ?
actually not even then
I mean the example you used can be solved by just making it caps insensitive
if used in a comparison, prefix2 will always return true if prefix1 doesnt exist
@valid holly you mean gnome desktop for linux?
yep
havent used it in a long time
I'll DM you better, got a problem
i think you'd better google, i probably wont be able to help
show code
in code blocks please
sigh..
i already downloaded it
you are not kicking anyone
where is member.kick()?
Hi
I need a tutor
in what
@uneven wyvern I think you're talking about .longdescription .content
For creating bit
Creating what?
A bot
bot
I don't think you need a tutor for that
that's why tutorials and docs exist
I mean for me a tutor would help but ok
¯_(ツ)_/¯
what
con.query(`SELECT * FROM **** WHERE id = ('${message.guild.id}')`, (err, rows) => {
if(err) throw err;
let prefix = rows[0].prefix;
message.channel.send(prefix);
let sql
if(rows.id = empty) {
sql = `INSERT INTO *** (id) VALUES ('${message.guild.id}')`
}
con.query(sql,console.log);
});```
run INSERT if the XY GUILD ID is not found
that I could do it?
Empty is not something that exists.
You would have to check If rows[0] is null/undefined.
if(rows[0] = null) {
sql = `INSERT INTO prefix (id) VALUES ('${message.guild.id}')`
}```
it runs the same way if it is in sql
fieldCount: 0,
affectedRows: 1,
insertId: 0,
serverStatus: 2,
warningCount: 0,
message: '',
protocol41: true,
changedRows: 0
} undefined```
LOPPING
if (!rows[0]) sorry I was right the first time.
.addrole
You're using a space
So I need to do person.addrole
Same thing as removeRole.
person.addRole*
Except It is addRole.
@tiny tinsel ```
code: 'ER_EMPTY_QUERY',
errno: 1065,
sqlMessage: 'Query was empty',
sqlState: '42000',
index: 0,
sql: undefined
} undefined undefined
LOPPINGjs
con.query(SELECT * FROM **** WHERE id = ('${message.guild.id}'), (err, rows) => {
if(err) throw err;
let prefix = rows[0].prefix;
message.channel.send(prefix);
let sql
if (!rows[0]) {
sql = `INSERT INTO **** (id) VALUES ('${message.guild.id}')`
}
con.query(sql,console.log);
});
@still merlin Also setTimeout won't work If you're trying to mute the person for x amount of time.
the command is
!mute @user time and then after time expires they get unmuted
so that dosent make sence tbh i dont know what Im doing that was all I could fiugure out
It worked thanks :) my bot is online
@earnest phoenix Let me read something.
@earnest phoenix Ok I see It returns an array so.
YOu want ot check if the array is emtpy.
instead of rows[0]
if (rows.length === 0)
Also Id check If It exists before sending the message.
errno: 1065,
sqlMessage: 'Query was empty',
sqlState: '42000',
index: 0,
sql: undefined
} undefined undefined``` ```js
if (rows.length === 0) {
sql = `INSERT INTO prefix (id) VALUES ('${message.guild.id}')`
}```
@earnest phoenix I see because you no matter what you try to execute the query.
I have this issue I added a time but like my bot thinks I didnt my code is:
bot.on('message', message=>{
let args = message.content.substring(PREFIX.length).split(" ");
switch(args[0]){
case 'mute':
let person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]) )
if(!person) return message.reply("***__This user isnt found try again__***");
let mainrole = message.guild.roles.find( role => role.name === "Waiting");
let muterole = message.guild.roles.find(role => role.name === "muted");
if (!muterole) return message.reply("*Couldn't find the muted role*");
let time = args [2];
if(!time){
return message.reply("Please specify a time!")
}
person.removeRole(mainrole.id);
person.addRole=(muterole.id)
message.channel.send(`@$(person.user.tag) *has now been muted for $(ms(ms)time))}`)
setTimeout(function(){
person.addRole(mainrole.id)
person.removeRole(muterole.id)
message.channel.send(@$(person.user.tag) has been unmuted)
}, ms(time));
break;
}
})
put
con.query(sql,console.log);
In your condition ( if (rows...) )
talking to me?
@still merlin Please use ``````
Wdym
@still merlin https://support.discordapp.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-
Code blocks
your code would be a lot more readable if you use code blocks
I will screenshot
just put it in a code block please
You want me to code block everything containing `'s??
only show us the relevant code
His code
bot.on('message', message=>{
let args = message.content.substring(PREFIX.length).split(" ");
switch(args[0]){
case 'mute':
let person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]) )
if(!person) return message.reply("This user isnt found try again");
let mainrole = message.guild.roles.find( role => role.name === "Waiting");
let muterole = message.guild.roles.find(role => role.name === "muted");
if (!muterole) return message.reply("Couldn't find the muted role");
let time = args [2];
if(!time){
return message.reply("Please specify a time!")
}
person.removeRole(mainrole.id);
person.addRole=(muterole.id)
message.channel.send(@$(person.user.tag) *has now been muted for $(ms(ms)time))})
setTimeout(function(){
person.addRole(mainrole.id)
person.removeRole(muterole.id)
message.channel.send(@$(person.user.tag) has been unmuted)
}, ms(time));
break;
}
})```
there
Oh wow-
oo nooo
thanks
no problem
Wdym when I do !Mute user time it says add a time
for future reference starting your message with ``` and ending with ``` does that
because
its saying I didnt specify a time when I did
@still merlin Did you try to console.log(args[2]);
oh thanks
no problem
@tiny tinsel
I deleted the SQL contents ```throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'prefix' of undefined js
con.query(SELECT * FROM prefix WHERE id = ('${message.guild.id}'), (err, rows) => {
if(err) throw err;
let prefix = rows[0].prefix;
message.channel.send(prefix);
let sql
if (rows.length === 0) {
sql = `INSERT INTO prefix (id) VALUES ('${message.guild.id}')`
}
con.query(sql,console.log);
let prefix = rows[0].prefix;
message.channel.send(prefix);
});
restaring my bot now thnx
That doesn't matter though @delicate zephyr
@earnest phoenix does rows[0] exist?
I didn't even know either. I mean It is ugly though.
@still merlin You have 2 spaces after the mention btw, which is causing args[1] to be a space
you can use regex to fix that
@delicate zephyr I changed my args 2 to args2 and it didnt work
You have 2 spaces after the mention
@earnest phoenix That's why I said look If exists before getting the prefix.
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 termin ate the node process on unhandled promise rejection, use the CLI flag `--unhandl ed-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejecti ons_mode). (rejection id: 2) (node:13832) [DEP0018] DeprecationWarning: Unhandled promise rejections are depr ecated. In the future, promise rejections that are not handled will terminate th e Node.js process with a non-zero exit code.
Help Plz
@still merlin i'll move to dms
@earnest phoenix You are running your first query. Then you try to get prefix. Which doesn't exists.
done
Someone Help
@earnest phoenix
con.query(`SELECT * FROM prefix WHERE id = ('${message.guild.id}')`, (err, rows) => {
if (err) throw err;
if (rows.length === 0) {
con.query(`INSERT INTO prefix (id) VALUES ('${message.guild.id}')`, console.log);
}
let prefix = rows[0].prefix;
message.channel.send(prefix);
});
@earnest phoenix Most of us here dont know java
@earnest phoenix Part of your code where the problem occurs.
@tiny tinsel SEE DM
okay did it succeed how disturbing it is? ```Error: ER_EMPTY_QUERY: Query was empty
code: 'ER_EMPTY_QUERY',
errno: 1065,
sqlMessage: 'Query was empty',
sqlState: '42000',
index: 0,
sql: undefined
} undefined undefined```
works just any command i write this gives the console this trouble?
current code ```js
con.query(SELECT * FROM prefix WHERE id = ('${message.guild.id}'), (err, rows) => {
if(err) throw err;
let sql
if (rows.length === 0) {
sql = `INSERT INTO prefix (id) VALUES ('${message.guild.id}')`
}
con.query(sql,console.log);
let prefix = rows[0].prefix;
if (!message.content.startsWith(prefix)) return undefined; // így lesz jó a 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, con);
});
});```
I just sent something earlier
Look at the code Nathan posted and compare it with your own code
I will try to explain better. So you're running your first query.
You check if It is empty with the if condition.
What happens If it is not empty?
It will try to execute sql.
That is empty because it doesn't go through your condition.
con.query(`SELECT * FROM prefix WHERE id = ('${message.guild.id}')`, (err, rows) => {
if (err) throw err;
if (rows.length === 0) {
con.query(`INSERT INTO prefix (id) VALUES ('${message.guild.id}')`, console.log);
}
let prefix = rows[0].prefix;
message.channel.send(prefix);
});```
thank you now perfect
👍
Hi
Sup.
Who wants to partner up like create a bot together
Wat
javascript
anyways, message.mentions.first(); || message.author || what do i put here so you can search by name
Wat
replying to @digital ibex mate, don't worry
Why would you check for the first mention or message author?
probably <prefix><command> <args>
@digital ibex Anyways https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Thats not the best way to do it am i correct?
It is
@digital ibex what do i put here so you can search by name
thank you Nathan
Instead of author try .member
grab the member object then use the user object whenever
@tiny tinsel after one mistake comes the other because my stupid english is here the cause of the mistake https://youtu.be/IhH0MutPVEw
@digital ibex remove that semicolon
yea ik
@earnest phoenix What's the code?
It is hard to tell from a video what doesn't work.
bot.on("message", async message => {
con.query(`SELECT * FROM prefix WHERE id = ('${message.guild.id}')`, (err, rows) => {
if(err) throw err;
if (rows.length === 0) {
con.query(`INSERT INTO prefix (id) VALUES ('${message.guild.id}')`, console.log);
}
let prefix = rows[0].prefix;
if (!message.content.startsWith(prefix)) return undefined; // így lesz jó a 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, con);
});
});```
Instead of return undefined;
Just return;
if (!message.content.startsWith(prefix)) return;
But I don't think that's the problem.
@earnest phoenix Do you have a onJoin event?
no
if rows.length === 0, then there is no rows[0] and much less rows[0].prefix
?
what Tim is saying is
if there are no rows (rows.length === 0), then there are no rows
else get the prefix from that row (rows[0].prefix)
Oh yeah I forgot about that.
@earnest phoenix is your bot reacting to every message on the server ?
And you can fix the null pointer error
By editing the default prefix onJoin
yes
Basically whenever your bot joins a server write an SQL table with guild.id
Easiest way
I was about to explain him that but surely a little bit rushed today nathan
I told Hedi earlier to check when the rows is empty.
You might also want to cache the prefix for each guild, else you do a SQL call for every message you receive
But you will have to get the prefix from that query too.
^
I'm confused. There's a lot of information
Did anyone know this was a thing in dc?
yes
yes
it's been there since day 1
i didnt know that was a thing
Me neither

@valid holly @tiny tinsel I'm confused. There's a lot of information
ok
they just told you
How do you get that info @ruby talon ?
@blissful scaffold
https://i.gyazo.com/51540889474e19d1d48f4584ec05b041.mp4
keep this to #memes-and-media
thanks ^^
please
Channel for chatting about (bot) development. If you have questions, ask the questions and wait for someone who can answer to help you. Do not ask to ask. Provide all possible information so people know what's up. Just saying "I get an error" doesn't give us enough information on your problem. Do not @mention people randomly.
I know.
@vital lark he'll need a default prefix eventually
yes ur correct
if(rows.length == 0) {
let prefix = "prefixHere";
} else prefix = rows[0].prefix;
But fristly fix your message event
Your bot is reacting to every message
Even DMChannels
which are not part of a guild object
Define default prefix at top
how can i do that if the bot's joinola server is going to break the insert into
bot.on("message", async message => {
var prefix = "yourPrefix"; // Change yourPrefix to whatever prefix you want your bot to have as default
if(!message.content.startsWith(prefix) || message.author.bot || !message.guild) return;
});
Then
You can put the rest of the code reading SQL info
And change variable prefix accordingly to the guild's settings
I highly suggest you create a configuration for each guild when the bot joins

Had to
but then it won't work well ```js
if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send({embed: nyetEmbed});
if(!args[0]) return message.reply("Kérlek írd be az új prefixet");
con.query(`UPDATE prefix SET prefix='${args[0]}' WHERE id = '${message.guild.id}'`, (err, rows) => {
if(err) throw err;
});```
name: "setprefix"
}```
don't insert the arg directly into the sql statement.
That's prone to SQL injection
@valid holly https://img.ichigo.uk/8l3bewebqzwc.png #rules-and-info
I know well but it doesn't store any data
Gave him a bit I think that's fine
doesn't store any data
what does args[0] do then
I think they mean it doesn't hold any data at the moment (the db, which is still confusing as when it does, that's still risky). Like, what is going wrong exactly?
Confusing confusing confusing
Then it stores data
So it makes it open to Kinolite's statement
I suggest you to revise the JS, SQL docs and come back
sanitize 👏 your 👏 input 👏
ngl im pretty happy with how simple this command handler is for like 30 mins of coding
drag n drop into file and just customise from that template
n thats it
I like my command handler

ah yh
if we had decorators in go 
I should improve my command handler aswell
Only for arguments tho, I handle everything from the command file
don't know why but seeing __namehere__ makes me angry in syntax 
i mean that is the standard method for defining a global var in python or imports, can change but how i define anything that gets called from another file
^ or in classes
python is weird™️
yes
i need to make the Command handler order the help command by categorys
but thats gunna be annoying 😫
i just hardcode my help command lul
I've got a custom help command, although discordpy's is good I've got a link to in depth detail
many many things broken when getting the categorys and position index
i forgot you wrote the crunchyroll bot
Make a crunchyroll API for me for free pl0x
cuz of the crunchyroll update it not only killed their private API it also killed my one aswell
it crippled theirs and just oofed mine
i gotta rebuild all my websockets aswell
:(
Can someone help me in the right direction for the following:
I have a JSON file, and if a user is not in that list, the user wil lose his/her roles.
I already have the way if you are in the list of JSON that you get the role, but doing in in a reverted way, I don't know yet.
So in short: if (user.id != JSON file) { remove roles. }
And that for every user.
@pallid aspen Watch for file changes.
for the python boys, what the heck is here wrong?
@regal saddle are you using the commands extension or..?
Looks like someone overwrote the discord.py Client class
... or isn't using the Bot class instead
the latter sounding more legit
@client.command() or without ()?
Parentheses recommended (I don't remember if the commit that allowed the decorators to be called without parentheses passed)
I was about to say, (for me) outside a cog is @bot.command() and inside is @commands.command()
But you gotta use the commands extension for built-in commands system
You need parenthesis
im confused af
You wouldn't want to check every member the bot knows of to see if they have the role in order to remove? It could probably be more simple, but I think a before/after would be good so:
- Read from the file you're checking (the "after" file)
- Compare with a "before" file
- Anybody in the before but not the after needs their roles removed
- Have the data in "after" copied to "before"? @pallid aspen

cause admin > *



