#development
1 messages · Page 714 of 1
it's- not needed to programming?
it's not, but it can help you understand documentation more
and keywords in languages are english based, e.g if else do while
?
I'd learn english first cause most docs for programming is in english
docs means documents?
documentation, yes
oh
ok ok, i'll go back on that site (Discord server) if i eventually could do anything here..
for now it's not place for me
Does anyone know, when calling channel.awaitMessages multiple times on the same channel, whether or not the resolved/rejected promises can interact with each other? I have a command that uses awaitMessages and it seems like the promise rejections from earlier calls to awaitMessages are causing the more recent calls to trigger thier catch.
I looked over TextBasedChannel.js, MessageCollector.js, Collector.js, and Client.js and the only channel-based connection I see is that the MessageCollectors stores the channel id. I would assume the _timeout's in the Collectors that are set in Client shouldn't have any connection between them either. After almost three hours of tinkering and digging through discordjs's code, I'm at a loss. Is there some subtle nuance about how the references, in the execute function of my command object, work that I'm missing here?
For reference, the code is at https://github.com/mattacer/ProvablyFairBot/blob/feat/poker-command/commands/Gambling/poker.js. It works properly when the user uses text responses like 1,2 presumably because the awaitMessages promise is resolved so it goes to the then block and can't be rejected anymore to reach any future catch. The problem is when you spam the command using the ok_hand reaction to end the game. The awaitMessages promise continues waiting until the Collector end/timeout is called. So after about 60 seconds the bot starts ending the games almost immediately. The attached picture is what it's doing.
@vocal phoenix pokerGame appears to be a global variable
I must have accidently deleted the let or forgot it, either way I'm an idiot.
@quartz kindle yup that was it. Thanks Tim.
how to create a txt file on server
with bot
and also how to read that txt file
js
Need help on a reaction menu - Discord.js
MY CODE
n.on('collect', r => {
embed.setTitle(`Paginator help`);
embed.setDescription(`**•** :arrow_backward: goes to the previous page\n**•** :arrow_forward: goes to the next page\n**•** :wastebasket: deletes the whole message\n**•** :stop_button: stops the interactive pagination session\n**•** :information_source: shows this message`);
embed.setFooter(`Rhino - Multi Purpose Bot | Page ${page} of ${pages.length}`);
msg.edit(embed)
r.remove(r.users.filter(u => u === message.author).first());
})
When I do this the bots reaction gets removed & not the users reaction...
How to make the users reaction get removed?
const info = (reaction, user) => reaction.emoji.name === 'ℹ' && user.id === message.author.id;
const n = msg.createReactionCollector(info);
make sure you are declaring message, msg and the other things correct
And perhaps give them a name that clearly lets you and us know what they are
Check what r.users.filter(u => u === message.author).first() actually gives you
it removed the bots reaction when i react and not mine
Your mixed use of message and msg seems right so I'm thinking maybe your filter doesn't actually find the user for some reason
If the user filter I put above returns undefined it'll remove the default, which is your bots reaction
So maybe that's what's happening?
ammm ok
How can i update objects in mongoose?
like when i try to make an setprefix command, that when it already exists that it gets overwritten by the new prefix
if (message.isMentioned(client.user)) {
let mm = new Discord.RichEmbed().setAuthor(client.user.username, client.user.avatarURL).addField("Hello, my prefix is:", "--").setFooter(client.footer)
if (message.content.toLowerCase().includes("<@!")) {
var args = message.content
.slice(22)
.trim()
.split(/ +/g);
if (!args) {
message.channel.send(mm)
}
} else {
var args = message.content
.slice(21)
.trim()
.split(/ +/g);
}
if (!args) {
message.channel.send(mm)
}
}
why does this not work?
try catch to see if an error occurs, step through every if closure
do you not know how to debug?
split() always returns an array
Which even if empty, will still be seen as true inside your if statements
Meaning that because you invert them, that code will never be executed
at the start, before anything else, above let mm .. I put message.channel.send("test"), and that never even executed
You also shouldn't be using var unless you have a specific need that requires it
Your code actually makes use of that, possibly unknowingly
whats the Difference between let, var, const?
if (message.isMentioned(client.user)) {
let mm = new Discord.RichEmbed()
.setAuthor(client.user.username, client.user.avatarURL)
.addField("Hello, my prefix is:", "--")
.setFooter(client.footer);
if (message.content.toLowerCase().includes("<@!")) {
var args = message.content.slice(22).trim().split(/ +/g);
if (!args) {
message.channel.send(mm)
}
}
else {
var args = message.content.slice(21).trim().split(/ +/g);
}
if (!args) {
message.channel.send(mm)
}
}```
That's your code but slightly re-aranged
how to read /write in a .db file with bot
I don't think you meant the if and else statements to be ordered that way
args shouldn't actually exist in your last if, but it will because you used var
How do I get the total members of all the servers my bot is in?
You can go through all guilds and add the member counts but that will include dupes
So there isn't a thingy like guild count?
@astral meteor read the docs
client.guilds.size gets the guild count
there's client.users.size but that'll only be cached users
So unless you cache them all

awaitMessages expects a filter which should be a function
You're giving it args.join(" ") which is a string
Hence the error string and not a function
hello, is there some way to make a cooldown for reaction collectors? sometimes it's counted twice instead of once (discord.js)
especially in collectors with 2 users
oh god
you're adding messages to the array, not their contents
also
your method is async
stop using then
and mixing sync and async
how can i space out the fields?
Would that affect the message outcome?
lmao 
uh
My Bot wont turn on anymore.
Error: Something took to long.
(im using glitch.com)
tip: don't
check if you dont have an infinite loop somewhere
Heroku is gay to setup @earnest phoenix
@quartz kindle whats a loop, sorry for asking
i'm aware, i'm suggesting not to use free hosting in general
makes sense
an infinite loop is a piece of code that repeats indefinitely
most programming languages have several types of loops, such as for and while
Hey any .js developer can do partnership with me please dm me
@earnest phoenix Why you want an Partnership?
@fallow spire I want a partner with whom I can create a bot
I could help
dms
ok its laggin
discord probably being slow or you have something wrong
discord's api is having a stroke
then it's discord having a stroke
i need to run pm2 but bot not logging in 
discord's api is just having issues quit complaining
How to change the name and avatar of an web-hook on a command - Discord.js
🇫 🇺 🇨 🇰
Please just, just don't @earnest phoenix
@earnest phoenix take it to #memes-and-media
how do bots get ping/latency?
what
demonstration:
user: "!ping"
bot: "Pong! 24ms"
start a timer, send the message, stop the timer, edit the message with elapsed time from the timer
How can I see uptime in 2 shards
i tried to sent the txt to mentioned channel
but bot sending the text on current channel
🤦
and how are you getting the mentioned channel
What's a "cog"? Is this something discord.py specific?
Yeah, cog in discord.py is a separate file that may contain several classes of commands and events
It's easy to reload commands and events on the go with cogs
Yep
Why not just call it a module or a plugin, like everyone else?
Because python doesnt really have a unimport function
that would work the same way as a cog
If it exists
del all the way
>>> def yeet(): print('test')
...
>>> yeet()
test
>>> del yeet
>>> yeet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'yeet' is not defined
Can't you undefine a loaded module like you can undef one in perl?
Hey, discordapp has a api endpoint that goes like this: discordapp.com/api/v6/login, where you send the email and password of a user and get his token in return. i forgot the whole website url, can someone help me out here?
Yeah, in perl you can go:
use my::mod::name;
Then when you don't want it any more,
no my::mod::name;
It removes the module and any local variables in the namespace
as far as I understand how it works, del in python does the same
if (message.content === !7Brûle ${user.tag}) {
const embed = new RichEmbed()
.setTitle(${user.tag} est en train de brûler ${user.tag})
.setColor(#df913a)
.setDescription(${user.tag} est en train de brûler ${user.tag} sur une brochette)
.setImage('')
}```
What's wrong with my code ?
I'm pretty sure a garbage collector should automatically do that @slender thistle
Hm?
for deleting variables and stuff
Many things
In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Garbage collection was invented by John McCart...
Does such thing exist in python 
Yes
@lunar crystal for starters missing quotes around the string in 2nd line
Same on line 4 and 6
sup 🅱ruhgust
do u have an build.gradle file in the root directory
open the build.gradle and add this to the top of the file:
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
mk
you should have access to build fatJars
i've got the default that intellij made
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
group 'bruhmoment'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
tbh
ok
and do mainClassName = "Main"
u can make packages if u want (i.e: dev/august/libraries/uwu in src/main/java)
Gradle is easy to learn when you get used to it
it's definitely new to me 
do i
src/main/java/{stuff} -> java stuff
ok made
do i just slap everything into src/main/java or leave the main class under src/main
u slap everything in src/main/java
but if ur making a big project, it's recommended to do this: dev.august.libraries.uwu (or src/main/java/dev/august/libraries/uwu)
@valid frigate he's probs sleeping
Hi
Is there a way to list all users in every server the bot is in? Like grab the list and remove any duplicates?
Might seem like a weird question but yea
If there is, there's probably a way to list the user count too so ya
You'll need to make sure you cache every user
Cache, then list, then sort, something along those lines
I'll fiddle around later and see what I come up with
create an array
Iterate through every guild
iterate through every user
on each iteration if the user ID isn't already in the array, push the ID to it
after all the iterations are done, array.size if it's JS iirc
There might be a better way but this is the only one I've come up with 
I'll try that and post results when I'm home, thanks
👍
somehow that flew past my head

@vital lark It was a markdown misstake ^^'
^The issue you have is most likely that you're just creating an embed and not doing anything with it?
Hi
hi. Using discord.js I am trying to get user id, name and tag. The ID is working perfectly but username and tag won't show up but always be 'unidentified'
console.error('Der Admin hat was geschrieben. Tag: '+ message.member.tag + " und ID: "+ message.member.id);
I am getting the id, but not the tag. Am I missing something ?
Awesome, works. But why is username and tag listed in the doc? <.<
@modern sable ^
!ban @cursive stump x)
and an auctions tester too
Everyone using everyone should get instakickbankill and cut their internet connection off forever. Unless it is an important announcement :3
Y
how about you eat a ban
Maybe with salt

I want to know the number of servers my bot is on. Help me please. Discord.py
on js it is client.guilds.size
@fickle anvil in the docs there is not tag property on members, just on users https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=tag as you can see it doesnt scroll to anything
kay thx
so im currently using this and console.log(client.users) to grab/list all users in all the servers the bot is in, seems to work, now I just gotta do a size check and print usernames only, but i feel like I'm missing something
any idea?
client.on('ready', () => {
setInterval (function (){
var u, user;
for(u in client.users){
user = client.users[u];
if(user instanceof Discord.User) console.log("["+u+"] "+user.username);
}
}, 10000);
});
Why would you have this on an interval
if(user instanceof Discord.User) console.log("["+u+"] "+user.username);
Rip server as soon as it gets a large amount of users
d.jsdoes this for checking your client as well
It can be very useful
Then you'll never learn
later™
its hopefully gonna be changed to a on guild join, rather than interval, so it updates that way, then I can call for it at any time
currently working on auto-updating a single message or channel name with the usercount
How do I make a bot
#502193464054644737 last message
i need help with something developing a website for my bot, am i allowed to ask here?
its html and css related
nvm
@balmy lantern the name for a hyperlink? (Google for www.google.com) it has to be in an embed and you use Name
@here in discord.js, how to search for a channel by name, and if it doesnt exist, create a channel.
for finding it, i tried javascript guild.channels.find(<myservername>, <channelname>).sendMessage("Hello World!")
but it resulted in an error. i tried looking up the syntax for this, and wasn't able to find the usage
UPDATE: I found a way to do it.
Yo
What are markdowns on the top.gg website
bc i try you know the bold and that does noting
Underscores around the word italicize it
i feel like I'm being hella dumb, how do I get my bot to DM a certain userID with a message?
say if I did like
DM!send (message)
and had it set to only send to a specific userID, how would I get the command to read and copy-paste the (message) into the userID's DM's?
I've got everything down except for the "read my message and send it to the userID" part
I've got a lock on sending a set message to a userID, but not a user-inputted one
whats ur lib
.js
atm
ight imma head out
its like 4 am and im tired, its killing me xD
and .js what
d.js, eris?
discord.js i think
im just hella tired so brain not working
id if this will work, oop
ok so i want to be able to run 1 node.js script more than once with 1 command
how can i do so
with my downloader i can make it so that it downloads multiple images at once
you mean offload your request to different processes?
multithreading in node 
well for starters you could look into child_process
discord js caches all avatarURL's and usernames? right?
@stray wasp no, only if the user has sent a message
thanks Plemso
Hey my bot says seth take too long to respond after start up, how could I fix it?
could you explain more
When I added shard, I encountered such a problem; client.channels.get gives error, how can I fix it?
Is there an event related to creating dispute in webhook in js?
wat
<body style="background-color: #23272A">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<a class="navbar-brand">
<img src="/images/icon.png" style="width:40px;">
</a>
<ul class="nav navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 3</a>
</li>
</ul>
<ul class="nav navbar-right">
<li>
<img class="rounded-circle pull-right" src=<%- user.avatarURL %> width="50" height="50">
</li>
</ul>
</nav>
</body>
http://owo.sh/8ZNoAJV.png
Why the avatar isn't in the right of the navbar?
because bootstrap doesn't work like that
what should I do so the avatar goes in the right? 
read the docs or google it
I'm "new" to bootstrap
there's something related to positioning to do it
i haven't used bootstrap in a while because there's better things
Changed pull-right to float-right but it still doesn't work
there's something else
let me check
try ml-auto or mr-auto on the navbar-right ul
but changed navbar-right to navbar-nav
if (user){
user.send('example test')
} else {
message.reply('user ?')
}```
@cerulean salmon example
💗 thank u very much
np 
you are getting all mentioned members. and with first you'll get the first entry
👀 without that function i will ge an array of mentioned user ,right ?
mh okay i dont use that, so i don't know what the issue can be
but if you catch a message someone mentioned a user in, you shouldnt get an empty array 👀
Hello
@humble anchor if you dont have a development question, go to #memes-and-media or #general. else, feel free to ask
write code
and magic happens
best try/catch method? bot seems to be going offline but not showing any errors in console or anywhere
to use... try catch
@humble anchor "How to make music command in Android" isnt a very good question. Try findind something in the internet and try it, if you run into errors feel free to ask
try {
client.login(discordApiKey);
}
catch(err) {
msg.author.send ("ERROR CATCH TEST - This Works??")
};
is what im using lmao
but it doesnt work xD
because that's a promise
client.login(key).catch((err => {
console.log('Error')
}))
😮 🥄
ik

@earnest phoenix in your code there are multiple errors
The message isnt defined there
If you make a space between msg.author.send and the message it wont work
you have to find the member you want to send it to in your bots cache with client.users.find(m => m.id == 'some id')
and send the message to him
= finished code (sorry for 🥄)
client.login(discordApiKey).catch((err => {
console.log('Error while login:\n' + err)
}))
like i said
try {
client.login(discordApiKey);
}
catch(err) {
client.users.get("USERID").send("Error")
};
so something like this? idk
so
if you fail to login
= ur bot cant login to discord
how would you send a message over ur discord client to yourself
if your bot cant login

ahh okay, send to console.log instead xD
so I've gotta do this for every section that might error out right?
if the error blocks you from sending messages log it into console
console.log("Hi i am ur console")
try {
client.login(discordApiKey);
}
catch(err) {
console.log("\x1b[31m" + err + "\x1b[0m")
};
so, something like this?
no try*
client.login(token).catch((err => {
//do something with err variable that contains the error
}))
u have to promise output i think
ill try that, how would I put this to grab any/all errors my app.js might put out, is there a global variant?
no
oof
gotta do this for each section of the code then I'm guessing
if there could be a error and you dont know how to prevent it then yes
so,say for instace I've got this
client.on("guildDelete", guild => {
client.users.get("USERID").send("Left a guild: " + guild.name)
})
how would I add the catch here?
would it just be as simple as
client.on("guildDelete", guild => {
client.users.get("227836492880281600").send("Left a guild: " + guild.name)
}).catch((err => {
console.log(err)
}))
oh ur bot got approvum gg
the catch comes after the send
so
client.on("guildDelete", guild => {
client.users.get("227836492880281600").send("Left a guild: " + guild.name).catch((err => {
console.log(err)
}))
})
im spoonfeeding aigan god dammned
sorry ❤ catch just confuses me xD
so for every line, I'd have to add the catch?
client.on("guildDelete", guild => {
client.users.get("USERID").send("Left a guild: " + guild.name).catch((err => {
console.log(err)
}))
const guildNames = client.guilds.map(g => g.name).join("\n").catch((err => {
console.log(err)
}))
console.log("\x1b[33m", guildNames, "\x1b[0m").catch((err => {
console.log(err)
}))
})
???
🤦🏿
no
wait
only in lines where you expect a error and want to give the user a output
you dont have to add a catch to everything
for example
idk what exactly is causing the error though oof, it just kills the bot at some point and idk when
thanks for the help though man, I really appreciate it ❤
wait
so wait
you want to output the guild names to the console and dm you when your bot gets removed from a guild
thats easy tho
hol on
I added a catch to everything and DMed unexpected errors to myself
absolutely
theres a lot more to it tbh, and im tempted to do that ^ alpha
got 212 lines of messy code that idk what could break in xD
client.on('guildCreate', guild => {
dbl.postStats(client.guilds.size)
console.log('Joined a new guild: ' + guild.name);
const owner = client.users.find(usr => usr.id == 'urid');
owner.send(`Joined ${guild.name} || ${guild.id}`)
});
client.on('guildDelete', guild => {
dbl.postStats(client.guilds.size)
console.log('Left a guild: ' + guild.name);
const owner = client.users.find(usr => usr.id == 'urid');
owner.send(`left ${guild.name} || ${guild.id}`)
});
i have those two
if you want to get a dm every time ur bot gets removed / added
you can go that path
wait why do you use string interpolation on owner.send but not on console.log?
*completely unrelated to how the code operates im just a doof
All my bot functions work, but one of them, idk which, is causing the bot to go offline and stop working, but the console is fine and keeps updating
How to make bot status remove command?? @earnest phoenix
So if someone spam invites/kicks your bot, you're gonna spam post stats to dbl 
no
ehhe
because if someone does
set it to dm you instead
hippedi hoppedi blacklist gets their property
@earnest phoenix if you dont know where an error is coming from
be sure to 100% log every single thing
works for me 
@knotty steeple yea ima stick a catch on every bit of code lmaooo til I figure out the issue that is
@earnest phoenix tell how to make bot status remove command??
what does that even mean
Also, from what I've seen guildDelete can fire when a server goes unavailable
if u type b.removestatus for example it resets presence
oh a command to remove
So literally just discord dying could get you ratelimitted from dbl
playing status
@late hill DBL ratelimits are kinda fucky
But wouldn't it be nice to respect them anyway 
True
You can get the ID from mention
client.users.find(m => m.id == args[0]).discrim
that only works if the user is cached
idk
use client.fetchUser
gets from cache if there is one, if there isn't one it does a REST request instead (which is why it's a promise)
i mean it shouldn't
guess it's just me being pissy about having less lines for that kind of stuff
d.js does it and does a lot of other things for the end user because a lot of d.js users are degenerates
Understandable
@late hill my fix for spamming DBL is that my updates are on an hourly schedule with the first update being an hour after the bot boots, reconnections don't affect that timer interval
That way even if it crashed it wouldn't submit again immediately
One message removed from a suspended account.
Do you mean a mention?
If so I think you need to do something like <@userid>
I'm not 100 percent sure
Because I haven't done that in a really long time
<@id> or <@!id>
One message removed from a suspended account.
We answered
bruh
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
{ Error: Connection lost: The server closed the connection.
at Protocol.end (/home/callum/newCMBtest/node_modules/mysql/lib/protocol/tocol.js:112:13)
at Socket.<anonymous> (/home/callum/newCMBtest/node_modules/mysql/lib/Contion.js:97:28)
at Socket.<anonymous> (/home/callum/newCMBtest/node_modules/mysql/lib/Contion.js:525:10)
at Socket.emit (events.js:194:15)
at endReadableNT (_stream_readable.js:1103:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
--------------------
at Protocol._enqueue (/home/callum/newCMBtest/node_modules/mysql/lib/protl/Protocol.js:144:48)
at Protocol.handshake (/home/callum/newCMBtest/node_modules/mysql/lib/prool/Protocol.js:51:23)
at Connection.connect (/home/callum/newCMBtest/node_modules/mysql/lib/Contion.js:119:18)
at Timeout._onTimeout (/home/callum/newCMBtest/bot/database.js:18:7)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10) fatal: true, code: 'PROTOCOL_COCTION_LOST' }
module.exports = client => {
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'url hidden',
port: '7503',
user: 'root',
password: 'pass hidden',
database: 'catmaniabot'
});
let sql = connection;
global.sqlConnection = sql
setTimeout(function(){
sql.connect(function(err) {
if ( !err ) {
console.log("Connected to MySQL");
} else if ( err ) {
console.log(err);
}
});
},10000)
}
Why is the sql not connecting?
is it possible to make a channel that has time to it?
Yup, but coming up with the format is up to you
i did try it but the time keeps bugging
i did interval
to make it update every 1 minute
In which way bugging?
like the numbers are getting crazy changing every second
its working fine in the start but after idk how long but lets say 5 minutes the time will go crazy
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
Id of undefined

client.shards is not defined
2 shard

does anyone know a npm module that i can use to make something like this in js
https://media.discordapp.net/attachments/633232832226918400/634465834340843540/graph.png
anyone know where i would start looking to learn abt sharding my bot?
@earnest phoenix id, not Id
🤦 You are right
What language is your bot written in? @modern elm
javascript
discord.js, right?
yeh
oh thanks :)
@peak quail that's grafana
Oh wait nvm it might not be
It looks like a grafana graph though
it means your quotes are wrong. you have to use the " character, not quotation marks
also, next time please make a print screen, that pic took ages to load
@ocean rampart wath is your thème of visual studio code ?
@untold galleon seems to be default dark
i personally use https://draculatheme.com for everything
dracula is hot
Material Darker > ***
What does The file name, directory name, or volume label syntax is incorrect. Mean?
ah ok so basically it means
say you have a path like C:\Users\you\project\config.json
that is a path
or linux is something like ~/project/config.json
so basically make sure your path looks something like the ones above without any characters that would cause that error
off of the top of my head, i think adding double slashes would cause that error
Oh okay, thanks.
yw
you'll need to show more code
@untold galleon my theme
that if else bracket is killing my eyes, but theme is dope
You're passing 'good' && lwcmd.search('night') to lwcmd.search()
Don't know what exactly you're trying to do, but probably not that
@green kestrel i can have your theme please ,
or it's visual studio code fot computer ?
can help me for develop one command for anti-raid please ?
isnt it the default vim theme?
Yes :)
vim gang
It's always been fine for me to read, so I didn't change it
The only command I know in vim is :q!
If I need to edit something on my VPS I just use nano or I use a SFTP extension in VSCode
sed also exists in discord
Nano is ok I guess
Yeah I found that out by mistake @mossy vine
s/?
yeah we found it accidentally like 2 years ago
Yep 2
I do that as habit from IRC and was surprised when it edited my last message for me
Ah well you really can't do anything about it
is there anyway I can catch all errors that happen when a command is executed with the command handler, just at the command handler, instead of putting a bunch of catches in the command code?
for the entire process
process
.on('unhandledRejection', (reason, p) => {
// handle
})
.on('uncaughtException', err => {
// handle
});
oh for the command handler
assuming require().run() just do require().run().catch(e => { //handle here})
wait
nvm im dumb
just a try / catch wherever you execute the command lol
if you're using djs then maybe
.on('message', m => {
messageHandler.dosomething(m).catch(e => {
// handle
handleError(e);
})
})
obv you wont have messagehandler like above id assume but it would look something like that
any good tutorial to writing to objects?
@tall arrow what do you mean?
and can i write something like
object.property = id[coins]
yes
help me for develop a command anti-raid on
const Discord = require('discord.js');
module.exports.run = (client, message, args) => {
};
module.export.help = {
name: 'setAnti-raid'
};
``` and I do not know the code of the entire anti raid ... in my main file it's like that
```js
client.on('message'......
```here
@untold galleon noone will spoonfeed you
I know but I ask for help
what ?
-> Sketch out your command
-> Think of the logical steps you'd have to create in order to get your desired result
-> If you don't know how to do a specific task, google it, if you still can't find what you're looking for you can ask here. Likewise if you need help with figuring out logical steps.
Just don't ask for something in it's entirety, aka how to do my whole command
furthermore, anti-raid is a very complex thing, there are a lot of things to think about. its not something that everyone uses and copy-pastes from each other
I know but I ask for help
and I do not know the code of the entire anti raid
@untold galleon Saying that you don't know code doesn't mean you're asking for help. You're indeed asking us to spoonfeed you
Spoonfeeding is for children up to 7 - 8 months old
choking hazard
Due to you knowing English and a bit of code I believe you have the mental capacity of at least a 9 year old or older. So I'm sorry your too old for spoonfeeding.
you're
Missing comma
that's an apostrophe bruh moment
Alright I'm go necklace
One message removed from a suspended account.
Try ().content
How do I add custom emoji to a server using a discord js bot? If I have an image link, how can I add them as emoji (given the bot has perms)?
Are you on stable or master
visit package.json and look for where discord.js is. If you're using master, check out the GuildEmojiRoleStore class. Else, just look at the Guild class for creating emojis.
@earnest phoenix if you uh mean
so you can use a nitro emote in other servers
then create a server, add the emoji and now you can use it on any server (for your bot)
@quick rain The wait_for_messages() method was replaced with wait_for() at this commit https://github.com/Rapptz/discord.py/commit/e5cb7d295c9c8ea5ca52308b4286452a64729b83.
https://webkit.org/blog/3632/introducing-backdrop-filters/
does anybody know of a firefox polyfill or replacement for backdrop-filter
help
Error:
(node:15879) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
Code: ```
const Canvas = require('canvas-constructor');
const Canvas1 = require('canvas');
const Discord = require ('discord.js')
exports.run = async (bot,message,args) => {
var award1 = args.join(' ')
if (!award1) return message.reply ('Not inputting a needed parameter and breaking the bot')
var pic3 = await Canvas1.loadImage('https://api.alexflipnote.dev/achievement?text=' + award1);
if (award1.toLowerCase().includes('gnomed')) var pic3 = await Canvas1.loadImage("https://i1.sndcdn.com/artworks-000179621054-n5eeg3-t500x500.jpg");
var w = pic3.naturalWidth;
var h = pic3.naturalHeight;
const canvas2 = new Canvas.Canvas(w, h)
.addImage(pic3, 0, 0)
.toBuffer()
const canvas3 = new Discord.MessageAttachment(canvas2, 'card.png')
message.channel.send(canvas3);
}
module.exports.help = {
name: "achievement",
aliases: ["achie"]
}```
My bot goes offline randomly, Anyone have a fix for this?
No
unhandled rejections don't cause your app to exit (yet)
but yeah id advise looking through your console
or something is emitting sigint/sigkill
events.js:194
throw err; // Unhandled 'error' event
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] {
message: [Function],
open: [Function],
error: [Function],
close: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
readyState: 2,
protocol: '',
_binaryType: 'nodebuffer',
_finalize: [Function: bound finalize] { __ultron: 0 },
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_finalized: true,
_closeCode: 1006,
_extensions: {},
_isServer: false,
_receiver: Receiver {
_binaryType: 'nodebuffer',
_extensions: {},
_maxPayload: 0,
_bufferedBytes: 0,
_buffers: [],
_compressed: false,
_payloadLength: 36,
_fragmented: 0,
_masked: false,
_fin: true,
_mask: null,
_opcode: 1,
_totalPayloadLength: 0,
_messageLength: 0,
_fragments: [],
_cleanupCallback: null,
_hadError: false,
_dead: false,
_loop: false,
onmessage: [Function],
onclose: [Function],
onerror: [Function],
onping: [Function],
onpong: [Function],
_state: 0
},
_sender: Sender {
_extensions: {},
_socket: [TLSSocket],
_firstFragment: true,
_compress: false,
_bufferedBytes: 0,
_deflating: false,
_queue: []
},
_socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'gateway.discord.gg',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 7,
connecting: false,
_hadError: false,
_parent: null,
_host: 'gateway.discord.gg',
_readableState: [ReadableState],
readable: false,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
timeout: 0,
[Symbol(res)]: [TLSWrap],
[Symb
judging by the word "websocket"
it probably has to do with your internet connection if djs didn't handle the error
404 client.on('error') not found
Alright
So it’s my internet?
K
didnt see the whole throw err; // Unhandled 'error' event bruh moment
i take picture with my phone
caand do creen with the pc
but i dont resolve that problem
@marble juniper
why not
I don't use phython so I Have no idea @quick rain
Using bot but putting client
@quick rain Indent that second if statement in on_message
@quick rain you didn't add the process command
On the on on_message add await bot.process_commands(message)
At the top
its possible to make a code that when someone voted ur bot bot says in a channel who voted?
i dont know how to tell that.
How do I do an "is bot" field on my userinfo command?
by adding it
even I dont python I feel like that agua is iindented wrong
@astral meteor make another field and then use message.author.bot and put it into that field if you want you can also replace the true or false with your own message
I think thats also in the docs idk if you use js but thats how I would do it
yeah ofc i use djs xd
ahh
but I hope that helped you
works. thank you :)
Yep
pretty sure the last two lines should be one indentation back
also, you're using bot, not client, so client.for_message is wrong
When I use "this" within a class it returns the first thing I bound to it.
Will doing this work to catch all errors when a command is ran?
try {
cmd.run(client, message, args);
} catch (e) {
message.channel.send(`**Whoopsies, an error has occured while trying to use this command!**\n**Error:**\`\`\`${e}\`\`\``)
}
That will send a message if the command doesn't exist or doesn't have .run method
You'll need to handle errors within commands too
What do I need to do, to catch all errors instead of having a bunch of .catch inside the command
try catch
Any one have music bot spriti python programming language
https://discordapp.com/channels/264445053596991498/272764566411149314/635798035158532096 + to my question,
When I console.log "this" within the constructor of a class it has all the properties but when I console.log "this" within a method of that class I just get the Client.
Nvm, Found out why. My bad.
@snow urchin that will work if everything in the run function is sync
if you have async code, then all promises must be awaited for it to work
including the run function itself, if its an async function
I make a music bot
And he did not connect in voice channel
What I do
Any one tell me
@quartz kindle
Can I use something else than YouTube to play music?
youtube music 🙃
guys, is there any way to embed into discord message?
you mean send an embed?
no
looking a way to countdown timer that reset every week and embed it into a command in MEE6
something like this https://countingdownto.com/?c=2694391
but embed it like a message 🤔
and then edit the message every minute
@glacial mango lavalink supports other hosts such as SoundCloud and Bandcamp
are you talking like a cooldown?
i heard it has "tick" resource problem
which library?
or language i mean
What's lavalink?
haven't tried myself 🤣
@buoyant lake you cannot have a live updating timer/countdown. you can update it every minute or so, or you can show how much time is left when a person uses the command, but you cant have live updating
thank you for describing it in detail
the absolute limit is update it every second, but that might get you banned from discord
the longer you wait between updates, the better
yes, but its not live updating
its the second option i said or you can show how much time is left when a person uses the command
ok sorry, i misunderstood
What is the ID and the token of a discord webhook ?
so is this the solution, wizyx?
by using webhook? 🤔
@opal summit
i got no knowledge about this part of discord
no it's another question
@opal summit what are you trying to do?
@buoyant lake what are you trying to do exactly?
Isn't the token of a webhook literally in the webhook URL
if we're talking Discord ones
how do i test how bot behave like if i compile it in IDE?
like the screnshot that i posted above
countdown run in the background and then update it when user run the command
webhooks are alternatives to sending messages with bots, you can't edit messages or read messages with them from what i'm aware
@buoyant lake are you coding your own bot? if so, what language and library are you using?
do you have experience with any programming language?
or that webhook alternative, is it possibile to use that method instead?
well i'm comp sci graduate 4 years ago, but i haven't touch programming since 2 years ago
🤦
just a degree i think now, since the skill is almost gone
useless
but are you familiar with any language?
c#, react* and the html,js,css
then its always better to stick with what you're familiar with
javascript and c# both have libraries for discord bots
but is it necessary to waste resource to develop bot for this purpose only? 🤔
if webhook method is enough to just send the timeleft message
well, you can try
you need a webservice that offers countdowns
in webhook form
and if their webhooks are not compatible with discords, you need to use a middle-man like IFTTT
how to have a premium bot linked with the normal bot?
Can i get some ideas
when i say linked i mean by having the same information as the main bot such as commands and db info - discord.js
help
Error:
(node:15879) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
Code: ```
const Canvas = require('canvas-constructor');
const Canvas1 = require('canvas');
const Discord = require ('discord.js')
exports.run = async (bot,message,args) => {
var award1 = args.join(' ')
if (!award1) return message.reply ('Not inputting a needed parameter and breaking the bot')
var pic3 = await Canvas1.loadImage('https://api.alexflipnote.dev/achievement?text=' + award1);
if (award1.toLowerCase().includes('gnomed')) var pic3 = await Canvas1.loadImage("https://i1.sndcdn.com/artworks-000179621054-n5eeg3-t500x500.jpg");
var w = pic3.naturalWidth;
var h = pic3.naturalHeight;
const canvas2 = new Canvas.Canvas(w, h)
.addImage(pic3, 0, 0)
.toBuffer()
const canvas3 = new Discord.MessageAttachment(canvas2, 'card.png')
message.channel.send(canvas3);
}
module.exports.help = {
name: "achievement",
aliases: ["achie"]
}```
the first parameter is reserved for the content
the second parameter takes in options/attachment
message.channel.send({ files: [{ attachment: result, name: 'card.png' }] });
@fallow spire
😮 🥄
ask yourself first if you need a premium bot
possible to make a code like when someone voted ur bot it will show a message
??? In.(js)
yep i do
why
well it would be nice
@heavy marsh u know?
that's not a valid reason
you don't need to have a premium bot
??
it's bad user experience and it's a pain to link two bots to work together in sync
U saying to me?
I can find that in dbl api?
okey
IDK it looks interesting
@heavy marsh tyy
np
okay so I finally managed to get the console to print the error that stops the bot from running
buuut
im stumped
events.js:189
throw err; // Unhandled 'error' event
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
target:
WebSocket {
_events:
[Object: null prototype] {
message: [Function],
open: [Function],
error: [Function],
close: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
readyState: 2,
protocol: '',
_binaryType: 'nodebuffer',
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_closeCode: 1006,
_extensions: {},
_receiver: null,
_sender: null,
_socket: null,
_isServer: false,
_redirects: 0,
url: 'wss://gateway.discord.gg/?v=6&encoding=json',
_req: null },
type: 'error',
message:
'getaddrinfo ENOTFOUND gateway.discord.gg gateway.discord.gg:443',
error:
{ Error: getaddrinfo ENOTFOUND gateway.discord.gg gateway.discord.gg:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'gateway.discord.gg',
host: 'gateway.discord.gg',
port: 443 } })
at Client.emit (events.js:187:17)
at WebSocketConnection.onError (F:\desktop\Dappers Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
at WebSocket.onError (F:\desktop\Dappers Bot\node_modules\ws\lib\event-target.js:128:16)
at WebSocket.emit (events.js:198:13)
at ClientRequest.req.on (F:\desktop\Dappers Bot\node_modules\ws\lib\websocket.js:568:15)
at ClientRequest.emit (events.js:198:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
ho boy, wall of text
Handle the error event
but where
nothing on line 189 except for commented out code ;-;
I didn't post the error
oof, idk why internet died then
gonna have to figure out how to attempt to re-connect after internet loss
@earnest phoenix listen and handle the error event
client.on("error", error => {
// do something with error, like console log it or something
})```
Ahh oki, I'll try that
someone with a working musicbot willing to give me the code? I lost my code because i had to reset my PC because of a VIRUS... and now i lost like tons of hours /lines of code... if you want proof dm me i can show you how the bot was..
ik its akward to ask....
hope i dont get banned for that.
^
idk i was doing it without thinking..
even if they did, the code would likely be drastically different from what you had before, and you wouldn't understand half of it
^^
YES
finally
any way to get this warning to go away without changing the type of enumClass to Class<Enum>
https://bruhh.wtf/hVMQorhaCQ.png
or not cause a wrong argument error if I do change it to Class<Enum> if I supply a enum class like SomeEnumType.class
@flat pelican can you change my nickname please?
Done
A discord server can't be DDOS'd however it can be raided, there is bots like altdefender which stops spam and raids
Altdentifier
I cant english
No Problem
a discord server cant, but discord itself can lul
xd
Discord servers absolutely can be DOS'd
It's just an incredibly nonstandard approach
Some bots can be DOS'd if you throw enough users/people at it
or just oof their host lol
but there is no way to know their ip/host as far as i know, all data goes through discord
akshcually
that's why i said as far as i know 😛
they used to expose the raw ip in a UDP voice connection
new exploits are still being found to get a user's ip address

Ill brb
it was loic aigan right?
(((((im joking)))))
so im planning to add a thing to my bot where it creates a channel, and updates the channel name periodically with a count.
I get how to make a channel and stuff, but if the channel name changes each time it gets updated, how do I refer to that specific channel each time it needs to update?
store the id
create channel in server
then find channel ID
store, and change via ID?
yes
the entire channel object is returned to you when you create it
so you can use the id property on it
ahh perfect, thanks
use a paste service like https://paste.mod.gg that's unreadable @ornate mortar
Im still having a problem when I try to do something like setInterval(function(){client.channels.get("630431103051890701").send("test")}, 10000). It says that send is not defined.
specifically setInterval(function(){client.channels.get("625117613151879172").send("test")}, 10000); ^ TypeError: Cannot read property 'send' of undefined
But, if I add client.channels.forEach((channel, id) => { console.log(`(${channel.type})${channel.name?channel.name:(channel.recipient?channel.recipient.tag:'')}:${channel.id}`) }); to the code, the channel is visible to the bot. I tried taking it out of the setInterval, didnt work, tried different channels/guilds, and that didnt work either
it says the channel is undefined
I know, but the channel is visible to the bot, and I can't figure out why it isnt defined
maybe try message.channel.send? I had an issue similar, might work idk
setInterval(function(){client.channels.get("625117613151879172")message.channel.send("test")},
10000);
no clue if ittl work but
it would probably give unexpected identifier because client.channels.get("625117613151879172") replaces message.channel
yep ```setInterval(function(){client.channels.get("625117613151879172")message.channel.
send("test")}, 10000);
^^^^^^^
SyntaxError: Unexpected identifier```
Wait, did you run client.channels.forEach((channel, id) => { console.log(`(${channel.type})${channel.name?channel.name:(channel.recipient?channel.recipient.tag:'')}:${channel.id}`) }); inside the lambda for setInterval? Or did you run it outside?
outside
Same results if inside?
Yes
Can I do that my bot do an announcement for @ashen cloudyone every day at 19:00 for exempel
@tight mountain
maybe
setInterval(function(){
var Chan = client.channels.get("625117613151879172")
Chan.send("test")},
10000);
idek, i cant remember how I fixed mine ;-;
same error
hmm
does it have to be that specific id?
or would you be able to check for name instead
setInterval(function(){client.channels.get('625117613151879172')channel.send("test")},
10000);
no clue, but this might work, looking into stuff
whelp idk, no clue here sorry
hopefully someone else can give you a hand
I'm just trying to create a voice channel where @ everyone can view its existance, but not access/connect to it. not sure what I'm doing wrong here and i feel like its super simple, code nd error here
https://paste.mod.gg/afidutiben.coffeescript
const everyone = message.guild.roles.find("@" + "everyone");
Find requires a callback function.
therefore pass a function
"@" + "everyone" wtf
The everyone role is also the the guild id
To which I would recommend using get over find as it's faster.
TypeError: Discord.RichEmbed is not a constructor...
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
this is legit what I do const embed = new Discord.RichEmbed()
const embed = new Discord.RichEmbed()
.setAuthor('Ping')
.setColor("RANDOM")
.setDescription("My websocket ping is " + Math.round(client.ping) + ".")
message.channel.send({embed});
one of my cmds
doesn't work
after i updated to v12
v11 was perfect though
WAIT WHAT
it sent???
oh wai, i ran npm i discord.js --f
One message removed from a suspended account.
One message removed from a suspended account.
How does one remove the color bit from the embed messages entirely?
how do you make message embeds?
One message removed from a suspended account.
I don’t and it comes up grey
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
No like remove it
One message removed from a suspended account.
i need to read docs again rip
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
How are those made?
Instead of RichEmbed, it’s MessageEmbed?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
you mean const embed = new Discord.MessageEmbed()
I’m trying to achieve that, Mythical bot has something like that but in embed
One message removed from a suspended account.
?
Afk is why I’m asking this weird questions lmao
I think rich embeds and message embeds are almost the same thing..
Is it possible to zip with nodejs?
I clearly don't understand https://www.npmjs.com/package/jszip-sync
Create, read and edit .zip files with Javascript, with sync capabilities, forked from http://stuartk.com/jszip
@earnest phoenix wait r u asking for color in ur embed or not?






