#development
1 messages · Page 938 of 1
your missing 1 ending parenthesis
from fs.writeFile
your code editor is supposed to tell you this
that's atom..
oh
So did i do it right or wrong?
Use visual studio code, it tells you if there is a error
And (most of the time) how to fix it
@rain jacinth I want to say that's for the channel line
you never closed your (
You still forgot a) after JSON.stringify(...)
^
i did and it still won't switch to the log i want it to..
got no idea what that is
Hey. What's the reason message.author.locale is undefined? I saw the ? in the docs but why is it not always there?
One message removed from a suspended account.
There's a problem in one of your commands maybe
Idk check the command you were recently working on
how to solve: Define name
One message removed from a suspended account.
One message removed from a suspended account.
Any reason to that?
One message removed from a suspended account.
@fallow steppe wrong formatting
show us da code
One sec
One message removed from a suspended account.
i would rather use ${}
I can't ss everything because I'm on mobile. One moment
pasting the code also works, just remove private stuff 
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I have a problem, suddenly my bot stopped working and now is not starting anymore, any idea why ?
I can't because I cant select anything in glitch
One message removed from a suspended account.
Ill try, a sec
One message removed from a suspended account.
exports.run = (client, message, args) => {
let days = Math.floor(client.uptime / 86400000);
let hours = Math.floor(client.uptime / 3600000) % 24;
let minutes = Math.floor(client.uptime / 60000) % 60;
let seconds = Math.floor(client.uptime / 1000) % 60;
let arr = [1, 2, 3, 4, 5, 6, 9, 7, 8, 9, 10];
arr.reverse();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
message.channel.send({embed:{
title:`Test Bot's stats`,
color:0xFFA07A,
fields:[
{
name:'Uptime',
value:`${days} days ${hours} hours ${minutes} minutes ${seconds} seconds`
},
{
name:'General stats',
value:`-Guilds: ${client.guilds.cache.size}
-Members count: ${client.users.cache.size}
-Memory usage:' + 'Math.round(used * 100) / 100' + 'MB'
},
{
name:'Bot owner and developer',
value:'Sandra#3781'
}
]
}})
}```
Had to copy it cause can't screenshot
@earnest phoenix ^
.setFooter(client.user.displayAvatarURL())
Can someone help me?
I tried to add avatar image but it gives url
well as far as i can understand js, it think this is formatted wrong
const Discord = require("discord.js");
exports.run = (client, message, args) => {
let days = Math.floor(client.uptime / 86400000);
let hours = Math.floor(client.uptime / 3600000) % 24;
let minutes = Math.floor(client.uptime / 60000) % 60;
let seconds = Math.floor(client.uptime / 1000) % 60;
let arr = [1, 2, 3, 4, 5, 6, 9, 7, 8, 9, 10];
arr.reverse();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
message.channel.send({embed:{
title:`Test Bot's stats`,
color:0xFFA07A,
fields:[
{
name:'Uptime',
value:`${days} days ${hours} hours ${minutes} minutes ${seconds} seconds`
},
{
name:'General stats',
value:`-Guilds: ${client.guilds.cache.size}
-Members count: ${client.users.cache.size}
-Memory usage:' + 'Math.round(used * 100) / 100' + 'MB'
},
{
name:'Bot owner and developer',
value:'Sandra#3781'
}
]
}})
}```
you're making them strings
Help me to convert the url to image
^
you need to have a name
then pass the avatar url
along with the name
what is a avatarurL? OwO
@fallow steppe there are two ways of mixing strings and variables, one is concatenating, the other is templating
// concatenating
"my string" + Math.round(number) + "another string"
// templating
`my string ${Math.round(number)} another string`
``` notice the difference in quoting
I see
My bot doesn't start anymore, any idea why ?
So I'd have to use quotes instead of inverted comma?
if you want to use concatenation, you can use whichever you want, but you have to stop the string, use the plus signs, then start another string
if you use templating, you dont need the plus signs, instead you use ${} around it. templating can only be done with backsticks/inverted comma
My bot suddenly stopped working, it actually doesn't start, any idea why? I didn't change anything about it except for some embeds
without any code or error, its impossible to know why
errors?
No errors
in console i got nothing
All clear
then you don't handle your errors properly
it worked 5 minutes ago
are you using glitch?
add a client.on("debug",console.log)
anywhere?
i got something in the console
what is it
Provided token: Njg3OTk2OTYxMjk4NTc5NDk0.XsbDwA.***************************
Preparing to connect to the gateway...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 0
[WS => Manager] Spawning shards: 0
[WS => Manager] Exceeded identify threshold. Will attempt a connection in 7027324ms
you reached your daily session limit
wtf are you doing to cross the 1k IDENTIFY limit
How do you await DM messages discordjsv11
well i did time / 1000 / 60 / 60 and got 1.9
did you do it in UTC though
wat
oh wait
xD
i thought the timestamp in "will attempt connection" was something d.js was doing, not what discord returned
my b
@earnest phoenix you should be able to use channel.awaitMessages the same way you do in guilds
Hey
For some reason when I try to post my sever on the website it doesnt allow me. Can someone help?
@quartz kindle i reached the limit maybe because my friend spammed with some bots ( old accounts tokens ) commands on my bot?
is a 1gb SSD vps good enough for a bot
cos i found this https://hostbend.com/discord-bot-hosting/
Thats technically not a vps, its just something like glitch
256mb is nothing for a discord bot
most bots in more than like 50 guilds will use more than this
unless you optimize
theres still a bunch of actual vps providers with decent vps servers under 10$
Digital Ocean is a good choice
OVH ( Best anti ddos ) Scaleway ( One Provider ) best support
private-hosting is the one i use, but theres several others
contabo and oneprovider are also good ones
ovh has disadantage that their ips are banned from a lot of services
but if ur just hosting discord bot this isnt an issue
Scaleway's support is hot shit
On several occasions we've had vm instances freeze and them take 6 hours just to say "we dont know"
If you want a smaller server Kimsufi ( OVH server ) & SoYouStart ( OVH too )
then take another 4 hours to say "Nothing we can do other than hope"
On several occasions we've had vm instances freeze and them take 6 hours just to say "we dont know"
@modest maple Yep scaleway very bad, but Online its ok
OneProvider is alright but yh scaleway is just
the big shit
Contabo is probably the best support ive seen so far
question
if i have this
guild: message.guild,
textChannel: message.channel,
voiceChannel
});```
how come it errors
at
(node:563) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'players' of undefined
this is the code its my play command
is bot.music a property?
I believe so
at Object.run (/app/src/commands/music/play.js:20:34)```
I think I know why
whenever im doing my styleing for my bot page I cant change the content box, when i change the longdescription it only changes the borders and when i change the div content nothing happens
How can I make my bot send a message each day at a certain time of the day?
Hey. What's the reason message.author.locale is undefined? I saw the ? in the docs but why is it not always there?
now i have this error
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 2333 }```
I don't understand it
glitch?
yes
The Connection is being refusedf
Ohh thank you @earnest phoenix
How do I fix it?
I dont use glitch so give me a minute
Try remixing project
@astral yoke are you trying to connect to a local host?
Yes.
and where exactly is that happening
thats why
it wont work
aka for what are you connecting to localhost?
{ "host": "localhost", "port": 2333, "password": "Stringer1212" }
]```
nobody cares anyway lol
^
as long as we dont have your host
- its a local host so we cant unless you ip foward
So in that support thing
it says to get the ip of the database
but im not using it for a database
im using it to play music?
so I need to find glitch ip or what?
something along those lines
you also need the IP i beleive
test it yourself
i dont use glitch so i dont know
@earnest phoenix ^?
welp
now i have this error
at ClientRequest.req.on (/rbd/pnpm-volume/8026e4ea-29c1-4714-8479-5e7241f9946b/node_modules/erela.js/node_modules/ws/lib/websocket.js:579:7)
at ClientRequest.emit (events.js:189:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at Socket.socketOnData (_http_client.js:442:20)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead (internal/stream_base_commons.js:94:17)```
when even the server doesn't expect it working
@earnest phoenix what are you trying to do
Why
thats useless
create 2 client objects
but why would you want 2 bots in one?
like
const client ....
const bot ....```
@mossy vine?
yes
yes
what would message.guild.channels.forEach be equivalent to in v12
message.guild.channels.cache.forEach
Question, how would I have my bot detect the server name and use it in an embed?
library?
JavaScript in V12.2.0
Okay?
Thank you hope.
How to make shards if I use discord.py and already have bot maked on cogs?
I want to test shards on my raspberry pi before something more powerful
i have this in my bot config
{ "host": "localhost", "port": 8080, "password": "yeeeyeepasswordtotallyit" }
]```
but with glitch
you cant use local host so what do I change it to/make it work with
I would have to have a comprehensive guide because I don't know where to start at all
wrong channel lads
Bon bye
anything wrong with this?
const beautify = require("beautify");
module.exports = {
name: "eval",
aliases: ["e"],
description: "Eval command.",
usage: "<code to eval>",
execute: (bot, message, args) => {
if (message.author.id !== "503641535342968832") {
return message.channel.send("You don't have permission to use this command.")
.then(m => m.delete(5000));
}
if (!args[0]) {
message.channel.send("You need to eval _**SOMETHING**_, please?")
.then(m => m.delete(5000));
}
try {
if(args.join(" ").toLowerCase().includes("token")) {
return;
}
const toEval = args.join(" ");
const evaluated = eval(toEval);
let embed = new RichEmbed()
.setColor("#00FF00")
.setTimestamp()
.setFooter(bot.user.username, bot.user.displayAvatarURL)
.setTitle("Eval")
.addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
.addField("Evaluated:", evaluated)
.addField("Type of:", typeof(evaluated));
message.channel.send(embed);
} catch (e) {
let embed = new RichEmbed()
.setColor("FF0000")
.setTitle("\:x: Error!")
.setDescription(e)
.setFooter(bot.user.username, bot.user.displayAvatarURL);
message.channel.send(embed);
}
}
}```
How can I catch an error from a const variable that awaits something? (Node)
You can use try.
Wait--so if I declare the variable inside try, can I use it outside of the try statement?
Nani for richembed ( acutally its v12 idk if its v11 )
v11 is okay, I use v12
is it hard to make a setprefix with mongodb?
No
ok
Just need to add this
ok thank
Just copy mongodb tutorial on yt and modify it
What
No
Don't copy a mongodb tutorial if you don't understand what it does
Literally
Which teaches you fucking nothing
into prefix
You don't take the fucking source code and call it yours
bruh
Legit
that is not coding
who said its mine
Why are you stating to copy shit from YouTube then when its common sense
that it nearly teaches you NIL
Because no one teach me irl
can u send a discord.js for mongodb
oh its python then ill head out
https://www.w3schools.com/nodejs/nodejs_mongodb.asp @faint token
ok thank
im pretty sure i downloaded mongodb
Don't copy paste it, read what it does and how it does it
The guy said just copy this from mongodb source and paste it here and make other things
He dont even say if i must include err in mongoose.connect
i dont copy
Following what they do and not understanding is useless
Following what they do and not understanding is useless
yes

Yikes 
I dont even understand what's he talking about just follow his money database tutorial and modify some
lol
in discord.py, how would you get the voice channel without an initial user sent message? usually i have voice = message.author.voice but it doesn’t work as i wish to play audio in the middle of a game, when only the bot has been sending messages. any ideas bc i’m stumped haha
@unique nimbus Imagine this, git clone <repo> && npm run 
yes
wdym translator app
Im bad at English
google translate dude
What are you trying to do anyways? This is Mongo. You're looking for a key that probably doesn't exist, so that's going to crash unless you catch it and insert the missing key
It sucks give false one - google translate
bruh
@faint token Makes me want to go closed source.
Watch them fail
If they take code
and not understand it
They will fail
and I will laugh
c:
yes
Closed Source = Good
some people who are bot developers usually don’t develop their own shit 🤡
i feel like yall should calm down a bit 😳
I did copy from closed source
bro

dont fucking talk to me
same
if they wanna copy code n understand nothing then that’s ultimately their problem
I dont copy all i made some by seeing those djs page
Can you all calm down, thank you.
because transforming v11 to v12
me calm
Im calm
v12 is unstable but i feel like if u learn v12 right now you will have a much better time in the future
Good news boys, sharding is working now and ready for my framework :)
ok gl
i use v12 and yt videos mostly are v11
???
imma go ahead and repost my question now sksj
v12 is fairly new as well
v12 has been around for a looooong time
i need to try to fix it all by using ?docs command on djs discord serv
Sorry I meant the brand new update
been stable for a few months lol
yo pog
;;;---;;;
in discord.py, how would you get the voice channel without an initial user sent message? usually i have voice = message.author.voice but it doesn’t work as i wish to play audio in the middle of a game, when only the bot has been sending messages. any ideas bc i’m stumped haha
hi
why does let e = require('ms'); e(message.member.createdAt) respond with 47 years?
¯\_(ツ)_/¯
createdAt is a timestamp (in Discord.js it's a date, but in Eris it's a string) from the start of 1970.
hi
and "ms" returns the amount of time the input represents
what do you want to format it as?
you want to know how long ago the member was created?
member.createdTimestamp = timestamp of when the member was created
Date.now() = current timestamp
Date.now() - member.createdTimestamp = difference between now and the creation date, aka how long ago it was
better to use createdTimestamp in this case, since it returns the timestamp as a number, while createdAt returns it as a Date object
oki, thanks
ah you're officiallylost
what does this error mean
Oops! Error: Client network socket disconnected before secure TLS connection was established
bro no star
why not
it means you .close() before you get a tls connection
I know im retarded for this
and Ik it isnt how it really works
but how can I make this work
const config = require("../../../botconfig.json");
module.exports = {
config: {
name: "givepremium",
},
run: async (bot, message, args) => {
if (ownerid.includes(message.author.id)) {
let premium = bot.db.set(`premium_${message.guild.id}`)
message.reply("set this server with premium! Congrats! :)")
}
}
}```
you guessed it
No value specified
my bot now has e🅱️ic spam command that requires manage roles
um, im not gonna diss much, but
why does your comment say //get ownerid from botconfig file
when requiring from ../../loaders/reader
and right under that comment you are using
const config = require("../../../botconfig.json");
because i use the same format of the tops for all my owner commands
does presence count as online/dnd/away?
i think so, not sure tho
ok, just to be safe i'll turn it on
Türkçe botlar ne sıklıkla onaylanıyor?
@fallow steppe example?
Example I have a variable that has your economy amount ( like gambling gives you 100 ), wht'd be the method to show this value and modify a variable value?
you mean this? ```js
let a = 100;
console.log(a) // show 100 in console
message.channel.send(a) // send 100 as a message
a += 100 // add 100 to a, so it becomes 200
console.log(a) // show 200 in the console
Not in console, just a variable within the bot itsself
Ex. My bot has a command called work and gives generated amount for ex 100, I'm not sure how do I modify a variable so it sums your balance with what's generated
Glitch
variables can be modified in any way, for example a += 10 is the same as a = a + 10
^
I see
What'd 'a' be though?
the balance
Ah
you can name it anything
Alright thanks
if the user's balance is 100, and you do balance = balance + 50
be mindful
the balance becomes 150
yes, all variables are in-memory only, they are destroyed when the bot's program exits or restarts
Oof rip
even if its txt / json files
How so?
thats better than nothing
there are a variety of ways
you could use mysql, mariadb, mongodb, postgresql, txt files, json files
its up to you to decide
Yeah I use json files on the bot
assuming you are using javascript
you could use the fs module to read and save json files
id advise against that however
Alright
thisIsMyVariable = 200; // value is 200
doSomeCommand() {
thisIsMyVariable += 100; // value is now 300
}
// bot restarts
thisIsMyVariable = 200; // value is 200 again
doSomeCommand() {
thisIsMyVariable += 100; // value is now 300
}
// with files
thisIsMyVariable = require("./somefile") // value is whatever it is in the file, for example 200
doSomeCommand() {
thisIsMyVariable += 100; // value is now 300
fs.writeFileSync("./somefile", thisIsMyVariable) // save 300 in the file
}
// bot restarts
thisIsMyVariable = require("./somefile") // value is still 300 because it was saved in a file
doSomeCommand() {
thisIsMyVariable += 100; // value is now 400
fs.writeFileSync("./somefile", thisIsMyVariable) // save 400 in the file
}
do bot clients need to enable presence intents to set their game status
been thinking about this one
if so that sucks tbf
hopefully not
@jovial kayak I found this
JDABuilder.setActivity(Activity.playing("Thrones"))```
online lol
GitHub
Java wrapper for the popular chat & VOIP service: Discord https://discordapp.com - DV8FromTheWorld/JDA
it's a bot
hover over it
I need a help can anyone help me?
Hola, alguien que juegue fort y hable español el costa este?
@arctic juniper mention your problem dont ask2ask
So I have a database for levels and want to know if there’s a way I can have my bot figure out who has the highest the second highest then 3rd highest level and then fetch their ID to put into mention form (<ID@>)
for a leaderboard
I currently have a database in a JSON file
please tell me why console.log(bot) makes my process lag
you what
you're logging your entire bot class probably that's why
and iirc it's massive
@white cloak este no es el canal para eso, ve a #memes-and-media y además este no es un servidor para fortnite, lee el nombre del server, ve a #memes-and-media para español
Can i have help, i'm trying to do a custom log channel cmd but i don't really seem to know what i'm doing so if anyone can help me, i'd really appreciate it... this is what i have so far https://gyazo.com/172c77ca2765c2393730d54bbc65515b
imagine being an idiot and not adding
{
"install": {
"include": [
"^package\\.json$",
"^\\.env$"
]
},
"restart": {
"exclude": [
"^public/",
"^dist/"
],
"include": [
"\\.js$",
"\\.json"
]
},
"throttle": 900000
}
``` when hosting a bot on glitch
I was that idiot 😂
.
TypeError: message.channel.sendmessage is not a function at Client.<anonymous> (C:\Users\ianab\Desktop\discord bot\index.js:18:29) at Client.emit (events.js:310:20) at MessageCreateAction.handle (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31) at WebSocketShard.onPacket (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22) at WebSocketShard.onMessage (C:\Users\ianab\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10) at WebSocket.onMessage (C:\Users\ianab\Desktop\discord bot\node_modules\ws\lib\event-target.js:125:16) at WebSocket.emit (events.js:310:20) at Receiver.receiverOnMessage (C:\Users\ianab\Desktop\discord bot\node_modules\ws\lib\websocket.js:800:20)
what does this mean
@merry edge I'm pretty sure it's sendMessage capital M and I'm also pretty sure that's Deprecated you can still use it but most common method now is just message.channel.send
Might be because you havent finished the if statement 🤔 other then that I'm honestly not to sure not really familiar with that command layout.
ill try that
yes its because you havent finished the if statement.
Yeah I thought so
thank you both really means a lot
Np
now it says invalid token? i know it read the token, but then it just says invalid? ;-;
@pine bear Refresh your bot token and re add it to the project usually helps if you are positive it's reading it/you added it properly 🤔
it works while self hosting the code

they had in in glitch beta!
Oof
db.set(...).then is not a function
if(!message.member.hasPermission("ADMINISTRATOR")) {
const adm = new Discord.MessageMember()
.setDescription(":no_entry_sign: **You don't have the required permission to do that!**")
.setColor("#ff9900");
message.channel.send(adm);
return;
}
if(!args.join(" ")) {
const s = new Discord.MessageEmbed()
.setDescription(":no_entry_sign: **You need to mention a role name!**")
.setColor("#ff9900")
.addField("Corect Usage:", "lt!arrole [roleName]");
message.channel.send(s);
return;
}
db.set(`autoRole_${message.guild.id}`, args.join(" ").trim()).then(i => {
const succes = new Discord.MessageEmbed()
.setDescription(`:white_check_mark: **The role has been set succesfully to ${i.text} !**`)
.setColor("#ff9900");
message.channel.send(succes);
})
help ?
what database
quick.db
I still can't figure it out
My bot is having problem connecting to my mongodb database it shows the error EREFFUSED
Can anyone help me
And tell me how to fix it
Have you whitelisted the ip it is hosted on
main file
bot.on("guildMemberAdd", (member) => {
const db = require("quick.db")
let role = db.get(`autoRole_${member.guild.id}`)
if(!role === 'none') return;
else {
try {
member.roles.add(member.guild.roles.find('name', role))
}catch (e) {
console.log("A server tried to autorole an invalid role")
}
}
}
i got
````A server tried to autorole an invalid role``` in console everytime someone joins the server
have you tried logging the error
no
ok so are you going to do that now?
let role = db.fetch(`autoRole_${member.guild.id}`);
if (!role) return;
member.addRole(role);
});```
@earnest phoenix maybe this should help.
@earnest phoenix that means you're not using the async keyword before the function
i can't just get rid of await ?
let role = db.fetch(`autoRole_${member.guild.id}`);
if (!role) return;
member.addRole(role);
});```
@earnest phoenix this?
Supplied roles is not an Role, Snowflake or Array or Collection of Roles or Snowflakes.
first time a got that error
have you ever heard of debugging
inspect your variables
see what their types and values are
try {
await dbclient.connect();
const result = await dbclient.db("musibeth").collection("prefixes").findOne({ guild: message.guild.id })
if (result)
{
const prefix = result.prefix;
} else {
const prefix = default_prefix;
}
} catch (e) {
console.error(e);
} finally {
await dbclient.close();
}
if (!message.content.startsWith(prefix)) return;
How can i fix this error: ReferenceError: prefix is not defined?
EDIT: I got also this in console: DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
you have defined prefix in the wrong place, it only exists within your if statement
you need to declare it within the scope of your event and set the value where you need it
Where have i to add this useUnifiedTopology: true?
@pale vessel Yes i have just replace it with let
i guess you didn't read the error
🤔
yeah thanks i am amazing
np!
but i wan't help with creating a discord bot.
@everyone @here in this development IS THE BEST BOT CREATORS IN THE WORLD!
oh well still the best
i bet im the youngest bot dev here
like 80% of bot devs here dont even know the basics lol
When making a bot, how do you keep the bot online because when i stop the program to run it on it goes offline ?
and you're not a noob
you dont unplug a microwave to keep the food warming in the background
Itll just shut down?
it'll*
if you stop the program you stop the bot
Oh wow
Okay,
So how do i get it to exit out of the program but still keep it running? (if thats possible)
What r u using to host
it'll and itll are practically the same, no-one is going to have a hard time reading their sentence without an apostrophe
wut
I just started yesterday lol
Somthing has to exist and be on 24/7 to run the code 24/7
a vps
noice
Ahh
What is the cause of this problem: MongoError: no primary server available?
i dont really work with mongodb but i guess the connection to the main database server does not exist?
correct me if im wrong
It doesn't always give me this error, sometimes it can connect to the database...
lemme google..
https://github.com/Automattic/mongoose/issues/3634
http://reactivemongo.org/releases/0.1x/documentation/tutorial/connect-database.html#netty-native
does anyone know a way of having javascript send the redirected link?
in my case I pull a url from reddit but its a gfycat url which in a browser would send you to the gifdeliverynetwork .com but the bot just sends the gfycat link which cannot embed the gif in question
Hey guys, how exactly do you develop your bot once you've deployed it to production? Like if I run it locally, my bot suddenly replies twice (prod and dev).
are you on .js?
use different tokens for dev and prod
dotenv is the solution
if you're using github here is the best method;
make a separate file for your token outside of your directory for all of the bot files and use ../config to fetch it
this could upload the bots token, though.
.gitignore exists
oh yeah thats even better
if you dont know how you can fix this simple issue, you may also not know about gitignore.
thats why its dotenv all the way.
does anyone have a solution for the redirect issue
see if there are any redirect instructions in the headers
bot.guild.channels.get("709875174324961383").createInvite
how i can fix this
oh
So i got these https://gyazo.com/172c77ca2765c2393730d54bbc65515b but idk what to do next.. for a custom log channel cmd..
@coral stirrup I tried to follow the links you sent me, but I didn't quite understand how to solve the problem. I don't really understand why sometimes it works and sometimes it doesn't.
how to find a specific role in discord.js v12?
if i do ```js
let role = message.guild.roles.find('name', 'Muted');
i got errors
- you have to pass a function to
.find() - read https://discordjs.guide/additional-info/changes-in-v12.html
if(message.content.startsWith(`${prefix}say`)) {
const args = message.content.slice(prefix.length).split(' ')
message.channel.send(args[1])
message.delete()
}
What is the problem? (say commmand)
let mReason = args.join(" ").slice(22)
at reason section in my embed it say all args from 0 to .... , why ?
So II tried looking about online to help see what there was but there was only a role permission update shown for this
bot.on("roleUpdate", async (oldRole, newRole) => {
});``` but is there a logs for hex color changes. I did newRole.color but it only showed numbers
I do know about oldRole.name and newRole.name but is there a oldRole
hexColor doesn't work?
or just like
undefine
you can convert the num to hex lol
toString(16)
color.toString(16) if that doesn't work
Why a map returns [object Object]
¯_(ツ)_/¯
how did you initialize the map?
ye hexColor works. Thanks flaz
np
@zenith terrace for future reference: https://discord.js.org/#/docs/main/stable/class/Role?scrollTo=hexColor
that's array#map
it's not the same as map lol
ah ok
Write only the first word the bot.
E.G: say test test
only write first test
(Soory my bad english)
@pale vessel
let me see
then just... join the args together?
throw out the command arg out of the array
and join it
boom
they did
they didn't
well you're not supposed to join the args if you want the first word
im pretty sure they want it to say the whole string not just the first arg
Write only the first word the bot.
E.G: say test test
only write first test
(Soory my bad english)
@pale vessel
pepehands
but they're already doing that
that's what i don't get lmao
maybe it's the whitespace
try .split(/\s+/) instead @toxic quarry
Thank you
did it fix the problem?
@pale vessel
at ReplSetState.pickServer (/rbd/pnpm-volume/c6dccffc-7036-44aa-92db-c340940f8112/node_modules/.registry.npmjs.org/mongodb/3.5.7/node_modules/mongodb/lib/core/topologies/replset_state.js:780:12)
at Timeout._selectServer [as _onTimeout] (/rbd/pnpm-volume/c6dccffc-7036-44aa-92db-c340940f8112/node_modules/.registry.npmjs.org/mongodb/3.5.7/node_modules/mongodb/lib/core/topologies/replset.js:1142:43)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
name: 'MongoError',
[Symbol(mongoErrorContextSymbol)]: {}
}```
I want integrate my bot in discord.js with a custom prefix feature, but when i try to connect the bot to a mongodb database, i got this error in console (sometimes all work properly). I had already reported a little over this problem, but they couldn't help me. Could you help me?
seems like an issue with mongo
Yes the problem concerns the connection in mongo. But I don't understand since sometimes it connects and sometimes it doesn't.
try:
- checking your credentials
- whitelisting your server ip
- have a proper connection string
@pale vessel The credentials and the connection string are correct, because sometimes all work. So i don't know
can't really help you with this one, sorry. i have no experience with mongo
How to overrwrite al channels permission ?
read docs
i already did but i don't understand
can someone help me with this error:
close the bracket
use ffmpeg to convert it to the standard format discord accepts and send it through the voice stream
(two channels, 48kHz sample rate)
hm ok I'll try it
most likely your discord library will do all of that for you lol
discord.js and lavalink
which lavalink library?
lavalink.js Version 2.10.0
This is something that might help you out.
thanks
lavalink.js has a .load method to add songs right? as far as i understand, it should support a path for a local file as well
hmm ok I'll check it
Merhaba
cmd is not defined
cmd not defined
i told you already that we can't fix every single error you get
read the error and do research on it instead of not even attempting to read it, screenshotting it and sending it to us saying "solve it lol"
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined send message
error
-_-
have you tried reading the error
l someone english
-_-
you someone english?
This is indeed alot of fun, go on
i know english a little @earnest phoenix
help -.-
doesn't prevent you from reading the error and doing research on it
but since you're lazy
whatever you're calling send on is undefined
member add send message channel
error
i don't speak caveman
🤨
IM DYING
rude but true
@warm marsh send me a related article
Read the documentation
I have a lot of work please
yeah we too
https://discord.js.org you mean
It's not too hard to search "Discord.js" on a search engine like Google and use its dedicated search feature.
they're being lazy and want someone else to fix it for them
Im amused
if i want to add how much channels there is on my serverinfo cmd do i do .addField("Total Channel", message.guild.channel?
Not quite, but there's a property for it with a similar name: https://discord.js.org/#/docs/main/stable/class/Guild
I don't understand that website
How so?
There is an overview of all the properties, methods, and events for a class.
It's easier to navigate than other documentation sites.
if you don't understand how to click on hyperlinks based on what you need
you might need to reconsider what you're doing
crys on a run today
const { Shoukaku } = require('shoukaku');
const ShoukakuOptions = { moveOnDisconnect: false, resumable: true, resumableTimeout: 30, reconnectTries: 2, restTimeout: 10000 };
module.exports = {
async execute(Bot) {
console.log("Creating PlayerManager")
Bot.PlayerManager = new Shoukaku(Bot, Bot.musicNodes, ShoukakuOptions)
console.log(Bot.PlayerManager)
Bot.PlayerManager.on('ready', (name) => console.log(`Lavalink Node: ${name} is now connected`));
Bot.PlayerManager.on('error', (name, error) => console.log(`Lavalink Node: ${name} emitted an error.`, error));
Bot.PlayerManager.on('close', (name, code, reason) => console.log(`Lavalink Node: ${name} closed with code ${code}. Reason: ${reason || 'No reason'}`));
Bot.PlayerManager.on('disconnected', (name, reason) => console.log(`Lavalink Node: ${name} disconnected. Reason: ${reason || 'No reason'}`));
}
}``` This isn't my first time using shoukaku, but im getting this weird error where the ready event for it doesn't fire. any idea why?
Hey. I need your advice. What would you prefer when you are making/using a help command?
A general help command where you have to react with emoji to get help about a category. Then you can return by reacting with ⬅️
A general help command which shows what categories the command has. You can get help about a category by doing <prefix>help <categoryname>, for example .help server settings
Last i'd say
from a user's perspective, to me all forms of paginators are annoying
just give me what i need plain and simple
bc the help command with reactions requires a reaction collecter which eats a lot of ram when used multiple times. Lets say some people want to break your bot and find a way to do so by spamming the help command. not good
put the categories in fields - field name is the category and field value is the list of commands in that category
^
if i want more information about some category or command, i'd expect for the bot to support help category or help command name
that's just me though, i don't know how other people feel about it
yeah
if (msg.content.toLowerCase().startsWith(prefix + "help")) {
const exampleEmbed = new Discord.MessageEmbed()
.setTitle('Some title')
.setDescription(`Testing`)
msg.channel.send(exampleEmbed);
}
ok so it works but im getting a coming error msg in chat instead of in my cmd prompt / node prompt
unfortunately i broke my magic crystall ball and i cannot read minds anymore so you'll have to tell me what's the error
lmao ur right i shouldve
and its not really a error, its a msg being sent in to the channel
i have a .catch(e) function on other cmds
but its now on its on help when i didnt put it.
.catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});
you probably have something outside of an if closure
in a embed to set the colour do you go 900093 or #900093
(its my colour thing i want to use)
no ik
but is use displayhexcolor
so the role they have the color of tht role is the embed
if its blue the embed is blue
it depends on the library you use
officially, discord's api only accepts a decimal format of colors
do I need to add a return before throw new Error(...) in js?
Nothing after a return statement is executed, so no
How can I send a custom emoji with a message?
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.
fixed
anyone know how to make mute timed discord.py
maybe this might help https://stackoverflow.com/questions/52788653/how-would-i-add-a-mute-timer-to-my-discord-bot-discord-py
@earnest phoenix still waiting for your elaboration, what do you mean with mounting
in discord.js how do i like check how many guilds my bot is in and then respond with the number of guilds
(Without any names)
and then using .size to get the count
so
.guilds.size
presumably yeah, try it and see
alright tysm
Anyone who could help a bit with React (TypeScript)?
I have an authentication using the Context API (& localStorage for persistence) but whenever I am authenticated (in localStorage) and reload the page, it just resets the authenticated to false.
export default (props: any) => {
const prevAuth = window.localStorage.getItem("auth") || false;
const prevAuthBody = window.localStorage.getItem("authBody") || null;
const [authenticated, setAuthenticated] = useState(prevAuth);
const [authBody, setAuthBody] = useState(prevAuthBody);
useEffect(() => {
window.localStorage.setItem("authenticated", `${authenticated}`);
window.localStorage.setItem("authBody", authBody!);
}, [authenticated, authBody]);
const defaultContext = {
authenticated,
setAuthenticated,
authBody,
setAuthBody,
};
return (
<RootContext.Provider value={defaultContext}>
{props.children}
</RootContext.Provider>
);
};
The only time I change the authenticated is whenever I actually authenticate (this code)
const json = await response.json();
if (json.access_token) {
context.setAuthenticated(true);
context.setAuthBody(json.access_token);
setToken(json.access_token);
} else setToken("invalid");
https://gyazo.com/1714722331d46d03b11ac38705b9e389 do i need to do npm i ms --save
One message removed from a suspended account.
stop being a help vampire
One message removed from a suspended account.
@nimble escarp you're setting it as "authenticated" but getting it as "auth"?
Anyone know why 2 of them are undefined?
my code is
client.on("message", (message) => {
let args = message.content.substring(prefix.length).split(" ");
switch (args[0]) {
case "botinfo":
let sicon = message.client.displayAvatarURL;
let serverembed = new Discord.MessageEmbed()
.setTitle("Bot Information!")
.setColor("#f9f162")
.setThumbnail(message.guild.iconURL())
.addField("Bot Uptime:", client.uptime)
.addField("Emojis:", message.guild.emojis)
.addField("I was created at:", message.client.createdAt)
.addField("I joined this server at:", message.client.joinedAt);
return message.channel.send(serverembed);
break;
}
});
Well, authenticated is the state variable from the react useState hook.
and auth is in localStorage
well i dont see you doing setItem("auth") anywhere in that code
It's there
useEffect(() => {
window.localStorage.setItem("authenticated", `${authenticated}`);
window.localStorage.setItem("authBody", authBody!);
}, [authenticated, authBody]);
where?
you're doing setItem("authenticated") but youre getting it as getItem("auth")
@still merlin client.createdAt and client.joinedAt are not a thing
@quartz kindle You're a godsend. Stupid mistake on my part, works fine now.
Thanks once again 
👍
My bot is having a problem where i change the prefix to something else but when i try the old one it still works like for example the prefix is . but : works aswell
how do i fix that?
@earnest phoenix Pff, people these days can't even read minds, smh.
ikr
Hey guys in DiscordJS, how can I log the event name without making a hardcoded value? Does the client.on actually log the type of event itself or do I have to hardcode it?
I want to get the event from the client when each type is fired, so I dont have to make functions for each type of event
use reflection
nevermind i forgot node.js' eventemitter is some hacky shit and you can't use reflection on it
How i can get my vote value with dblapi.js
is there something in discord.js that finds the author of a command's permissions and sends there permissions?
html to json? are you crazy?
how do i print a list inside a list?
i tried to do
x[0][0]
but it seems to print the first letter of the first list
wait am i suppsoe to do x[0, 0]?
how do i print a list inside a list?
i tried to do
x[0][0]
but it seems to print the first letter of the first list
@narrow kettle imagine it being like this:```
0: [0, 1, 2, 3],
1: [0, 1, 2, 3],
2: [0, 1, 2, 3],
3: [0, 1, 2, 3]
so [0][0] will get the first index of the first row
to print the whole arra (row) you just need to get [0]
isnt it like this tho?
0: [0: [0, 1, 2, 3], 1: [0, 1, 2, 3], 2: [0, 1, 2, 3], 3: [0, 1, 2, 3]]
wait a sec, ill send you the function that I used to make the string into a list
note that I know little less than 1% of python
so I might not be able to read it
oh, nvm, though you were using python
How many times is a bot to change his status? I don't ask this for myself but I see a bot here that's updating like every 8 seconds or something
How many times is a bot to change his status? I don't ask this for myself but I see a bot here that's updating like every 8 seconds or something
@nocturne grove 8 seconds is api abuse
def open_file():
f = open("Pink_Floyd_DB.txt", "r")
text = f.read()
f.close()
x = text.split('#')
for i in x:
i = i.split('*')
x.pop(0)
return x[0][0]
the file is just full of songs and albums, the first split, splits the string into albums(Which works), and then the second splits should split the songs inside the albums(which i dont know if it works because i cant manage to print it)
yeah already thought that
idk what to do with it now but just wanted to be sure 😂
@narrow kettle so that's correct
it's a 2d matrix, which has albums as rows and songs as columns
wazzup nubcakes ❤️
html to json isn't a thing but xml to json is
probably you're getting the album as a text
ah
how am i suppose to do that there is a list taht contains the albums which contains the songs then?
getting [0] of that album would return y
mhm
you need to use objects
wdym use objects
artist A contains N albums, which contains N songs
I'll use json code as example
{
"id": 0,
"name": "Linkin Park",
"albums": [
{
"id": 0,
"name": "Hybrid Theory",
"songs": ["a", "b", "c"]
}
]
}
for example
so when you do artist.albums[0].songs you'll get all the songs of that artist
obviously for python you'll need to create a proper object (unless python works with json)
ty :)
checkchannel is null. But when I try to check that, it gives false
can you help me .
wrong parameter
same
is it still giving false?
yes
@lyric mountain is there any relevant article I searched but couldn't find any material to fix

well, with that two-line error I can't help much
all I can say is: check your parameters
ah
resolved 👍
another entry to DiscordIDE: What is it and why not to use book
@earnest phoenix can you show your code
@summer torrent
const db = require("quick.db");
module.exports = async member => {
if(!member.guild) return;
if (db.has(`autoROL${member.guild.id}`) === true) {
var i = await db.fetch(`autoROL${member.guild.id}`)
if(!i) return;
var role = member.guild.roles.find(r => r.id === i);
try {
member.addRole(role)
} catch (e) {
console.log('Hmm..')
}
}
}```
?
-.
What?
that's poorly indented
when I finish trying to read it
if (msg.content.toLowerCase().startsWith(prefix + "mute")) {
var mem = msg.mentions.members.first();
if (msg.guild.roles.find("name", "Muted")) {
mem.addRole(msg.guild.roles.find("name", "Muted")).then(() => {
msg.channel.send(mem.displayName + " has successfully been muted!");
}).catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});
}
}
OOf
does anyone know the code to give role?
for discord.js
@lyric mountain help me solve it when -.-
@earnest phoenix isn't addRole()'s arg a string?
@cosmic girder not working?
like, addRole(ID)
@earnest phoenix it works yes but doesnt give him the role
@lyric mountain no
show the whole error
addRole(ID) wont work because of the fact its gonna be in different servers
ID is unique for each entity
exactly
no two roles have the same id, regardless of being in different servers
@still merlin this question could not be more vague
@lyric mountain exactly im trying to make it so they get muted so addRole(id) wont work
@lyric mountain
how do bots with many shards scale their bot? If their bot is added in thousands of servers every day, how could they scale automatically?
-.- yes
@lyric mountain exactly im trying to make it so they get muted so addRole(id) wont work
@cosmic girder addRole(id) will always work, unless you're trying to add a role to a member that's not in that server
@earnest phoenix use addRole(role.id)
You can pass a role instance or the ID
well :D
do a console.log(role)
ok
btw that try catch statement won't work since <Role>.addRole returns a promise.
it would
if (msg.content.toLowerCase().startsWith(prefix + "mute")) {
var mem = msg.mentions.members.first();
if (msg.guild.roles.find("name", "Muted")) {
mem.addRole(msg.guild.roles.find("name", "Muted")).then(() => {
msg.channel.send(mem.displayName + " has successfully been muted!");
}).catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});
}
}
@cosmic girder use this:```js
msg.guild.roles.find("name", "Muted")).then(r => {
mem.addRole(r);
msg.channel.send(mem.displayName + " has successfully been muted!");
}).catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});
anyone know why im getting a error
see if it works
you can't return a value outside a function
["command"].forEach(handler => require(`./handlers/` + handler)(bot));
error
require(...) is not a function
did you export a function in the file
no
you don't need return
@pale vessel I removed it and got more errors
what kind?
show
no
@earnest phoenix export it
@lyric mountain
tht wouldnt work you have
msg.guild.roles.find("name", "Muted")).then(r => {
mem.addRole(r);
msg.channel.send(mem.displayName + " has successfully been muted!");
}).catch(e => {
msg.channel.send("Please mention the users @");
console.log(e);
});
Amazri I think you're missing a ) around setThumbnail


