#development
1 messages · Page 725 of 1
@sage bobcat mathematical operations have priority over comparisons
u need brackets
dv you could learn ipc, because broadcastEval scripts can be kinda big
One message removed from a suspended account.
inter process communication
dont mathematical operations resolve first before comparisons
and yeah
if i did 1 + 1 > 1 that would resolve to true
ye
inter process communication allows you to request anything from shards as long as they receive the right code
fsr I thought that was 2 == 1 and went crazy for a while
LOL
i should do some sharding testing shit but so lazy
... and somehow I later came to a conclusion that was 1 + False
i don't know of any resources on ipc, but just know it's kinda like this
Several people typing...
i only code quantity > quality what i know > quality
i dont even code for speed
but now im kinda am
One message removed from a suspended account.
say 1 shard wants to request data, so it sends something out like
const d = ipc.broadcast("requestShardData")
all other shards recieve that message and send back their data
someIpcClient.on("requestShardData", (f) => { // return shard data })
the variable d contains data from all shards
One message removed from a suspended account.
@sage bobcat use your brain pls
oh that might be confusing
One message removed from a suspended account.
client.shard.broadcastEval("(this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? 'green_heart' : 'broken_heart')")

also
you dont need the first brackets
How long is this chat going on about that issue for
idk shiv
do you even need sharding right now
dv honestly just use stackoverflow
discord bots is so vague that there's nothing specific for it on so
@slender thistle a few days
he cant even use this channel, how can he use stackoverflow
Isn't SO just "marked as duplicate" spam
or closed as off-topic
optimist: the glass is half full
pessimist: the glass is half empty
stackoverflow: the glass is stupid, marking as duplicate, you have been banned for asking questions for 8 months
SO?
StackOverflow
o
I'll close this as off topic
k
ok
general advice: dont ask questions on SO because youre gonna be attacked
just look stuff up cuz whatever you're looking for it's gonna be there
One message removed from a suspended account.
wut?
I went to school for 3 hours this conversation is still ongoing?
Let me send some docs...
https://discord.js.org/#/docs/main/master/class/Client?scrollTo=ws
https://discord.js.org/#/docs/main/master/class/WebSocketManager?scrollTo=shards
https://discord.js.org/#/docs/main/master/class/WebSocketShard?scrollTo=ping
https://discord.js.org/#/docs/main/master/class/WebSocketShard?scrollTo=status
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Read a little bit. This should give you all the knowledge you need to display shard ids with their ping and status.
publish a message?
yes
like send a message to a channel?
Bots aren't able to publish messages in announcement channels
I have this code, which is to send an image with the avatar and text that the author wrote, well, when the text is larger than the background, the text shrinks, but I would like that instead of doing that of a jump line, but I don't know that, I use canvas
let fontSize = 70;
do {
ctx.font = `${fontSize -= 10}px sans-serif`;
} while (ctx.measureText(text).width > canvas.width - 300);
return ctx.font;
};
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
var bgs = [
"https://cdn.pixabay.com/photo/2016/10/20/18/35/sunrise-1756274__340.jpg"
];
var bg = bgs[Math.floor(Math.random() * bgs.length)];
const memetext = args.join(" ")
if (!memetext) {
const embed = new Discord.RichEmbed()
.setTitle(`${message.author.username}, debes escribir algo`)
.setColor("RED");
message.channel.send(embed);
return;
}
if(memetext.length > 100){
const embed = new Discord.RichEmbed()
.setTitle(`${message.author.username}, no puedes usar mas de 100 caracteres`)
.setColor("RED");
message.channel.send(embed);
return;
}
const background = await Canvas.loadImage(bg);
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
ctx.font = applyText(canvas, memetext);
ctx.fillStyle = '#ffffff';
ctx.fillText(memetext, canvas.width / 2.5, canvas.height / 3.5);
ctx.beginPath();
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(message.author.avatarURL);
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'reflection.png');
message.channel.send(attachment);
```
instead of changing the font size, split the text into smaller pieces and measure each line again
Does anybody have any idea how I could make it so when I do like !check it goes through all the users in my server and checks when there account was created and if there account was created less then 2 months ago it shows there username and when there account was made?
loop through every guild on your client
in that loop
loop through all of the members of the guild and check their account creation date
@quartz kindle How can I do that?
@quartz kindle I dont know ;-; I copied the code
theres ur issue then
sometimes it slips
bots only get denied if its a blatant copy of another bot/open source bot
a bot built with random copy pasting of random blocks of code from multiple sources wont get denied (which is most likely the case here)
Does anyone know how to detect when the client leaves a voice channel? (discord.js)
a music bot but when it get's disconnected from a vc by someone, the bot still thinks the music is playing even though it isn't and it stops people from being able to use the music commands (in that guild until the bot restarts or the music queue ends)
thank you! i didnt find it in the docs when i looked lol
@quartz kindle It is not copied from another bot, I was just looking for how to manipulate images, and I found one of canvas for a welcome, but I modified it so that random text could be written, but I did not know how to do what I told you
its not an easy thing to do
take a look at this example
this example does the following:
- split text into words
- start with one word, measure its length
- if length is smaller than the canvas width, add another word.
- measure the length of two words
- if the length is smaller than the canvas width, add another word.
- repeat until the length is bigger than the canvas width
- when the length is bigger, remove the last word, write the text, move to new line, start a new string and add the word there
- repeat the process until no words are left
@quartz kindle Thank you! already achieved
i wonder is
"Authorization" : "Bearer " + ACCESS_TOKEN
correct header to access https://discordapp.com/api/users/@me
it keeps giving me
{'message': '405: Method Not Allowed', 'code': 0}
code:
@staticmethod
async def get_user_json(access_token):
url = Oauth.discord_api_url + "/users/@me"
headers = {
"Authorization" : "Bearer {}".format(access_token)
}
print(url, headers)
async with aiohttp.ClientSession() as session:
async with session.post(url, headers = headers) as r:
return await r.json(content_type=None)
does it not take a get request and not a post?
One message removed from a suspended account.
One message removed from a suspended account.
How can i even shard my bot xD
For who xD
I domt know how to make a shard system xD
Do one of u know how to check the boosts?
From a server
https://support.discordapp.com/hc/en-us/community/posts/360044355652-Nitro-Boost-the-API @sterile minnow
afaik not possible
K
it is possible
usually it would be in the guild object, eg in eris it's subscriptionCount
Are JSON files slow to work with?
store your config in .env if you work with js/ts
doesnt py also support .env
all languages support multiple config files i guess
As a database
I’ve been storing player data in json files and reading/writing but I can feel my bot getting slower and more people use it and more files get added
Would MongoDB be better?
If you wanna work with JSON, yeah
Ty!
someone would be that she event use us to know when a user joins a voice ?
@wicked pivot ???
o
can you elaborate on the issue?
you want to set up an event to detect when a user joins a voice channel @wicked pivot?
what lib?
discord.js
ooooo, give me a sec
thx
Huh, can't find anything in the discord.js docs. I have no clue how to do that. Wait for someone else to respond. :(
thx you no problem
what
eh I hope it's the same in master
const discord = require('discord.js')
module.exports = async (oldMember, newMember) => {
guild = new.guild
let newMemberchannel = newMember.voiceChannel
let oldMemberchannel = oldMember.voiceChannel
if(oldMemberchannel === undefined && newMemberchannel !== "534738699628576782") {
let embed = new discord.RichEmbed()
.setTitle('Un membre viens de rejoindre un vocal')
.setDescription(`
User qui à rejoint : " ${newMember.user.username} "
`)
.setColor('#E37D00')
.setTimestamp()
.setFooter(`Logs serveur ${guild.name}`)
bot.channels.get("535553754359922705").send(embed)
}else if(newMemberchannel === undefined) {
//leave
}
}``` i did this, but it doesn't work
what is new.guild
Language: Discord.js
Code: ```js
if (!message.guild.roles.has(roleName.id))return
**IS it correct?**
newMember sorry
there is no error but no message send
const discord = require('discord.js')
module.exports = async (oldMember, newMember) => {
let newMemberchannel = newMember.voiceChannel
let oldMemberchannel = oldMember.voiceChannel
if(oldMemberchannel === undefined && newMemberchannel !== "534738699628576782") {
console.log("join")
}else if(newMemberchannel === undefined) {
//leave
}
}``` even like that, but it doesn't work
@heavy marsh https://tryitands.ee
Thanks for thanks
I fixed it but how can i remove this ...
My Code: ```js
if (!message.guild.roles.find(name, roleName))return [utils.timed_msg(utils.cmd_fail(No role found by that name!), 5000)];
const roleID = message.guild.roles.find(name, roleName).id;
**Console Error:** http://ss.danbot.xyz/u/03.00.25-08.11.19.png
should i catch the error and ignore?
find('a', 'b') is deprecated
It wants you to do find(a => a.prop == 'value') instead
Fucking mobile
Hate it
@heavy marsh
hmmm oks let me try
a in this case would be Role
then a.prop
ooh ok i got it thanks
botConfigs.find(ch => ch.name === 'Support')``` Anyone got this but for category's?
wait
that makes no sense
nvm
no
u see ch.name i need it to be converted
(╯°□°)╯︵ ┻━┻
coverted to catogery
nvm again
args are this right?: js !say hi everyone
^^^^^^^^^
hi guys, is there any way to get the Invite code of a Discord server channel without having Manage Channels permission?
basically I'm trying to link the data I have (invite link with code) with the discord server where the bot is invited
Why?
If your plan is to join some of the servers your bot is in that is kinda a massive breach of privacy no?
yeah it is a massive breach of privacy
exactly
i dont think you can fetch existing invite codes without perms either
u can't fetch but create a new one
please move to #general or #memes-and-media if it is not development related
how i doo like this in my bot
do i need to put their a dbl api key or not change anything
what do you think
i think i need to put my dbl bot token
yes
Yes
yes
i have one problem
my main bot is in vps so can i creat a new bot i test in that then i put it in the main bot
my main bot is approved
yh
but for testing
ur test bot wont be xD
yes
i have done now how can i check it@quartz kindle
check what

well, does it work? if not, then you did something wrong
One message removed from a suspended account.
One message removed from a suspended account.
master?
One message removed from a suspended account.
shard.ids[0]
its not showing the server count in main page it shows when i click on view
Is your bot in this server?
Then it should be automatic iirc
it cant
Because you're seeing a cached value
when i restart my bot then before restart i saw it was 70k+ members in my bot status after resart it shows me 48+ members in my bot status every time
cached members
anyone here, just drop off your question
Okay
{
"discu_chan": [
{
"chan_id": "642362119312113702"
}
]
}```
```js
client.on('message', async message => {
var channn = message.channel.id;
var chann = db.get("discu_chan").find({ chan_id: channn }).value();
if(message.channel.id === chann) {
message.delete()
createWebhook(message.author.username, message.author.avatarURL).then(async mm => {
try {
await mm.send(message.content)
await mm.delete()
} catch (e) {
await mm.delete()
}})
}
})```
I'm trying to make sure that if the channel id is = to the json file id then it deletes the message and sends it back with a webhook
But I can't do it.
:/
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I'm trying to make sure that if the channel id is = to the json file id then it deletes the message and sends it back with a webhook
One message removed from a suspended account.
plzz help on that
Do you know how I could do that?
If anyone can help me, ping me
TY
what does db.get("discu_chan").find({ chan_id: channn }).value(); return
var channn = message.channel.id;```
Bug i want to use
{
"discu_chan": [
{
"chan_id": "642362119312113702"
}
]
}```
This
and please use helpful variable names that explain what the variable is/does
Oh okay
Wait
client.on('message', async message => {
var messageChannelId = message.channel.id;
var chanIdInDB = db.get("discu_chan").find({ chan_id: messageChannelId }).value();
if(message.channel.id === chanIdInDB) {
message.delete()
createWebhook(message.author.username, message.author.avatarURL).then(async mm => {
try {
await mm.send(message.content)
await mm.delete()
} catch (e) {
await mm.delete()
}})
}
})```
Like that?
Ok okay x)
It's just a json file that you required or ..?
if db really is a json file what the fuck is that db.get().find().valur
Just the json file
{
"discu_chan": [
{
"chan_id": "642362119312113702"
}
]
}```
@mossy vine i use lowdb
But later I'll use sqlite
oh why is this a thing
idk lowdb
log
db.get("discu_chan").find({ chan_id: channn }).value(); to console
what does it return
{ chan_id: '642362119312113702' } won't be equal to '642362119312113702'
But your logic doesn't rly make sense
How can this be fixed?
I'd assume that if your search fails
As in you used find() but with a different channel id
Mmmh
it would probably return undefined ?
Oh
With anoter channel i have "undefined" in log console yes
it means it's the wrong channel
Yes
so you can use that in an if
you don't need to compare it with the channel id a second time
Hmm but how?
let channel = db.get(...
if (channel) { //code }
is there any script translator?
script translator?
Bug he spam bruh...
i mean, the only way that would be remotely possible is if the languages are extremely similar
like typescript to javascript
but java to C i dont think so
Can anyone invent one
He deletes my message then sends it with a webhook, then it keeps deleting and sending it back @late hill
they are completely different languages with completely different way of working and operating in different environments
client.on('message', async message => {
var messageChannelID = message.channel.id;
console.log(db.get("discu_chan").find({ chan_id: messageChannelID }).value())
var chanIdInDB = db.get("discu_chan").find({ chan_id: messageChannelID }).value();
if(chanIdInDB) {
message.delete()
await client.channels.find(q => q.name == message.channel.name).createWebhook(message.author.username, message.author.avatarURL).then(async mm => {
await mm.send(message.content)
})
} else {
await mm.delete()
}
})```
@chrome verge you can't convert any langage
Can a machine learning AI translate to that excate operating
Good luck for this lol
if it were possible, people would have done so
x)
Me lazy to do so
but no, people need to create emulators for that
Also making such an AI like this is hard
Like you need Tons of data sets for 100language
the problem is not only the languages, but mostly the environment
and AI can have a gradient explodion
for example, what good is translating C to javascript for example if javascript can only run inside a javascript engine
Like for example if the AI finds a int function(){}
he translate it to local function()end
example ^^^^
yes, but that only works if the languages are extremely similar
and run in the same environment
can i give it a try?
sure
or bad idea
when i restart my bot then before restart i saw it was 70k+ members in my bot status after resart it shows me 48+ members in my bot status every time
ok
@earnest phoenix i already told you, its because of caching
i dont understand that
yeh @earnest phoenix because it replies to it's own
I will start with python to lua
The message sent by the webhook
will fire the event again
Oh yes
so that'll keep going forever
MMmh
@chrome verge what will you do when the code requires importing something?
means
lmao
but it is in my bot status
what if the import is a native python module
it will translate it to nil
lmao
or a list
anyways something None or null
I'm pretty sure if (message.author.bot) return; would get webhooks
@earnest phoenix your bot never stores ALL members, because it takes too much memory
Ty
it stores members as it needs them
@quartz kindle so how i store more thay that
if you want to get an accurate member count, dont use users.size
use guild.memberCount
but it happens when i restart the bot
You should also consider caching that channel id
Because currently your bot will be fetching that from your "db" on every single message
You can't randomly use "guild"
If you wish to get the memberCount of a specific guild you'll have to get it's guild object
guilds are stored in client.guilds
example
you can grab one from there or what you probably want to do, go through them all and add up their member count
One message removed from a suspended account.
its their
@earnest phoenix there is client, and client has guilds, and each guild has memberCount
so you need to use client.guilds and loop over all guilds and get the memberCount for each one
you can use a for loop, or you can use .forEach() or you can use .reduce()
no
client.guilds.forEach(do something here with each guild)
Reduce would be the most compact, the for loops are easier to read and make.
var chan = args[0].replace(/\D/g,"")
if (chan < 1) return message.channel.send("**:x: | Merci d'indiquer un channel.**")```
`Merci d'indiquer un channel = Please indicate a channel`
var chan = args[0].replace(/\D/g,"")
TypeError: Cannot read property 'replace' of undefined
Why he not return the message??
Why are you checking if a string is lessthan 1
args[0] undefined
Oh I didnt even see the error 
@amber fractal for don't make crash the bot
But what cyber said
Check if it's undefined
try:
(Code)
except TypeError:
(ErrorCode)
Uh
@vernal willow i know but wait
or before the replace
That's not how js works
I thought it was py
Worng language
var chan = args[0].replace(/\D/g,"")
if (!chan) return message.channel.send("**:x: | Merci d'indiquer un channel.**")```
var chan = args[0].replace(/\D/g,"")
TypeError: Cannot read property 'replace' of undefined
if(!args[0])
That will error anyways, you need to check args
sure it would be easier to just do try; catch
then you're doing something wrong, checking for the args before anything else is correct
client.on('message', message => {
if (message.content.startsWith(`${prefix}del-chan`)) {
if (!message.member.permissions.has("MANAGE_MESSAGES")) {
message.channel.send('Désolé tu n\'a pas la permission d\'utiliser la commande de add-chan.[MANAGE_MESSAGES] :x:');
return;
}
let args = message.content.split(' ').slice(1);
var chan = args[0].replace(/\D/g,"")
if (!chan) return message.channel.send("**:x: | Merci d'indiquer un channel.**")
//rest of the code
}});```
Mmmh
Okay
Already the same error
client.on('message', message => {
if (message.content.startsWith(`${prefix}del-chan`)) {
if (!message.member.permissions.has("MANAGE_MESSAGES")) {
message.channel.send('Désolé tu n\'a pas la permission d\'utiliser la commande de add-chan.[MANAGE_MESSAGES] :x:');
return;
}
let args = message.content.split(' ').slice(1);
if (!args[0]) return message.channel.send("**:x: | Merci d'indiquer un channel.**")
var chan = args[0].replace(/\D/g,"")
//rest of code
}
});```
Resolved ty
if (!args.length) return message.channel.send(`You didn't pass any command to reload, ${message.author}!`);
const commandName = args[0].toLowerCase();
const command = message.client.commands.get(commandName)
|| message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`);
delete require.cache[require.resolve(`./${commandName}.js`)];
try {
const newCommand = require(`./${commandName}.js`);
message.client.commands.set(newCommand.name, newCommand);
message.channel.send(`Command \`${commandName}\` was reloaded!`);
} catch (error) {
console.log(error);
message.channel.send(`There was an error while reloading a command \`${commandName}\`:\n\`${error.message}\``);
}```
Why does it always return Enmap require keys to be strings or numbers.?
Nvm, got it.
@chrome verge are you trying to read a file?
?
No
Like
In lua
loadstring("x=10 print(10)")
I want like that
but in python
what does that function do?
is there any bot that connect pinterest and discord
you can make one using requests
are u a dev tho
if not i can tell u how
@mossy vine It turns a string into a chunk of code
or compiles and run a string
what langauge you use?
ty so much!
client.shard.broadcastEval(':busts_in_silhouette: Users:', client.guilds.reduce((a, b) => a + b.memberCount, 0).toLocaleString())
that is the total users count
ok

Giving code directly relating to the exact solution of a problem is spoonfeeding
oh
One message removed from a suspended account.
@boreal yarrow
Error [SyntaxError]: Unexpected token :
at Client._eval (C:\Users\ZaidYt\Desktop\Discord Bot\node_modules\discord.js\src\client\Client.js:507:17)
at ShardClientUtil._handleMessage (C:\Users\ZaidYt\Desktop\Discord Bot\node_modules\discord.js\src\sharding\ShardClientUtil.js:111:76)
at process.emit (events.js:208:15)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
name: 'SyntaxError'
}
GOT THIS ERROR
wait
Ok I'll waiting.
OoF
can't do what?
client.shard.broadcastEval('client.guilds.reduce((a, b) => a + b.memberCount, 0).toLocaleString()')
Try
this is what happens when people spoon feed lol
You mean to tell me that when you give someone code they don't understand it and it errors? No way!
Almost like that's why spoonfeeding is bad
will that even work
It wouldn't finish the job no
also I believe broadcastEval is already in respect to client
fetchClientValues() would be easier too
Is there a way to un-electronify an app? I want to use electron apps without all the bloatware that comes with them
electron is tightly knit into applications that use it so idk man
have you googled yet
likely nof
not*
electron is basically chromium with access to system apis
and not having access to those system apis will likely fuck everything up
ce
electron is basically node with an UI
no!
How long does it generally take to have your bot reviewed for approval?
Been 8 days figure I'd ask to get an idea
-faq 2 -c
@west raptor thank you ! I appreciate the input. I'm not being pushy just asking for a typical idea of time frame
does
member.guild.channels.get('638541831663124480').send("Welcome");
});```
only work on real users, and not bot?
I have a hard time testing if it actually work or not

Both
Because i have tried inviting bots to see if it work or not and it didn't do anything

damnit
Hey, I'm working on a Discord bot in Javascript and there's three different variables I'm passing between two different functions.
Despite both functions changing the variables, the values of them keep resetting.
Two of the variables (one string, one integer) are declared using let outside of the two functions (in different functions that aren't being called multiple times) and the other variable (string) is global.
How do I get them to retain their values?
@earnest phoenix you can make it lol
Your explanation is flimsy, please visualize
Does this help?
Function0() {
let variable1 = 10;
Function1(variable1);
}
Function1(variable1) {
variable1--;
Function2(variable1);
}
Function2(variable1) {
if (variable1 == 5) {
FunctionEnd();
}
else {
Function1(variable1);
}
}
you can't name your functions like that
lol
you can't have variable/function names as numbers
It's an example.
...I suppose the question I would ask is, exactly what are you trying to accomplish here?
I guess the example was so simple that it's more confusing than helpful.
I'm trying to make something that allows for typos.
So there's a lot of comparing what the user inputted and the correct answer.
"Function1" edits their response a little and sends it to "Function2" when the first letters match.
If it doesn't match, "Function1" calls itself.
The integer mentioned earlier is how many typos they're allowed.
You could accomplish that in a while loop..
while (number of typos left is greater than 0){
do things
typos allowed - 1
if ( check things ){
actions
else
stuff
}
Yep, it uses a while loop.
The example was very simple. >.>
Okay maybe I'm blind, but I don't see a while loop in there..
The problem I presented was variables not retaining their value so I didn't include it. >.>
Well, lemme give ya some advice lolz...
Be more detailed?
When asking for help from other developers, it's best to either include your actual code, or example code that's, yanno, very close to the actual thing.
For all we know, the variable value retention issue could be somewhere not at all related to your recursive functions
But as far as any of us can see, your code is quite literally three functions
And nothing else.
There's so much I thought it would just be a bother. >.>
I'll post it in a moment since you're so willing to help~
Eh... I personally am actually about to hop off, but this server is filled with alot of talented devs.. even if it's not me that helps, I'm sure someone can at least point ya in the right direction.
I'll probably reformat my question and post the appropriate code in the future then.
I changed a little thing (after giving up after hours of fiddling earlier) and got it to work a bit for the first time.
So with hope I won't need to repost the question.
One last pointer for ya as well; it would be a good thing to troubleshoot your code yourself first too. console.log() can be your best friend, printing out the current variable values as it loops through your functions.
Yep!
It's helped a lot.
lolz... it's honestly my best way to troubleshoot my own code, when I modify things with my own bots.
I would suggest, if you end up needing to, have each function itself print out variable values, along with individual counter variable values each time it loops through a function.
That might help you track down the bug faster.
Anywho I'm off

I haven't implemented a counter since it's just been looping infinitely until I stop it, but I might give it a try.
Bye~
Thanks for the help~

Alright, so I have a function that runs on a for each and in each loop it checks if a condition is met. Here is a hypothetical scenario (very plausible with my bot):
On loop 1-15 (a random number) of the for each loop, the required condition is met and the user will get/keep a prespecified role
On loop 15 (again a random number) of the for each loop, the required condition is not met and the user has the role removed
How can I fix this so that if the condition is met just once, the role will persist throughout the for each loop regardless of other condition meets/nonmeets? I don't want to break/return out of the loop. This is nodejs.
hi guys, does a bot need any permissions to do this? guild.owner.send("MSG"); is there any scenario where it could fail and return error? thanks
if the guild owner has blocked the bot or has DMs closed
may I show you the code?
is there anything else thats relevant?
thanks, actually I had no idea how to check if bot is blocked or DM closed 🙂
will google, thx again
thanks to discord the only way to check is to send a message to the user
I read about it, you can only use a .catch but pretty useless in my case 🙂
still would be much better to have checks instead of attempts 🙂
blame discord
@outer moon u need to code it in ur main bot filr
You need to use our API which is fond here: https://top.gg/api/docs
If you have any questions about it you can ask them in #topgg-api
really thanks @twilit rapids
No problem
Can you use localhost ( MongoDB) as well?
what
what
Has someone a idea how to check the Voice connections from a bot with the normal discord.js api?
Should be the newest version
stable or master? @sterile minnow
its voiceConnections
also 'of undefined'
so theres probably more fucky shit going on
It's also better not to send error messages to the end user like that
oh you are straight up doing Client.voiceConnections arent you
I assume if the command has an error, it displays the error as in your screenshot
then this.client is undefined
Jep
A regular user shouldn't see errors like that
I think only !e see that
The Bot is in Alpha there are errors normal
.array is shitier
Anyway, if you need help with the code to resolve the client undefined, you're gonna have to post the code 
I have admin handy cause I dont have a pc here
Hand*
But why ist this not going?
Because this isn't your client I guess
this is probably nothing or an empty object in there
👀
Thx
But the Problem is he loggs the Voice connections from this Instance but he has 3 (Main, Radio, Music) how do he loggs every connection?
Fetch the amount of connections from the other instances
And how?
Yeah all inctances are logged in in Pika but Music and Radio are in a other hoster
oh like that
Cause main hoster has Traffic Limit
But main hoster is better
But cannot stream something
well you'd need some form of connection between them
And how?
if you have processes running on separate machines, you need to communicate via network
you have to make some sort of API
I have a API for my database to watch the stuff on web
But Pascal (a other dev from pika) has coded this
But i dont know how to make thia lol
have each instance run an http server
and then send requests to each other's ip addresses
@earnest phoenix @thick cipher
@earnest phoenix
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
- client.shard.broadcastEval("(this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? '💚' : '💔') console.log('hi')")
+ client.shard.broadcastEval("(this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? '💚' : '💔'); console.log('hi')")
; ?
One message removed from a suspended account.
One message removed from a suspended account.
if you have 3 shards that makes sense
^^
One message removed from a suspended account.
what
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.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Can someone help?
script = "code here"
client.shard ? client.shard.broadcastEval(script) : eval(script)```
at least i think that will work
log is undefined
also bot.channels.get is gonna return undefined, as its outside of the ready event, which is emitted when channels are cached
One message removed from a suspended account.
One message removed from a suspended account.
missing a closing ) on line 2
One message removed from a suspended account.
so just the string..?
One message removed from a suspended account.
- script = client.shard.broadcastEval("(this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? '💚' : '💔'); console.log('hi')"
+ script = client.shard.broadcastEval("(this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? '💚' : '💔'); console.log('hi')")```
oh
let script =
i keep forgetting what language im supposed to be writing
One message removed from a suspended account.
One message removed from a suspended account.
huh what
Pretty sure you meant to do this
let script = "script here"
client.shard ? client.shard.broadcastEval(script) : eval(script)```
you're already doing the broadcasteval
which will make script a promise
One message removed from a suspended account.
so you're just sending a promise to broadcastEval/eval
One message removed from a suspended account.
wat
escape all 's in the string
wait what
But that right there could still broadcastEval a broadcastEval
^
And that probably aint it
One message removed from a suspended account.
One message removed from a suspended account.
module.exports.run = async (client, message, args) => {
const script = "(this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? '💚' : '💔'); console.log(\"hi\")"
client.shard ? client.shard.broadcastEval(script) : eval(script)
}
module.exports.info = {
name: 'shards',
aliases: ['shardstats']
}```
Why it normal evaling?
simpler than repeating yourself
user input never touches eval input, so it is considered safe
One message removed from a suspended account.
One message removed from a suspended account.
You're trying to get stats of shard 0 without having shards?
You mean like
Your bot isn't sharded
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.
where client always has shards
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.
discord.net has sharding yes
the way discord.net handles it is basically wraps multiple clients into one
sharded client -> collection of discord client with separate shard ids
One message removed from a suspended account.
also you probably shouldn't look at nadeko for a reference to discord.net
nadeko is a clusterfuck and kwoth is stubborn
are there any common reasons why express doesn't get any form data from a post
all it gets is {}
first reason i can think of is there is actually no data being sent
do the fields need a property to be detected maybe
i've set an id to them all but idk
One message removed from a suspended account.
@earnest phoenix dont ping him 
iam sorry
error found : TypeError: Cannot read property 'botName' of undefined
why are you using request and fetch? why are you requesting it twice?
you return the body outside of the promise, so body doesnt exist
if an error like
DiscordAPIError: Unknown Member
gets spammed, could it lead to a 429 ip ban?
since its making alot of failed requests to the api
yes
429 is a ratelimit status code
hitting too many 429, 404 and something else will load to an api ban
also it depends whether the request is a rest request or not
Wasn't it 401, 403, and 429?
if ('1' == true) {
console.log('true')
//logs true
}
wait how does this work?

how that works? well, everything that's not 0, null, "" or anything like that is considered true
Is there any return limit in reaction.users.fetch
or does it return all the users that reacted
uhm... I think all
Is there a way that I can make user specific variables? I tried making a variable called "${member}Type" but that did not work.
var persist = JSON.parse(persist1);
SyntaxError: Unexpected token o in JSON at position 1
Uh, what is wrong with this?
JSON.parse expects a string
you gave it an json object, the correct way to do it would just be var persist = persist1;
Thanks
should be 100 @split hazel
so it only returns a max of 100 reacted users?
the limit defaults to 100
But I'm pretty sure you can only decrease it
if you need more than 100 you could use the before/after option
and fetch them using multiple calls
top.gg ignored my javascript in the detailed description of my bot, now how am I gonna make a server count for my bot and show it in the description?
well, I already have an url in which it automatically stores the server count, but how am I gonna link that to my description?
anchor tags exist
You can just send a POST request and the server count will be shown
Why would you need it in the desc
javascript in the description is only available for certified bots
you can show your server count with an iframe or even have your url return an image of the count and place it in an img tag lol
also, you have the dbl widget after your bot is approved, which you can also post in the description
question is it possible to return data from a function without using "return"
kind of like eval()
actually it is possible
wait no nvm
@split hazel why wouldnt you want to use return anyways
so why not just promisify eval? wouldnt that work?
if only i was told this existed earlier
?
How can I use a single mongodb connection in my entire program across multiple files?
so you want the eval function to be asynchronous?
as in, return a promise?
or execute async code?
yeah, util.promisify
https://nodejs.org/dist/latest-v12.x/docs/api/util.html#util_util_promisify_original
@near ether pass the connection object between the functions
Does that work for u?
You’re passing what exactly, the “mongoclient.connect” part?
Regular driver
uhh gimme a sec then, i dont know if its the same
Would you recommend mongoose over the driver?
Honestly if it makes passing around a single connection easier, then I’m all for it lol
Because I don’t think creating a new connection every time I need to access the database is the right move
Probably very inefficient
yeah its not the best idea
Thanks my dude
okay i have no idea what its called (or if it even exists in regular driver)
okay i think i got it
TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type Function. Received type string
when i try run
util.promisify(code)
what is code
something like
"1 + 1"
hold up, i got what you need
<MongoClient>.connect(bla, bla, async (err, data) => {
someVariableDefinedOutsideOfCallback = await data.db('coolDatabase')
//pass that variable to other functions
})
yknow, thats exactly what ive been trying for a while now
oh
lmao
yea using the driver is a PITA if you wanna pass around a single connection, so im probably gonna join mongoose gang
Hello
hi who would do a reboot command please
using mongoose the connection will just be mongoose.connection
@earnest phoenix we dont spoonfeed here
if you are using a process manager that restarts your bot when it stops, simply stopping the process is enough
here is an example from my current project in case it doesnt work for you
const mongoose = require('mongoose')
const db = mongoose.connection
mongoose.connect('mongodb://localhost:27017/AAAAAAAAAAAAAAAAAAAAA', { useNewUrlParser: true, useUnifiedTopology: true })```
@mossy vineI know but I would like to commende
order what? a pizza?
In command with the <commands> folder
Sorry if my english is not terrible
@mossy vine
mongoose bad driver good
people choose node because of its non blocking io meaning it doesnt wait for a request to finish on a thread
in basic terms it's a good candidate for applications like discord bots, however it's your choice
Feck i keep gettin the boot from discord api since its complaining my fricking token is invalid
But it is valid
I regened it several times
@solar wraith are you sure you are getting the token and not client secret
Yes
also making a bot with xml???
no just storing the key there
But not calling it and just havin it in the code
so in the main file
Don't store the token in XML file or any file without remembering to remove the \n from jt
When it gets read it automatically has a \n at the end to show new line
const taggedUser = message.mentions.users.first();
taggedUser.setNickname(NewName,'Request via §rename by ' + message.author.username);```
Why does it tell me, that taggedUser.setNickname is not a valid function ?
taggedUser.avatarURL works
because setNickname is located on a GuildMember
how can I fetch it then? message.mentions.guildmember.first(); ?
how about some docs
Well, how about closing the channel with a pinned message with a link to docs, then no one asks...
because some people need more help
this is one word change
if you need more help on that then idk
If it is that easy, whyraging that much about someone that doesn't know everything inside out instead of saying that one word together with the link and something like "read more about it here" instead of that... <.<
because if you do it yourself it will more likely stick with you
and it encourages doing research by yourself
Because you know if I didn't already try around with that for an hour or not. Please don't be so highnosey. If the question is unworthy, just don't answer. Not everyone is a super duper pro.
It's one mistyping you can find on the docs how to fix. Just look through the properties and you'll see it
It's literally one word
located on the docs I send
and says member in the description
My text was not against the link per se but against the rest of the text from him. Worked now and could finish what I tried. Thanks.
Hey, i got my Raspberry PI 3B+ few days ago. I am setting an website (www) but it won't work...
I have my local ip (that the page is working) and raspberry ip (static) but it's not working.
Any help?
rpi IP isn't static. The local IP needs to be static, you should run that through your internet company @earnest phoenix
ports = serial.tools.list_ports_windows.iterate_comports()
print(list(ports))```
ight am trying to just at this point list out the connected drives, or usb stuff, idk if I'm using the right thing, but the only thing it outputs is `[]`
@west spoke can you Tell me how?
One message removed from a suspended account.
One message removed from a suspended account.
Anyone here use Discord development bot in phone?
@earnest phoenix yes, some people have. but its comparable to using your toilet bowl as a cereal bowl
do you know js
r e a d
lol wait
hmmm
"unexpected identifier"
Restart you editor if you can't see text
what kind of advice is that
you clearly dont know js
thats why I asked you
with basic knowledge of js you wont get that error
how about you read the code then read the error
okay
or better dont use glitch
yep
and host it on something like 2 dollars vps
either your code is bad or glitch is bugging
Using glitch for what looks like a music bot (ytdl-core, youtube-api) will be horrible
go code it on a proper editor, then deploy it on a vps
if that fixed your problem
then glitch bad
if not then code bad
what glitch's editor isn't a proper editor ???
Glitch's editor completely breaks code sometimes
Going back to VS code...
glitch is not a reliable hosting platform so if you're testing your bot, use your local machine
you control the process, and you can keep it it on for as long as you want instead of having the bot shut off every what 30 minutes
okay
k 👌
Better go back and test right here
if (err) undefined; that doesn't do anything.
Ngl I used to have the same thought process
I wasn't..?
I can do some wrong things because I'm still learning and I can make some mistakes
I mean yeah..?




