#development
1 messages ยท Page 946 of 1
So put the ID in "ID HERE"
yes
@clear wraith there is a test feature on dbl website. your users dont have to actually vote for you to test ๐
On your bot's edit page
Ahhhhhh
That's how you also set your password
VPS
@earnest phoenix import traceback
So input your VPS IP, unless you've got a domain etc
http://vpsIP:5000/dblapi
i fixed the status, but can someone tell me how to make a role for the bot
a role?
like when he join in server to get it auto like MEE6, role Mee6
just give a role to the member inside a join event
Noo, i mean role SyntaBOT and when he join the server to get it without my touching in the settings
you need to define the permissions your bot needs in the invite link
The bot receives a role automatically based off of it's permissions
ah, that's given to your bot whenever you invite it with at least one permission
use an invite generator
omg, im really that much stupid ? ๐
oooohh, i was actually wondering about that. my latest bot didnt get a custom role when i added it to my main server, was wondering why. guess its cause he asked for no perms ๐
somebody know how the bot send a DM message to people who voted?
pretty sure you just .send() to the specific user rather than a channel
something like client.users.cache.get('userid').send('you voted')
ok
When I awaitMessages, it seems that the content it gets is toLowerCase. how can I keep the caps? Djs v11
you define the webhook url you want in the config for the dbl api
and on the bot edit page on dbl site
the url depends on where your bot is hosted
I can't understand where to get it...
if your bot is hosted on a vps, the url is the vps ip address and the port you define in your dblapi.js
ewww, gforce update for valorant :/
any valorant api yet? like for getting game stats?
google says 'not yet' ๐
Third party developers can now sign up in the Riot Developer Portal to sign up for API access to develop third party VALORANT applications or products.
@neat ingot
1|audio | at WebSocketManager.handlePacket (/root/audio/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
1|audio | at WebSocketShard.onPacket (/root/audio/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
1|audio | at WebSocketShard.onMessage (/root/audio/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
1|audio | TypeError: Cannot read property 'host' of undefined
1|audio | at Function.load (/root/audio/node_modules/lavacord/dist/lib/Rest.js52)
1|audio | at MusicManager.getSongs (/root/audio/src/structures/MusicManager.js:82:35)
1|audio | at Object.run (/root/audio/src/commands/play.js:7:48)
1|audio | at MusicClient.<anonymous> (/root/audio/src/structures/MusicC```
Help
host is undefined
Uhmm
For a discord.js statistics bot, that records textmessages etc. i want to keep a log of the sent messages ([guildId, channelId, userId, data]).
But as i dont want to call the database (mysql) every time a message is written, i want to cache the changes and flush them together in one transaction.
How should i store the cache for these statistics? I was thinking attach a Map to the client object. Then i could also easily periodically retrieve the data in the shardingManager and even send all shards in one transaction.
You could write all entries to the database when it exceeds a certain amount
okey and add it to the client object is safe? using the sharding manager to collect the data from all shards for this node is also ok?
should be fine, if you dont accidentally duplicate data across shards
Is it possible to check if a user is joined to a server by a self-created Invite-Link?
"The reason is" + reason ? `${reason}` : 'no reason' + "by" + message.author.tag
// This will return
// 1. The reason is ${reason}
// 2. The reason is no reason by ${message.author.tag}
// But I want it to be
// 1. The reason is ${reason} by ${message.author.tag}
// 2. The reason is no reason by ${message.author.tag}
How can I do that?
hello I will have a question for you EVERYONE after 2 days, if we do not pass v12 the boots will close this truth
@earnest phoenix put it in parenthesis
sometihng + (reason ? reason : no reason) + something else
thanks ๐
hi back! it's about mongoose again.
I created a variable with a model that is supposed to be saved in the 'crumble' collection. BUT in Mongo Compass, I don't see anything. But when I use the <model>.find() method, I can see all the things I added with the model! Why isn't that displayed in Compass? js var userSchema = new mongoose.Schema({ id: String, tag: String, coins: Number, xp: Number, bio: String, msgCount: Number, meanMsgCount: Number, meanWordsCount: Number, dblVotes: Array, upvotes: Number, givenUpvotes: Number, lastUpvote: Number }) js const userModel = mongoose.model('crumble', userSchema) ```js
async function updateUser(userID) {
let user = await client.users.fetch(userID)
let newUser = new userModel({
tag: user.tag,
coins: 0,
xp: 0,
bio: ``,
msgCount: 0,
meanMsgCount: 0,
meanWordsCount: 0,
dblVotes: 0,
upvotes: 0,
givenUpvotes: [],
lastUpvote: 0
})
newUser.save(function (err, newUser) {
console.log(`user saved in crumble.`)
console.log(userModel.find()) // THE PART I WAS TALKING ABOUT RIGHT ABOVE
})
}```
ok nice.
about the datastructure.. i could make an array of objects,with the fields guildId, channelId, userId, data.
However, i of course want to add the stats from the same user to his already existing entry in the array. So if i do it that way, wouldnt it cause too much searches, if every messages need to search the whole datastructure?
To solve this i could maybe make an object, where each field is one entry, or a map, whereas the key of that field is string concatenated guildId+userId+channelId. Would that be faster?
Also, i could simply add every single event to my cache, without stacking events from the same user/channel (and have duplicate keys in my cache), and do the sum up at the point of saving the cache to database?
Is it possible to check if a user is joined to a server by a self-created Invite-Link?
@earnest phoenix , the Discord API doesn't provide this data as far as I know.
@spice smelt did you refresh your compass after adding the data? it doesnt auto refresh unfortunately
also, you can design your schema like this:
notice: i have required fields, and default values. so when im creating an instance of a model i dont need to provide all fields, it will auto populate them with default values. i only need to give the required fields ๐
(if i do give a value for a property that has a default value, the given value will overwrite the default)
that formatting hurts
โค๏ธ
hi
how can i get the last message my bot sent in a specific channel?
using eris
even id, anything which is unique about the message or the actual content
!ping
wrong channel
How to make this api panda url random image https://some-random-api.ml/img/panda to work like cat command. .get dont work
the way u use an api
its a promise
u have to fetch it, using node-fetch
so like
fetch('url').then
but don't use callbacks doe
hey, whats the code for pinging user used the command
the fuc+ im sleeping all day and can not remember nothing ๐
js
what language glassykiller?
@fresh hatch the library?
if(message.content.includes('<@!id>')) do whatever
Officially what?
which library r u using
im on glitch
thats not a library
you mean JS, PY ? :?
that's a programming language
yes, but what he mean
how to clear a JSON?
language?
node.js
tony kun ^^
o ok
i believe its uhhh
delete.json[key]
orr.... u can use splice
i'm not too sure
if (message.content.includes("<@id>") || message.content.includes("<@!id>")) @earnest phoenix
key =?
it's delete something.key
oh, i was close ๐ฟ
before:
{"418087389337223169":{"pseudo":"418087389337223169","nombre":0},"353425485516242944":{"pseudo":"353425485516242944","nombre":0},"296303601490329600":{"pseudo":"296303601490329600","nombre":0},"581912619359666196":{"pseudo":"581912619359666196","nombre":0},"451373987469983752":{"pseudo":"451373987469983752","nombre":0},"435459271438761995":{"pseudo":"435459271438761995","nombre":0},"370781128258486283":{"pseudo":"370781128258486283","nombre":0},"508709897345433602":{"pseudo":"508709897345433602","nombre":0},"552228849245749258":{"pseudo":"552228849245749258","nombre":0},"697530944785088643":{"pseudo":"697530944785088643","nombre":0},"697092345711296574":{"pseudo":"697092345711296574","nombre":0},"152048666486636544":{"pseudo":"152048666486636544","nombre":0},"528556830490886154":{"pseudo":"528556830490886154","nombre":0},"576120314048675890":{"pseudo":"576120314048675890","nombre":0},"339473820723445760":{"pseudo":"339473820723445760","nombre":0},"566437516639469585":{"pseudo":"566437516639469585","nombre":0}}```
after
```json
{}``` you understand ?
oh, then
const mutedjson = require("./data/muted.json")```
you want to clear it and save it in a json file again?
you can simply save an empty object and overwrite the file
I just want the clear to be 0
fs.writeFileSync("./data/muted.json","{}")
then you also need to clear the require cache
its something like
const data = fs.readFileSync('./data/muted');
const json = JSON.parse(data);
fs.readFileSync('./data/muted', JSON.stringify(json, null, 2);
``` (i got this from <https://stackoverflow.com/questions/40537990/removing-json-object-from-json-file> )
tim
do u know how i get the last message my bot sent in a specific channel?
using eris
id, content, anything about the last message it sent
you have to fetch messages and filter them
probably channel.messages.fetch()
i can't find anything in the Message class about it
i'm not trying to get the last message of a channel
i'm trying to get the last message of a user
@digital ibex @quartz kindle neither works: /
what did you do?
I tried : js writeFileSync("./data/muted.json",JSON.stringify("{}"))
or
const data = fs.readFileSync('./data/muted.json');
const json = JSON.parse(data);
fs.readFileSync('./data/muted.json', JSON.stringify(json, null, 2);```
I have a question... How can I remove a user from my team in the Discord Developer Portal?
What's that unsend message method
@wicked pivot did you just copy and paste it or what? also Lost's code has a typo
if you just copy and paste then it wont work
and your JSON.stringify() is wrong
@slender thistle
it just deletes it without a reason
lmao
hang on why is it .call

i had a feeling it was gonna be a poorly worded 'delete' function ๐
The call() method calls a function with a given this value and arguments provided individually.
but... why not just .deleteMessage(args)
apply() does the same but you provide arguments in the form of an array.
oh, thank u tim
my music bot stopped working when it joins the vc channel nothing plays
0|npm | ... 4 common frames omitted
0|npm | Caused by: java.io.IOException: Invalid status code for video page response: 429
0|npm | at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeTrackDetailsLoader.load(DefaultYoutubeTrackDetailsLoader.java:39) ~[lavaplayer-1.3.47.jar!/:na]
0|npm | at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeTrackDetailsLoader.loadDetails(DefaultYoutubeTrackDetailsLoader.java:26) ~[lavaplayer-1.3.47.jar!/:na]
0|npm | ... 7 common frames omitted
it was working this morning
for how long
how can you .replace(); multiple words with something?
for how long
@hardy vector, probably a few hrs
oh
you can use regex with the g flag
does using the i flag rather than toLowerCase() affect performance?
regex is generally slow, toLowerCase() creates a copy of the string
so idk
but probably toLowerCase() will be faster
does anyone have any good resources to learn regex
regex is hell
no u
no ur pfp
why
regex is good
regex is what happens when mathematicians try to program
lmao
I'm getting an Error: ENOENT: no such file or directory, scandir '../Comandos/Miscelaneo/' on Javascript
my code: const Comandos = readdirSync(`../Comandos/${Directorios}/`).filter(d => d.endsWith('.js'));
no such file or directory
-owner @splash
Please include a bot mention or ID
@indigo tapir the error literally says what your problem is
you don't have a folder called 'Miscelaneo' inside of your 'Comandos' folder
regexp is corona
-botcommands @earnest phoenix
@earnest phoenix
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
keep bot commands in testing channels
my code:
const Comandos = readdirSync(`../Comandos/${Directorios}/`).filter(d => d.endsWith('.js'));
@indigo tapir are you spanish bro?
Yeah
you don't have a folder called 'Miscelaneo' inside of your 'Comandos' folder
@copper cradle I actually do
show your files
My messageReactionAdd doesnt work discord.js
https://ghostbin.co/paste/dvz6o
no errors and the console.log doesnt even return anything
i have raw events on
this is my raw events https://ghostbin.co/paste/qcjwn
nvm
raw events dont work
guys, can someone tell me the code for pinging user who used the command
like !hey
Hello @fresh hatch
how do i add a reaction to a message? Discord.js
Also why this is not working?
client.createMessage(msg.channel.id, "Hello ${user}, and welcome!") // Send a message in the same channel with "damn it"
(g.maxUses).replace("0", "โ")```(node:517) UnhandledPromiseRejectionWarning: TypeError: g.maxUses.replace is not a function
@fresh hatch which library are you using?
Discord.js
discord.js doesnt have createMessage()
(fetchInvites)
๐ฆ
discord.js uses message.channel.send()
and to mention people you just need to send <@USERIDHERE>
t appears your bot, SyntaX Bot, has connected to Discord more than 1000 times within a short time period. Since this kind of behavior is usually a result of a bug we have gone ahead and reset your bot's token.
the hell? ๐
what did you do lol
nothing, just my bot is hosted on glitch and after all words its restarting
then thats why
Using PM2?
why is it restarting on all words?
idk act ๐
So I'm guessing it tried to start, errored out, repeat 1000x. Lol
@quartz kindle Hello <@USERIDHERE>, and welcome!
yes
its writing that in the chat
of course, you need to put a valid id
you can get the author's id from message.author as i said
message.channel.send( `Hello <@${ message.author.id }>, and welcome.` );
Hello <@${ message.author.id }>, and welcome!
Backticks, not single quotes
client.createMessage(msg.channel.id, "Hello <@${ message.author.id }>, and welcome!") // Send a message in the same channel with "damn it"
this is the code
Not quotes. Backticks
let id = "12345";
"this is " + id + " concatenation"; // "this is 12345 concatenation"
'this is also ' + id + ' concatenation'; // "this is also 12345 concatenation"
`this is ${id} templating`; // this is 12345 templating
notice the different quotes
Fack
Backticks - `
quotes "
message.channel.send(`Hello <@${message.author.id}>, and welcome`)
message.channel.send("Hello <@"+message.author.id+">, and welcome")
message.channel.send('Hello <@'+message.author.id+'>, and welcome')
```all 3 are the same
nope
all 3 result in the same
if(message.content.includes('test')) {
message.channel.send('Hello <@'+message.author.id+'>, and welcome')
}
});
this is the code, right?
Should be using DJS v12, which is just message, not messageCreate
just message
@fresh hatch does your bot use some kind of auto restarting thing like node.js's nodemon? i had the same issue whenever a file got changed cause of autosave, my token got reset a few tiems
๐
If you sent 1k login requests you're doing something wack.
Such as constantly editing your files without a watch.json file to set a time before it restarts
I'm on websites top.gg Gadi Jesse would like to turn back from the bot for me.
What do I do?
what
make more sense plz?
so you want to add your bot onto top gg like i said?
Yeah.
see link above ๐
then i dont know im afirad ๐ฆ
how to upload a bot xD
That's an error.
wut
The code returned by the discode has expired or is not valid Please try again.
An error ...,
are you logged in? maybe you need to be logged in first?
hmm, it tried to log me in automatically lol
@scenic kelp so I didnโt know in what chat to ask this, but Iโm working on a moderation bot... and if it gets accepted, do you guys want me to disable it here? (Iโm not done yet and havenโt uploaded it yet but just a heads up)
there's no need to disable it here unless it attempts to post messages without a user's input
Well it deletes messages.... thatโs the thing
It won't be able to delete messages here
Probably you arenโt even gone give that perm to a bot tho and ye I tought that
Ok
Thanks
Now that I think about it, it does send messages... like if I say a swear word it sends a message to not use that word again but it does delete that message after 5 sec
you will need to disable that for this server
Ok
Was probably gonna disable it anyway cause this server spammed my other bot for some reason and idk why lol
this server does a lot of bad things to bots
Hi, A Quick Question. I made a code that if the Voicechannel is empty it should leave it but that doesnt work.
Here is the Code:
let voiceconnection = "false"
setInterval(function(){
let members = 0;
client.channels.cache.get("714808804294000672").members.forEach(m => {
if(m.user.bot) return;
if(m.id == bot.user.id) return;
members++
})
console.log(members)
console.log(voiceconnection)
if(members < 0 && voiceconnection == "true"){
console.log("false")
client.channels.cache.get("714808804294000672")
.leave()
voiceconnection = "false"
}
if(members > 0 && voiceconnection == "false"){
client.channels.cache.get("714808804294000672")
.join()
.then(connection => {
var playing = new Discord.MessageEmbed()
.setTitle(":musical_note: | Now Playing")
.setDescription(
`Connected\nPlaying: โถ Blueflame Radio\nYou hear nothing? Please use [prefix]contact`
)
.setFooter("To set the volume use: r>vol [volume]")
.setColor("GREEN");
// client.channels.cache.get("609313142194962442").send(playing)
connection.play("URL");
voiceconnection = "true"
})}
}, 3000)```
no error given. nothing
let user = message.mentions.members.first();
${user.tag}``` idk why but the output is undefined when the message gets sent.
nvm
it's supposed to be users not members smh
@earnest phoenix user.user.tag
No?
I just said I realized I put members instead of users
@sterile minnow why are you using an interval?
there are much better ways to do that
and you're checking if members is smaller than 0, but i dont see how it could ever be smaller than 0
Oooh. Cuz its a bit laggy
you should be using the voiceStateUpdate event instead of that interval
and you can check the member's size, no need to count them
What's the best language for a discord bot?
Is it true that java is one of the best ones, expecially with sharding?
There's no best language
I mean, there are some which are more efficient in some cases
Yeah but it all depends on what you specifically want for your bot, there's no objective best
All depends on what you plan to do
someone created a welcome bot for me
All depends on what you plan to do
what do you mean with that, what the bot does on discord?
Uhm, my bot creates temporary voice channels, you know what that is?
whats the best way to make a music system using discord.js?
Uhm, my bot creates temporary voice channels, you know what that is?
Note that channel creation has a quite small quota per hour
You might hit the ratelimit very quickly
Seriuosly?
Yep
Wait, there is a bot who does this and it's in over 22000 servers
and I don't even know if it uses sharding
Anyone know the best way to create a music system using discord.js 11.5.1
there isn't a "best way"
You might hit the ratelimit very quickly
does sharding fix that?
There is so many ways, im just wondering which is the best option.
im fixing to add music to my bot
It's just "good code"
Sharding just splits your bot in N versions of itself, each dealing with their own slices of guilds
Maybe, MAYBE it might affect ratelimit quotas
But I've never sharded, so idk
Yeah, cd is the safest way
cd?
Cooldown
yeah that's for sure
I've tried to invite the bot to my server but it won't join
https://pastebin.com/YnNYXmV7 could someone help me make the numbers under the sliders?
the for statement is suppost to do that
what am I looking at
i equals 1
while i is bigger than 14
i++
that will never run
probably meant to be a <
but why not a for loop?
considering it was made for counting 
can someone help me make a bot!
As in what. Help develop it from scratch? Solve an issue you're having?
what means help?
if you havent started at all, then head over to google to find some guides
and if you dont know any programming, and really want to write your own, learn some programming first ๐
i need help making one from scratch @sudden geyser
we only help people with errors and stuff here, we cant really help to make from scratch, though you can find guides online
bot just asked me that for a quiz question ๐
Errr....not that there's a common iterator for arrays
Depends on what you want to do
i was thiinking the same tbh. like, i guess most common is a for loop, but ive iterated over arrays with while, as i shift or pop them off the array many times
@quartz kindle Do you know how to use cheerio?
I have a few question on how it works but I'm parsing over 200k lines and its hard to figure out what I need to select.
isnt that just the same as regular jquery ?
yeah I dont know jquery
I am trying to find this data here
<script type="application/ld+json" id="videoObject">```
I'll try my chance to get a help here, sorry, too lazy to rewrite.
Do I select it like this $('script.id[videoObject]')
been a while since i jqueried, but im sure $('#videoObject') is sufficient
yea it should be
so you could do something like $('#videoObject').text() to get the content of the html element
what is like the code for it to have a prefix for the commands?
what language
English
coding language....
idk
java
java or javascript
javascript
ok
Make a new file called config.js
"token": {"your bots token"},
"prefix": {"prefix"}
}```
and then put that in it
dont put the {}
wait so in {
"token": {"your bots token"},
"prefix": {"prefix"}
}
dont put the "{"
"token": "your bots token",
"prefix": "prefix"
}```
there
sorry for the confusion
you need the { } around the code
dont forget to load it in your main .js file your executing or it wont work
thats why i just said main .js people call them random stuff i did mine ๐
i thought u said main.js
lol
i didnt see the space
ye that works too
you have to download the package tho
Its called dot env
i think....
o
meanwhile my bots hosted on a pi3 , can i use .env instead too ?
bruh
wdym
wdym how
wait i got this msg after putting in the token
Unexpected token, expected ; (17:9)
you want inv to my server?
put ;
after }
js is gae
C# is where its at
or ye python
i havent done python doe
nO!
dont share that here
delete it
@earnest phoenix id change my token now if i was you
i did
ah ok
wait but did i do the coding right?
i think so
wait it keeps saying
Unexpected token, expected ; (16:9)
so is the .env a module for discord .js can i install it with npm then alter my code to load it from the .env file instead of .json?
oh sweet ty
i havnt done it yet but i will soon , can i just leave rest of data in the .json like prefix yes?
because im planning on using api's for other things
An api for prefix?
no , but what im asking is can i not just leave my prefix in the .json too or im going to have to change alot of code
i have it load commands from separate files ie the functions are all seperate and all depends on the .json for the prefix
im sure ill figure it out thanks though
Ok so... I just coded a messageUpdate and a messageDelete command for my events folder. And when i go to edit a message it spams that I edited the message 200000 times. Why?
no break?
No. It doesn't stop
It keeps doing that, and then it stops after it sends it 2 million times
2 possibilities
- Discord has a seizure
- You misconfigured the event handler and edit the log message, resulting in the bot entering a infinite loop
Ill grab the code
This is what is in the Index.js file for both of them.
require("./events/messageUpdate")(oldMessage, newMessage);
});
client.on("messageDelete", async (message) => {
require(".events/messageDelete")(message);
});
That's right... Isn't it?
:p
@earnest phoenix can you send us the code for it (please make sure to censor all important information such as bot token and api keys please)
ok
so we can take a look on what's wrong
if (!message.content.startsWith(prefix) || message.author.bot) return;
if (message.content.startsWith(prefix + "ping")) {
message.channel.send("pong!");
} else
if (message.content.startsWith(prefix + "foo")) {
message.channel.send("bar!");
}
});
client.login("SuperSecretBotTokenHere");
client.on("ready", () => {
console.log("I am ready!");
});
client.on("message", (message) => {
if (message.content.startsWith("ping")) {
message.channel.send("pong!");
}
});
client.login("token");
client.on("message", (message) => {
// This code runs when the event is triggered
});
client.on("message", (message) => {
// This code runs when the event is triggered
});
i gtg so i will be back tmr
uh
this is wrong on so many fucking levels
@earnest phoenix here is the messageUpdate file.
const { MessageEmbed } = require("discord.js");
module.exports = async (oldMessage, newMessage) => {
let embed = new MessageEmbed()
.setTitle("Message Edited")
.setColor("GREEN")
.setDescription(
`**${oldMessage.author.tag} Edited a message in <#${oldMessage.channel.id}>**`
)
.addField("Old Message", oldMessage.content, true)
.addField("New Message", newMessage.content, true);
let channel = oldMessage.guild.channels.cache.find(
ch => ch.name === "โserver-log"
);
if (!channel) return;
channel.send(embed);
};
can you help me tmr @earnest phoenix
I can not
but this can
@clear wraith that looks okay to me
then its just discord having a seizure
try killing all processes your bot runs on and completly restart it
So.. I can't do anything about it?
So... Redo the Index.js file?
restart everything and hope
Or restart it in the terminal
restart the node process
Ok
like kill off node entirely and start it over again
this might seem like a weird question, but does anyone know a good solution on how to make a countdown?
i dont want to edit the message every second for obvious reasons
and i tried using an emoji for a countdown
only problem is that if they leave the channel the emoji resets
and i cant really find any consistent gif designs cause I have different times for countdowns
you can change the interval of the message being edited
You could edit the message in jumps, E.g. every 10 seconds until you get to like 10 then use a gif
it counts down every second but only edits it every 10 secs or so
its a 30 second countdown
ah
well i guess doing 30, then 20, then 10, then (maybe) 3, 2, 1 would be a good idea
im not sure about the ratelimits though
more to do with html & php, but how can you have a file that can only be downloaded if you're logged in?
How would I access the children key in this object? Sorry kinda still trying to get the hang of this
initialize {
'0': <ref *1> {
type: 'script',
name: 'script',
attribs: { type: 'application/ld+json', id: 'videoObject' },
children: [ [Object] ],
next: {
type: 'script',
name: 'script',
attribs: [Object],
children: [Array],
next: [Object],
prev: [Circular *1],
parent: [Object]
},```
I think is obj[0].children[0]
next.children[0]?
@earnest phoenix check if the user is logged in and the session key is valid, then send the file
else send a null byte or send nothing
or send status 403
no but
if they just visit the link, for example text.exe
you mean per ftp server
or per express server
with express you can check if a cookie was sent, if yes, check that cookie
if not, 403
mk ill try that
how do bots make status pages for their shards?
msg.channel.send(new Discord.Attachment(videoMeta.videoUrl, 'video.mp4')).catch(console.error);```
TypeError: Discord.Attachment is not a constructor
wot
@magic jackal its Discord.MessageAttachment
oh
how do bots make status pages for their shards?
@gritty bolt
anyone know anything about that?
do we get on update webhooks from mongodb?
whats the way to add roles to a user
click on their avatar
Any regex masters? I want to remove everything starting at ? in my url here however this is my current code, is this smart?
const string = "https://www.tiktok.com/tesdt/video/6822417395412520198?lang=en"
let urlRegex = /(https?:\/\/[^ ]*)/;
let url = string.match(urlRegex)[0];
console.log(url.substr(0, url.length - 8))```
why not just split?
idk that is why I asked
so basically you just want Lang=en?
I want to remove that part
oh
I just dont know regex that well
would split("?")[0] work?
yea, should work fine
I just worry if its gonna contain it anywhere else in the link by mistake
but its a url so it shouldnt
you should try to avoid regex since it tends to be slow
I c. thanks
Does anyone know why my wavelink music player doesnt play youtube music sometimes?
rate limited?
Apparently lavalink cant get rate limited
no way
idk saw that on reddit
If it a rate limit problem, how long do i have to wait for it to comeback to normal?
Someone knows how to reduce ram usage?
with discord js is there a way to fake a member joining using my eval command
yes
how could i do that?
thank you
Would any user here happen to know the box name of whatever is behind the img for bot's icons on top.gg pages?
Having an issue with the line on the right and bottom from what the default "Shadow" box sort of looks like, but can't seem to find the name of what I'm looking for in Aspect View to try and get it removed
OIII never mind i finally found it after removing the image source. it was .columns .bot-img, agh
awe, i appreciate it X3
.get('https://corona.lmao.ninja/v2/countries/${args}'); do i do something wrong, its not returning anything
full code maybe?
check your dm
just send a pastebin
user isnt defined
const Discord = require('discord.js');
const superagent = require("superagent");
exports.run = async (client, message, args) => {
let {body} = await superagent
.get('https://corona.lmao.ninja/v2/countries/', args);
const embed = new Discord.RichEmbed()
.addField('Statistic1', '**Total Cases**: ' + body.deaths + '\n' + '**Cases**: ' + body.deaths + '\n' + '**todayCases**: ' + body.todayCases, true)
.addField('\u200b', '**Deaths**: ' + body.deaths + '\n' + '**Cases**: ' + body.deaths + '\n' + '**todayCases**: ' + body.todayCases, true)
.setTimestamp()
.setColor(0x00ccff);
message.channel.send(embed);
}
any idea why is not working, its returning undefined
wtih command
but what command and what args you pass there?
some apis just support 2 letter name of the country
like us, fi, se, ee, de, ru, au, ca
! command nad the country name
try !command us
same problem, undefined
isnt args array?
.get(`https://corona.lmao.ninja/v2/countries/${args[0]}`)
and try to go urself to that url with country does it return anything
well thank you for now everything work
ignore the double names its jsut for testing ๐
Hello!
I'm having some issues with the code me and a friend are trying to use
# Say
@client.command()
async def say(ctx, *, content):
await ctx.message.delete()
#channel = discord.TextChannel.name('test')
#channel = client.get_channel(715038598361120779)
await ctx.channel.send(content, channel)
We're trying to use the say command to try and send the message into a different channel according to the channel's name
any error?
Do you have to put the ID?
Hes the other bot coder
no, d.py will magically guess what channel you need
a recent update includes machine learning features
soon it will also guess what you want your entire bot to do
of course you need the id why wouldnt you ๐ฉ
Alright to confirm
lmao, machine learning algorithms yes.
I'll also remember to use my neutron cyclotron to calculate the derivatives of the acceleration of the third moon of jupiter as well
ALright fr, tho, I was thinking if it was possible to use a name to identify it
but its only possible for using the Channel id right?
idk how d.py handles things but you might be able to fetch the channel from cache by name
What about
I was thinking that some bots have this sort of commandline that allows for the user
to specifically set a channel
Channel converter
In function args you set an argument's type annotation to discord.Channel
How do i get video id?
use song.info.id?
aaaaaaaaaaaaa
Hey. Is the guildMembersChunk event ever used? And will guildMemberAdd be fired for every individual guildMember that got added? (discord.js v12)
if I try to play any song with shoukaku this https://canary.discordapp.com/channels/264445053596991498/272764566411149314/715469213141172254 happens in lavalink logs, and nothing is played plz help
@nocturne grove 1- idfk
2- yes
@tight plinth how to get video id ?
what u use to get video
lavalink
okay thank you @tight plinth!
np
song.info returns what
wait
check what song.info returns, and use ur brain to determinate what is the id
object object
lavalink is 
ytdl-core is 
what should I use to do music?
lavalink
make ur own lib
to log objects, simply console.log({object})
or convert them to arrays
brobro
fast
how can i write a command
for a giveaway bot
message.channels.react
or how
i need when he sends the giveaway message, autoreact to it with ๐
pls help me
That guy cant chill lol
and then doesnt even respond
i hate these people, wanting something so desperate, then spamming to get attention
then not responding after answering
that's generally how folks are on Discord, sadly
var string = "Hello this is a test sentence";
['hello', 'this', 'is', 'a', 'test', 'sentence']; // after splitting it
// wanted result (breaking after every 3 words)
'hello this is
a test sentence'
anyone knows how i can do thit
.join(' ')
you will need a loop with indexes and the modulo operator
I did, can't figure it out that's why I asked - use your brain if you can't seem to understand the purpose of this textchannel.
toxic
we're not gonna spoonfeed code
don't need to?
a = "this is a test string";
b = a.split(" ");
for(let i = 0; i < b.length; i++) {
// this is a "for" loop. it defines i as 0, then loops while i is smaller than the length of b.
console.log(i); // this will give you the current index
b[i] // this will let you access the item of the array that exists in this index
}
thanks
1 % 5 // this is a modulo operator, it returns the remainder of division. this returns 1
4 % 5 // returns 4
5 % 5 // returns 0
6 % 5 // returns 1 again
Wait so that is what % means?
// text was a string
text = text.split(" "); // -> array
let txt = "";
for (i = 0; i > text.length; i += 2){
txt += `${text[i].toString()} + ${text[i+1].toString()}\n`;
};
ohhhhhhhhhhhhhhhh
8%4 returns 2
If I console log it, it just returns some empty text
wht
8%4 returns 0
why +=2
@tight plinth trying to split it every 2 words
no it doesnt
i +=2?
you dont want to skip indexes, you want them all, else you will be skipping words, not putting them in new lines
i>text.length
what you want is, if the index reaches an amount that can be divided by 2, then you add the new line character "\n"
otherwise you dont add it
thanks guys ๐
@tight plinth better discord 
i dont see the problem
can someone help, my guilds are undefined. my code is
.addField("Guilds", client.guilds.size)
and result is:
client.guilds.cache.size
ok tysm
my stupid tamigotchi's keep being ded af when i wake up ๐ข
f
quite ๐ข
if you host a bot on glitch, is anyone then able to view the source code for it?
yes
How do you guys handle custom prefixes?
Do you query the database each time a message is sent and check if it starts with the prefix that's on the database?
So I'm using glitch to code a bot, and uptime robot to host them 24/7. However, whenever I shut down the glitch project, the bot stays up for a while and shuts down. I correctly provided the live app link to uptime robot but still is not working. Any ideas? ( if this belongs here )
does the bot still respond after being shut down?
@opaque seal yes. I check for guild specific custom config when each message is sent, if none is found it uses the default config
Doesn't that lead to too many disk operations?
no, because i implemented a cachebase, which is basically a wrapper around my database that stores objects via id (guild id in this case). my cachebase will either give me existing data (and update the time that data was last used), or it will fetch the data from database, and set the time the data was used. then, i use my cachebase as the database, and fetch data from that. so really, it only reads from the database when it needs to get new guild information, then it holds it in memory until it hasnt been used for x minutes (configurable).the cachebase saves the data to database each minute, and then clears any that are past the time limit
tbh, its just a decently written database manager. i just call it a cachebase as its like, the main brain of the db, and i care about file hierarchy in my directories, and c is higher in the list than d. I could have easily called it datacache, or db_cache, or w.e ๐
@opaque seal you dont need anything that complicated, it can be a lot simpler for only prefixes
๐
the general idea is: when you receive a message, check if you have a prefix already stored somewhere, if not, get it from the database and store it somewhere for future uses
with somewhere being a variable, array, map, object, etc inside the program
Yeah I know what cashing is
cashing lmao
cachรฉing
hahah
it shouldnt be hard to implement
tbh, just read it from the database each message for now
it can be as simple as a 1-2 liner
yea, it doesnt need to be over the top
my solution is for portability, its a module i wrote that ive used in a few projects
No that's not the problem, the problem is that it would require RAM and it would still query the database a lot if the bot is in many servers
not much ram tbh
tbh, just read it from the database each message for now
@neat ingot atm this is causing my bot CPU usage to go above 100
@pale vessel no it does not
Wasn't only that there reason, I was querying the db on the message event and on the command file too, now I changed it so the message event passes the db values it got to the command
what database are you using?
@neat ingot mongoDB
It shuts down completely, won't come back until I re-open the project
oh, mongo โค๏ธ
Should switch to SQL in the future
imagine you have 5000 servers. you receive messages from 500 of them over a couple minutes, you will make 500 requests to the database, yes, but its a simple read request which is usually done in 1 millisecond. then all those 500 guilds will never need to touch the database anymore for prefix lookup, because they will be stored in the ram. how much ram would a prefix cost? its a simple 1-2 char string, 500 prefixes will not cost more than 1-2kb ram
no no, mongo is scalable af!!!
^
i use mongodb/mongoose as part of my database/cache system ๐
@fallow steppe then it's just discord being slow at updating the bot status. your bot is actually offline
imagine you have 5000 servers. you receive messages from 500 of them over a couple minutes, you will make 500 requests to the database, yes, but its a simple read request which is usually done in 1 millisecond. then all those 500 guilds will never need to touch the database anymore for prefix lookup, because they will be stored in the ram. how much ram would a prefix cost? its a simple 1-2 char string, 500 prefixes will not cost more than 1-2kb ram
Right
No, aslong as I open it it starts as "Logged in as Test Bot#0110"
Then the rest of logs is spammed with null
what
I have a query. Can anyone help me?
No errors are logged
why does it spam with null?
I have a query. Can anyone help me?
Idk, it's surely something related to glitch
@arctic juniper dont ask to ask
Help me plzz
@fallow steppe it shouldnt be logging null lol
Hold Ill take a ss
๐ญ
@arctic juniper just ask
Ok
im trying to get my bot to react to the help message embed i tried
sentMessage.react("๐โโ๏ธ");
and it dont work, anyone know what i need to put?
is it ok to ask if im allowed to ask a question?
my cachebase, for 1 player, 1 server, and 1 minigame record (bot specific) is 13106 bytes.
no no, mongo is scalable af!!!
isn't SQL too?
all databases are scalable
@quartz kindle
function roughSizeOfObject( object ) {
var objectList = [];
var stack = [ object ];
var bytes = 0;
while ( stack.length ) {
var value = stack.pop();
if ( typeof value === 'boolean' ) {
bytes += 4;
}
else if ( typeof value === 'string' ) {
bytes += value.length * 2;
}
else if ( typeof value === 'number' ) {
bytes += 8;
}
else if
(
typeof value === 'object'
&& objectList.indexOf( value ) === -1
)
{
objectList.push( value );
for( var i in value ) {
stack.push( value[ i ] );
}
}
}
return bytes;
}
^ used that function to get bytes
why does a boolean use 4 bytes?
@quartz kindle screenshotted above
@fallow steppe you have some console.log somewhere in your code doing that
Wait, actually, sorry. It's a glitch outage that keeps dropping project hosting throughout the day
Just noticed
theres a private server for agar.io i play on sometimes, and its hosted on glitch...
it is not performant at all.
xD
so, i noticed that my minigame bot has a little bit of lag it seems when more than one person is playing it at a time. is there some issue with awaiting messages/reactions from multiple users at the same time within discord js?
or perhaps it was due to awaiting multiple messages in the same channel?
It could be, maybe a more economic thing to use would be a message collector
isnt that what await reactions/messages does behind the scenes anyway?
Yeah
You could make it so it doesn't just await 1 message, but instead waits as many as you need
or you can build your own much lighter solution by using one single listener and your own collection of messages that need listening
then simply check for those in the event
Do you guys know any open source bots to help understand a good code structure for a java bot?
how can i place text in the middle of a canvas ?
There is a guide on their site
ok
thanks
if you want to center the text, you need to either use measureText and then apply an offset, or you need to set the text to align center and middle
Hey guys, i'm a beginner in discord.js, and i keep running into a certain problem => client.ping returns undefined and i can't find information in the documentation.... do you have any ideas?
@fiery hill client.ws.ping
๐
if you want to center the text, you need to either use measureText and then apply an offset, or you need to set the text to align center and middle
@quartz kindle how can i set the align to middle?
on d.js
i used to do it on html
@earnest phoenix - context.textAlign = 'center'
context.textBaseline = 'middle'
You mean that?
i used it but it doesnt seem to work
im trying to fix that
ctx.font = '28px sans-serif';
ctx.textAlign = "center";
ctx.fillStyle = '#ffffff';
ctx.fillText("ABCD", canvas.width / 2.5, canvas.height / 3.5);```
i used this line
but i dont see the text
width console => 700
height console => 250
what does the /2.5 and /3.5 mean actually
is it gonna be 700/2.5 and 250/3.5 and place it there?
Yeah
You're not drawing white text on a white BG are ya? Lol
dividing by 2.5 and 3.5 will not give you the center of the canvas
in the font
oh
change the px ?
yes
it wont change it i think
i changed from 28px to 64px
nvm it did
how can i run multiple file in visual studio code
pm2
Hm
os.system kinda dont working
use pm2
how can i run multiple file in visual studio code
@earnest phoenix ???
whatever
Is there a big difference in performance from discord.js and jda libraries?
@earnest phoenix you can use pm2 with basically everything
is it python
no it is node.js
my bot is python ๐ฆ
pm2 supports python
how i get the time of the song?
const song = {
title: songInfo.title,
url: songInfo.video_url,
author: message.author.tag
};```
duration
thanks
songInfo.duration right?
dont work xd
console.log(songInfo) and check
@summer torrent tam ben yazฤฑyordum onu
ok
{
likes: 757,
dislikes: 72,
video_id: 'xmZZb-313D4',
video_url: 'https://www.youtube.com/watch?v=xmZZb-313D4',
title: 'Cantando con DOKI Sentado debajo de un Mango',
length_seconds: '128',
age_restricted: false,
html5player: '/s/player/4583e272/player_ias.vflset/en_US/base.js',
full: true
}
length_seconds
but is just the seconds :c
math.trunc(result)?
no
hey, wondering how to add reaction to a embed discord.py
d o c s
i cant find it in d o c s
lol
@wise prairie so
Hi
you wanted to do click here
yes
yes
! help here list of all commands for example
yea use embeds
const embed = new Discord.MessageEmbed()
.setDescription("[click here](www.google.com)")
message.channel.send(embed)
and that will have a text that says 'click here'
and when you click on it, you will go to the link
np hopefully it helped

