#development

1 messages ยท Page 767 of 1

earnest phoenix
#

what is it?

empty owl
#

It sends Not a valid add-inID for everything

quartz kindle
#

why do you have an infinite loop?

empty owl
#

i have the if() statment

#

oh shoot

sudden geyser
#

also if the first entry is not true, it'll always send the error message. What elements does addOnsA feature?

empty owl
#

should I make it so the loop stops when I is like the length of

quartz kindle
#

at least make it limited by the array size

empty owl
#

let addOns = args.slice(2).join(" ")

quartz kindle
#

i = 0; i < addOnsA.length; i++

empty owl
#

ok thanks

#

would It be less than or equal

#

or just lesthan

quartz kindle
#

less than array length

empty owl
#

ah

#

ok thanks

quartz kindle
#

because array length starts at 1, not 0

empty owl
#

oh ok

#

thanks

quartz kindle
#

well, its 0 if the array is empty

empty owl
#

oh yea

#

but i told the people to put "none" if they didnt want any so

outer niche
#

'NoneType' object has no attribute 'create_ytdl_player' i do notunderstand

quartz kindle
#

you're trying to do <null/undefined>.create_ytdl_player

slender thistle
#

Are you familiar with Python data types

outer niche
#

I do not understand because it is connected to a channel when I am running the command

slender thistle
#

Try to reconnect

jaunty stump
#

what I'm trying to do is make the bot find its discord role position check if it is the highest role in the server and if it isn't then send error message(embed)

If I could get some documentation on how to do that or where to look that would be better than what "help" I got already

outer niche
#

I did I even shut down the code and restarted the entire bot

empty owl
#

Thanks tim

#

it works now

outer niche
#

shivaco I have tried reconnecting and even restarting everything and it still does not work

slender thistle
#

Did you reconnect to the vc through the bot code after restarting it

outer niche
#

I reconnected it using the command

quartz kindle
#

@jaunty stump first of all, remove the await. .filter() is not a promise

#

then, which role do you need?

#

the bot's own role? what if it has more roles?

jaunty stump
#

it's in an async

#

just the bots role

quartz kindle
#

it doesnt matter

jaunty stump
#

oh

quartz kindle
#

await is for promises

#

filter is not a promise

#

you want to check the position of the bot's highest role?

#

you can use member.highestRole

jaunty stump
#

yea

#

ok

#

and if it isn't the highest make it send the embed

quartz kindle
#

so message.guild.me.highestRole

#

gives you the highest role of your bot

jaunty stump
#

ok

quartz kindle
#

then you can use role.position or role.calculatedPosition

#

afaik, the highest role would be position 0

#

any other number means the role is not the highest

outer niche
#

shivaco any other suggestions

jaunty stump
#

ok

quartz kindle
#

why highestRole.forEach?

#

highestRole is one role

outer niche
#

'VoiceClient' object has no attribute 'create_ytdl_player' how can i fiz this

quartz kindle
#

not many

jaunty stump
#

ok

sudden geyser
#

it's a role, not a function.

jaunty stump
#

what would I need to change now?

quartz kindle
#

highestRole is already a role

#

just remove the entire code block

#

you can call directly highestRole.position

jaunty stump
#

ok, so say it is already checking to see if it is the highest role with highestRole.position, I now need it to check if it isn't and if it isn't then it needs to send that embed

quartz kindle
#

check if its bigger than 0

jaunty stump
#

so keep if (role.position < 0){

quartz kindle
#

thats checking if its smaller than 0

#

it cant be smaller than 0

jaunty stump
#

so keep it? if the highest role position is 0 then yes?

quartz kindle
#

if its 0 then it means its the highest

#

if its bigger than 0, it means its not the highest

jaunty stump
#

so what would I do?

quartz kindle
#

check if its bigger than 0

jaunty stump
#

if (role.position > 0){ so this then?

grizzled raven
#

yes

jaunty stump
grizzled raven
#

check if its equal to the amount of roles in the server if your want to check if its the highest role in the server

#

role.position > 0 will always be true unless it doesnt have a role

#

also that should be let role = message.guild.me.highestRolw

jaunty stump
#

ok
let role is now there

#

now what?

quartz kindle
#

isnt the highest role 0? or are roles reversed in order?

grizzled raven
#

0 is the lowest role

jaunty stump
#

then what is the highest?

grizzled raven
#

higher it is, bigger the number

#

the highest is the amount of roles in the server

jaunty stump
#

well that sucks

#

what do I do to replace it then?

quartz kindle
#

well then just do if(role.position === guild.roles.size-1)

jaunty stump
#

ok

grizzled raven
#

do >= if you have anxiety like me

jaunty stump
#

ok

grizzled raven
#

well guild isnt defined

#

tim saying guild was his placeholder

quartz kindle
#

yeah, message.guild

jaunty stump
#

Well this bot will be in many servers not just one

grizzled raven
#

just replace guild.roles.size with message.guild.roles.size

jaunty stump
#

ok

quartz kindle
#

wait you want the message if not the highest

#

so change it to position < .size -1

jaunty stump
#

I want the bot to check if Its role is the highest, if it isn't send the embed

grizzled raven
#

oh yeah

jaunty stump
#

ok

grizzled raven
#

!==, or <=

#

change the === to*

jaunty stump
#

=== is changed to >=

#

Let me fix it

grizzled raven
#

oh wait

#

thats wrong

jaunty stump
#

what is wrong ?

grizzled raven
#

yeah just change the operator to <

jaunty stump
#

like that?

#

ignore the space

#

role.position < .size -1){

quartz kindle
#

๐Ÿคฆโ€โ™‚๏ธ

#

dont literally copy and paste, think with context

grizzled raven
#

yeah 2 people explaining how to compare numbers must be confusing

jaunty stump
#

yea..

quartz kindle
#

me writing .size -1 doesnt mean "remove message.guild.roles"

jaunty stump
#

so it would be

#

if (role.position >= message.guild.roles.size -1){

grizzled raven
#

ok just do role.position < message.guild.roles.size

#

thats all

jaunty stump
#

ok, lemme try it

#

it worked

#

Thank you guys for the help with the code and helping me learn something new

outer niche
#

'VoiceClient' object has no attribute 'create_ytdl_player' how can i fix this

unique nimbus
#

You are taking code from 0.16.4

#

it is 1.x.x now

#

I forgot what

#

create_ytdl_player doesnt exist anymore

outer niche
#

so how can i fix it

unique nimbus
#

read

#

create_ffmpeg_player/create_stream_player/create_ytdl_player have all been removed.

The goal is to create AudioSource instead.
outer niche
#

nun of that maches this tho ```@bot.command(pass_context=True)
async def play(ctx, url):
server = ctx.message.guild
await ctx.send('Music now playing...')
voice_client = ctx.guild.voice_client
player = await voice_client.create_ytdl_player(url, after=lambda:
check_queue(guild.id))
players[server.id] = player
player.start()

modest maple
#

Because it's all outdated c+p code

outer niche
unique nimbus
#

did you take it from here

#

it looks nearly identical

earnest phoenix
#

this is fun, working on 3 different layers of an app that has to be done by thursday

unique nimbus
#

as I said before we don't use create_ytdl_player anymore

modest maple
#

Almost 100% coppied from outdated code

#

Which is why we told you AGES ago to consider something else e.g lava link or another alternative

earnest phoenix
outer niche
modest maple
#

That's pretty clean cry

outer niche
modest maple
#

We saw the error

slender thistle
#

Out of context without Peter's message it looks like cry is being told not to copy paste code

earnest phoenix
#

ikrrr i'm so proud of myself for doing clean design

modest maple
#

No need to keep sending it

earnest phoenix
#

lol shivaco

modest maple
#

Xd

unique nimbus
#

@earnest phoenix well done

#

Teach me one day

earnest phoenix
#

it's surprisingly not that hard

#

electron docs are really good

#

i've never seen cleaner docs

unique nimbus
#

You are talking to someone who struggled with making loops in python for a while

earnest phoenix
#

F

unique nimbus
#

yes

#

I mean I am smarter now

#

and just made playlists work for music

#

but yes

#

I will see later

modest maple
#

I've spent a fair bit of time today compiling python scripts xD

quartz kindle
#

e-education
modernization of teaching methods

earnest phoenix
#

yeah

unique nimbus
#

yes

#

I still need to make my website

earnest phoenix
#

it's for a comp, basically allows hosting classes online, keeping track of exams, homework and your school timetable

unique nimbus
#

but I can't CSS for crap and make good designs

quartz kindle
#

the beauty of the slavic languages, know one and you automatically know many

earnest phoenix
#

this

unique nimbus
#

Ah yes Russian

#

oh

#

that isnt slavic is it

quartz kindle
#

its serbian/croatian i think

earnest phoenix
#

croatian yeah

unique nimbus
#

Russian (ั€ัƒััะบะธะน ัะทั‹ะบ, tr. rรบssky yazรฝk) is an East Slavic language

#

Wikipedia N.1

slender thistle
#

They're kinda similar in pronunciation and spelling

unique nimbus
#

that is what Tim said basically

#

i think

slender thistle
#

Yup

unique nimbus
#

ye

quartz kindle
#

i know slovenian, so croatian is not hard to understand

#

but if someone speaks croatian to me i wont understand shit

unique nimbus
#

lmao

modest maple
#

just your standard British boi passing by

earnest phoenix
#

lol

#

mood

unique nimbus
#

I mean I am both Russian and British

#

but I can't speak/understand Russian for crap

#

Need to learn

modest maple
#

I can only speak one Language and I even speak that badly

unique nimbus
#

same

#

ngl

obtuse wind
#

Node.js, // discord.js, I need help

#

2 of my bot commands aren't loading .-.

#

idk what to do about that

minor kelp
#

What ones aren't loading?

#

@obtuse wind

obtuse wind
#

send message, clearxp, addxp, trainingon, trainingover commands

#

oh and my warnings command as well

lilac wharf
#

Are you sure you're actually registering them?

outer niche
#
async def play(ctx, url):
    server = ctx.message.guild
    await ctx.send('Music now playing...')
    voice_client = ctx.guild.voice_client
    player = await voice_client.create_ytdl_player(url, after=lambda: 
    check_queue(guild.id))
    players[server.id] = player
    player.start()``` ```'VoiceClient' object has no attribute 'create_ytdl_player'```
vital lark
#

it's saying the voice client doesn't have a create_ytdl_player function

#

I don't use discord.py so I would recommend looking at the documentation of the library

outer niche
#

how can i fix it

vital lark
#

look at the VoiceClient documentation page

outer niche
#

i can not find it

blissful scaffold
#

read that and the links before and after that message

outer niche
blissful scaffold
#

we already explained you a couple times today what a NoneType object is, that object does not exist

outer niche
#

I get object does not exist but how do I fix it

blissful scaffold
#

the screenshot you just send seems to have no relation to the code you showed

outer niche
#

bs

#
async def play(ctx, url):
    server = ctx.message.guild
    await ctx.send('Music now playing...')
    voice_client = ctx.guild.voice_client
    player = await voice_client.create_ffmpeg_player(url, after=lambda: 
    check_queue(guild.id))
    players[server.id] = player
    player.start()```
blissful scaffold
#

create_ffmpeg_player/create_stream_player/create_ytdl_player have all been removed

outer niche
#

I have read everything yet I have not been able to figure out how to fix it cuz I replaced it was ffmpeg

blissful scaffold
#

Then you also saw this:
The goal is to create AudioSource instead.

#

and read the documentation links that are posted there

outer niche
#

Yes

outer niche
#

I have read them a literally have them pulled up in front of me you know what screw this I am paying someone to do it

blissful scaffold
#

The first thing in the voice changes document is this:
Connection is done through VoiceChannel.connect() instead of Client.join_voice_channel.

outer niche
#

I don't want that I don't want it to join using this command

blissful scaffold
#

when the bot joins a channel store it in a variable and use that variable to play or stop music

#

how you keep track of the variable is up to you

outer niche
#

This is more complicated and has taken longer than it should have I'm just going to pay someone to do it

slender thistle
#

Jesus suffering fuck

blissful scaffold
#

Hey Shivaco, are you a python dev and do you want to make some money? Kappa

slender thistle
#

Yes I am and probably

blissful scaffold
#

Culan is looking for a dev

hoary elm
#

Not sure if this is really development related but are there very many bots who track mutes...

Example: if a server member recieves 5 Mutes they get a warning through the bot for receiving to many mutes. If they recieve 10 mutes they get kicked 15 they get banned ect..

If this is not a thing would it be useful? Obviously I would make an option to either disable or enable it for your server but just wanted some opinions on this feature

EDIT: Yes I have looked around on the bot list but have yet to find one that does this (that doesn't always mean there isn't one as bot descriptions don't always go in depth with command lists)

earnest phoenix
#

auto modding

#

yeah

#

it's useful

#

a lot of private bots have it

hoary elm
#

The bot this would be in is public and will be on the list when approved

earnest phoenix
#

i inplemented that, kinda, in my open src bot

#

implemented*

hoary elm
#

Hmm okay, thanks ๐Ÿ˜ I'll look into making it maybe after the bot is approved for the list so I don't experience a downtime and then they try to test it while it's down๐Ÿ‘Œ

earnest phoenix
#

tip, use different bots for debugging/developing and an actual production build

blissful scaffold
#

I always test with a different bot

hoary elm
#

๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ that is actually a good tip but never crossed my mind ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

#

Lol

blissful scaffold
#

that way my main bot is only offline for a few seconds while updating to a new version

knotty steeple
#

@earnest phoenix test on prod tree_cool

hoary elm
#

I will do that ๐Ÿ˜‚๐Ÿ˜‚ thanks again

blissful scaffold
#

It also forces you to store your tokens in a settings file so you wont leak it if you ever share your code with someone

#

And I stored a few other settings that are different between my test bot and production bot in that settings file

hoary elm
#

I always use process.env.BOT_TOKEN anyways ๐Ÿ˜‚

#

Always have

#

Token is defined via variables outside the bots code

knotty steeple
#

i just dont share my bot files

#

simple

blissful scaffold
#

same, my bot is my code

knotty steeple
#

just use a proper gitignore file

#

or just dont upload

#

it

hoary elm
#

I do make open source ones though so ๐Ÿคท๐Ÿปโ€โ™‚๏ธ if anything .gitignore is useful

blissful scaffold
#

i also store the code on a git server that i own

hoary elm
#

Also lately GitHub has been good for flagging public projects that have tokens in them I did it ONCE and my bot went offline almost instantly and then GitHub sent me a notification

blissful scaffold
#

(it's just a simple gitlab docker container that runs on my nas)

hoary elm
#

Was that hard to set up? I have been thinking about trying it

#

The gitlab docker thing

blissful scaffold
#

if you know how docker works then its not hard at all

hoary elm
#

I know a bit not a lot

#

But I am always open to learn

blissful scaffold
#

you do need more than 2GB of ram because it loves ram

hoary elm
#

Yeah I should be good there

blissful scaffold
#

I am running Synology Gitlab on my Synology NAS, I don't know how easy other gitlab docker containers are

hoary elm
#

I will look into it ๐Ÿ˜ my current project is attempting to work with discord webhooks for GitHub (essentially I want to make my own commit updates bot)

blissful scaffold
#

so that it posts a message on your server every time you commit something?

#

interesting

knotty steeple
#

yes

hoary elm
#

Yeah it's been a pain so far due to the fact that I'm not the best with webhooks yet but ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

knotty steeple
#

its a webhook

#

its not hard to setup

hoary elm
#

I know thats not hard to set up I meant I want my own

knotty steeple
#

and you can find a simple guide on google

hoary elm
#

Custom one

knotty steeple
#

its the same

blissful scaffold
#

the theory behind webhooks is pretty easy, but i havent worked much with them yet

#

in my private bot i accidentally implemented something that looks like webhooks without knowing what webhooks are

hoary elm
#

Hahah so it was a good mistake

blissful scaffold
#

it's just a basic web server that gets pinged every time someone visits a forum with data about the page the person is visiting

#

because the MMO guild im in wanted to use a forum and link the forum with discord

hoary elm
#

Interesting

#

I have done something similar but it was with FiveM if you know what that is

blissful scaffold
#

we use proboards and they allow you to create plugins

hoary elm
#

Hmm nice so setup was pretty simple?

blissful scaffold
#

so i created a simple JS plugin that sends simple JSON files to the bot every time someone uses the forum

hoary elm
#

Interesting

blissful scaffold
#

the only thing is that i cant do anything from the server side of the forum, so the clients/people that connect to the forum send the data that i need through to my bot

#

the most important thing is that my bot gets informed every time a new post is created on the forum and it will then post that on discord

hoary elm
#

So then they can go and check the post yeah that seems pretty useful

blissful scaffold
#

yeah, and i learned to love AJAX calls ๐Ÿ˜„

hoary elm
#

Lol

blissful scaffold
#

or whatever its called, im not a js dev

hoary elm
#

Most in depth I have gone with webhooks is my buddy ran a FiveM Server (Private GTA Online Servers) used mainly for police roleplay, and wanted something set up so that when people join and leave the server, type commands in the server chat or die. It posts it in a discord channel... Only downside is FiveM uses LUA for their scripts ๐Ÿคฎ but it was pretty easy to make each of those events can be called to different channels and the death logs I have set up so that it says how and where on the map they died

#

But I am familiar with coding when it comes to game related coding so that was easy

blissful scaffold
#

I think I used LUA once in minecraft for a computer mod, it was an interesting language

hoary elm
#

It is interesting for sure lol

blissful scaffold
#

but it's 6 years ago or so and i forgot 90% of it

hoary elm
#

I still actively work with it as i still make scripts for FiveM and post them on their modding/public script forums

blissful scaffold
#

I will be leaving now, it's close to 4am here ^^

hoary elm
#

Ahh good night ๐Ÿ˜ thanks again for your help

blissful scaffold
#

no problem, good luck with your bots

earnest phoenix
#

how do you get the maximum cpu for the process

hoary elm
#

@earnest phoenix what language?

knotty steeple
#

what do you mean max cpu

#

if you use node.js you can find everything about the host machine/os with the os module

#

require("os")

hoary elm
#

๐Ÿ˜

knotty steeple
#

i have nitro im 2000iq

#

makes sense

hoary elm
#

Lol I sent that cause you beat me to it

#

But yeah makes sense ๐Ÿ‘Œ nitro = instant IQ boost

knotty steeple
#

lmao i shouldnt shitpost here

zealous veldt
#

What is the best way to pass things like a connected database client, etc. into an express router for its routes to use? I don't want to be creating connections to my database for each router. Currently, I'm thinking of injecting the stuff I need into the req or res objects using middleware, but that doesn't seem like good practice and isn't optimal. Please ping me with any response

valid frigate
#

i was gonna suggest global variables but only for the database since it's not constantly changing and therefore can't be in conflict

#

by exporting it out of a certain file and allowing it to be used everywhere, so long as it isnt changing it should be fine

#

i know there's been some conflict around using global variables that aren't constant, but really it should be up to you

#

otherwise if you're fine passing a database client as a parameter for every callback that needs it that also works but might be less optimal; from personal experience a database as a global variable has never caused any issue

#

so like export const databaseClient = etc... should be good enough

#

@zealous veldt nerd

#

additionally this is just speculation but passing a database client through every request/response object could bloat your app's memory usage and make it extremely slow since js duplicates parameters

zealous veldt
#

that's why I don't want to pass it through

#

I might use app.locals

valid frigate
#

yeah

#

if you can maybe put the entire app into a class then just make the db a property

#

readonly*

earnest phoenix
#

How do I make pages for arrays like 25 values per page? I am using discord.js. I need pages because a Discord embed field cant handle all my array values.

#

if you want me to get into more detail of what I am doing, I am basically trying to make pages for my botโ€™s playerโ€™s inventory because their inventory wont show up due to their inventory array having too many items

#

let pages = Math.ceil(stats.beys.length / 25); if(pages === 0) pages = 1;
  if(args[0] && args[0] === "page" && parseInt(args[1]) > pages) return message.reply("no page found.")
  stats = await db.collection("users").findOne({_id: message.author.id});
  let page = parseInt(args[1]);
  let amtshift;
  let amtslice;
  if(page === 1){
    amtshift = 0;
    amtslice = 0;
  }else{
    amtshift = (page-1)* 25;
    amtslice = (page-1) * 25;
  }
  stats.beys.slice(0, amtshift-1);
  stats.beys.slice(amtslice, stats.beys.length - 1);
    for(var i in stats.beys){
    binfo += `**[${parseInt(i)+1}]:** \`${stats.beys[i].name} (Level ${stats.beys[i].level})\`\n`;
    }
``` This is the code I tried but none of the values are sliced. Might just be me being stupid.
late hill
#

slice doesn't edit the original array

#

you have to use the returned value

#

Not sure if that will make it work, but that's definitely an issue

earnest phoenix
#

How to host 24/7 free a discord bot without glitch or heroku or self host

mossy vine
#

you dont

#

maybe you can find a friend who lets you use their vps

earnest phoenix
#

I don't have friends with vos

#

They didn't even know what is a vps

mossy vine
#

then too bad mmLol

quartz kindle
#

google and amazon have free for 12 months

#

you can use both and get free for 24 months

#

you just need a credit card to create your account

earnest phoenix
#

Good but what to do after 2 years lol

mossy vine
#

pay

wicked pivot
#

hello excuse me for bothering you i just created an xp system with my bot and i don't know how to do that if a member leave the server its deletes are xp

mossy vine
#

listen to the member leave event and delete its xp

earnest phoenix
#

ok my typing speed is slow lol

#

what library are you using?

wicked pivot
#

yes i know the event "guildMemberRemove" of course but i don't know how to delete his xp

earnest phoenix
#

Do you use a non sql or sql database?

#

or do you just use JSON?

wicked pivot
#

I would like to use a SQL database but I don't know how it works too x)

earnest phoenix
#

same

#

but how are we supposed to help you without knowing what kind of database u r using?

wicked pivot
#

json

earnest phoenix
#

JSON is not a database

#

but it works as one

#

you can use delete thing like ```js
delete JSON[โ€œ123โ€]

mossy vine
#

json should never be used as a database

earnest phoenix
#

I used it before and i got issues with it saving so I switched to MongoDB

wicked pivot
#

what else can i use? end what do you advise me?

earnest phoenix
#

MongoDB

#

it has a free plan and works like JSON

wicked pivot
#

okay i will watch this

earnest phoenix
#

you can use the Mongoose or MongoDB driver for MongoDB if you are using JavaScript

wicked pivot
#

I'm using JavaScript so I'm going to watch this

earnest phoenix
#

watch what?

#

a YT tutorial?

#

ok gl

wicked pivot
#

To use MongoDB

#

too complicated for me x)

#

Can someone just tell me what I can use to check if the user has XP if yes deleted it?

bot.on('guildMemberRemove', async(member) => {
  if(xp.indexOf(member.user.id)){
    delete xp[member.user.id]
    write()
  }
})```
quartz kindle
#

if you want the absolute easiest to use, go with enmap or something

#

or an ORM

hidden pecan
quartz kindle
#

if you want simple and efficient, go with sqlite (requires learning sql)

wicked pivot
#

it's a custom bot for a 3000 member server I don't think I need a big database

#

I did everything I need I just miss it, because if I don't delete its xp my top command doesn't work anymore

quartz kindle
#

well, if its just one server, json should be fine, if you use it correctly

#

there are some tips and tricks you should follow if you decide to go with json

#
  1. load the file once at bot start
  2. keep the entire file in memory as an object
  3. only write to file when changes occur
  4. dont write directly to file, write to a temporary file first and then rename it
  5. keep backups
wicked pivot
#

load the file once at bot start "
How?

quartz kindle
#

are you using javascript?

wicked pivot
#

fs.writeFile ?

#

yes

quartz kindle
#

let database = JSON.parse(fs.readFileSync(your file))

wicked pivot
#

oww okay it's already done ^^ '

const xp = JSON.parse(fs.readFileSync("./exp.json", "utf8"))```
quartz kindle
#

alright, now all your read operations should be done in memory, ie: always use xp[something] and never use fs.readfile again

wicked pivot
#

this is what i do ^^

quartz kindle
#

and when you do changes, like xp[something] = somethingNew or delete xp[something]

#

you write a copy to file

#

fs.writeFile(your file, JSON.stringify(xp))

#

but dont write it directly to the main file

wicked pivot
#

because there is a risk of error I imagine?

quartz kindle
#

do something like js fs.writeFile("exp_temp.json", JSON.stringify(xp), "utf8", err => { if(err) { throw err } fs.rename("exp_temp.json", "exp.json", err => { if(err) { throw err } }) })

#

of course, do your own error handling to avoid crashing the bot

wicked pivot
#

it's taken note

fleet chasm
#

when i try running my join command i get
**Error while joining** FFMPEG not found
however, i have downloaded ffmpeg

quartz kindle
#

and yeah, to answer your original question, you can easily delete an entry by doing delete xp[something]

#

and then saving the file

wicked pivot
fleet chasm
#

already done that

quartz kindle
#

did you install it in node as well?

fleet chasm
#

yes

quartz kindle
#

did you rebuild the relevant audio packages?

wicked pivot
#

yes yes I know but I would like to check if the user has XP and if he deleted it

fleet chasm
#

let me check

quartz kindle
#

run npm rebuild

#

@wicked pivot what do you mean?

wicked pivot
#

to earn XP you have to write on the server in questions do you agree with me?

fleet chasm
#

rebuilt them successfully, still getting the error

quartz kindle
#

did you add ffmpeg to PATH?

#

did you restart your system after adding it?

#

yes Tony

wicked pivot
#

the user can leave the server without ever writing a message, so I would like to make an "if" which checks if it has any

quartz kindle
#

you can easily do if(xp[userid]) { delete xp[userid] }

#

however you dont even need it because delete doesnt cause any errors, it will delete if found, and do nothing if not found

#

i dont know how your json structure looks like, but im assuming its organized by user ids

wicked pivot
#
{"363402633752477696":{"xp":2,"pseudo":"363402633752477696"}}```
#
bot.on('message', async message => {
    
    if(message.author.bot)return;
    
    if(!xp[message.author.id]) {
      xp[message.author.id] = {
          xp: 0,
          pseudo: message.author.id
          };
      }```
#

and for my "top xp" system I don't really have the choice to delete the XP after a leave

#
if(message.content.startsWith(prefix + "top")){
      let trier = Object.values(xp).sort(function(b,a){
        return a.xp - b.xp
      })
      let xppp = trier.map(e => trier.indexOf(e) + 1 + ") " + message.guild.members.get(e.pseudo).user.tag + " - " + e.xp + "message").slice(0,15).join("\n")

      let embed = new Discord.RichEmbed()
       .setTitle('Le top du serveur en terme de message !')
       .setColor('#dc143c')
       .setDescription(xppp)
       return message.channel.send(embed)
     }```
quartz kindle
#

there is always a choice

#

if you want to delete, its easy, just do js client.on("guildMemberRemove", member => { delete xp[member.user.id]; fs.writeFile(etc...) });

#

if you dont want to delete, you can use array.filter

wicked pivot
#

I have what I need on that thank you now I'm going to take the lead to make a top but for the time pass in voice

quartz kindle
#
let filtered = xp.filter(id => message.guild.members.has(id)); // requires caching all members
let trier = Object.values(filtered)...

or

// keep a variable in xp indicating if user is in guild
let filtered = xp.filter(id => id.inGuild);
let trier = Object.values(filtered)...

wicked pivot
#
bot.on('voiceStateUpdate', async(bot, oldMember, newMember) => {
  let newUserChannel = newMember.voiceChannel
  let oldUserChannel = oldMember.voiceChannel

  if(oldUserChannel === undefined && newUserChannel !== undefined) {
    if(!voicetime[message.author.id]) {
      voicetime[message.author.id] = {
          seconde: 0,
          minute: 0,
          hour: 0,
          day: 0,
          pseudo: message.author.id
          };
      }
      
  }
})``` now I just have to find a way to put each +1 its second +1 per second
quartz kindle
#

dont put +1 each second

#

record a timestamp for when they join and when they leave, and calculate the difference

wicked pivot
#

not stupid

#

what i do is good? ```js
if(voicetime[oldMember.member.id].seconde === "60"){

  let currentSeconde = voicetime[oldMember.member.id].minute;
  voicetime[oldMember.member.id].seconde = "0"
  voicetime[oldMember.member.id].minute = currentSeconde + "1"
  }```
quartz kindle
#

no

#

its too complicated and prone to errors

#

you should only save one type of data

wicked pivot
#

in the worst case I put that second in my json then after I calculate with the command "top"? like this its will not touch the json

#

excuse me if my english is pitiful i use google translate x)

quartz kindle
#
.on("voiceStateUpdate", blablabla => {
  if(user joined) {
    voicetime[user id].lastJoined = Date.now();
  } else {
    voicetime[user id].lastLeft = Date.now();
    voicetime[user id].total += (voicetime[user id].lastLeft - voicetime[user id].lastJoined)
  }
})```
#

then when you want to show, in an embed for example, you do the calculation to convert the miliseconds to seconds, minutes, hours, days, etc

#

but you dont save them, you only save the miliseconds

wicked pivot
#

okay

#

I will test it all ^^

wicked pivot
#

someone can help me ?

storm bluff
unique nimbus
#

canvas?

storm bluff
#

ya

#

yes

#

@unique nimbus

unique nimbus
lofty vine
#

I need help with Discord Rich Embed's field names

#

//Code:-
const moderationemote = client.emojis.get("664381246553456640");
const embed = new Discord.RichEmbed()
.addField(${moderationemote}Moderation,'xyz');
message.channel.send(embed);

#

//Error:-
undefinedModeration //this apperas as a feild name idk why

#

//additional
I have tried using :- <:emoji_name:emoji_id>

#

How do I fix it?

restive furnace
#

Emoji wont exist or its uncached.

lofty vine
#

emoji exists

#

@restive furnace

#

uncached?

blissful scaffold
#

when it's animated it needs to start with <a:

#

I don't know why your emoji isn't working in your code, maybe you can't have an emoji in a field title?

earnest phoenix
#

I heard someone else here say you cant, but idk how true that is

sage bobcat
#

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.

green kestrel
#

i see quite a few bots running on rpi

#

in theory how far can a bot on rpi scale

#

assuming it's written in node with d.js

#

or similar

earnest phoenix
#

i mean if it has 4gb of ram

#

pretty far?

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

^

green kestrel
#

no hard figures on that then? i'd be curious to know

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

green kestrel
#

last i checked a mid range rpi struggles to even run a desktop environment smoothly?

wicked pivot
#

someone can help me ?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

green kestrel
#

no doubt someone can, the question is who

#

and with what?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

blissful scaffold
#

It really depends on what you expect the bot to do

sage bobcat
#

One message removed from a suspended account.

green kestrel
#

yeah this isnt something i plan to try @sage bobcat i was curious

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

green kestrel
#

i have something rpi-like with 4 network ports on it at home, but i use it as my router

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

green kestrel
#

ive just passed 750 servers

blissful scaffold
#

If it just post funny memes when you do !meme then it can probably handle a lot of servers

#

if you want it to play music then it can handle a lot less servers

sage bobcat
#

One message removed from a suspended account.

wicked pivot
#

I would like to make a system that counts the number of times spent in a vocal

green kestrel
#

im currently using a dedicated server and wouldnt 'downgrade' to an rpi, it would be silly for me to do so

wicked pivot
#

problem I do not really know how to do

green kestrel
#

im currently battering the dedi, teaching my bot half of project gutenberg

sage bobcat
#

One message removed from a suspended account.

blissful scaffold
#

if a dedicated server is already struggling then don't run it on a RPI ๐Ÿ˜›

green kestrel
#

yeah exactly my thought lol

#

this is the result of me hammering it the past two days... what looks like a line of zero isnt... its 3000-4000 learned facts a day of normal discord use of 750 servers

#

in fact i might have to hide that spike from the graph

#

it makes it useless for a month, lol

blissful scaffold
green kestrel
#

yeah i see a similar pattern long term with bandwidth

#

mines partially due to nightly backups, though, it was smooth like yours until i added that

quartz kindle
#

the problem with discord is that they hammer your server with presence updates that most bots dont even use

green kestrel
#

yeah

#

and the majority of those come from here

blissful scaffold
#

my traffic only shows the spikes when I send the backups to my local machine every night

#

it overpowers all other traffic

green kestrel
#

you can turn off guild subscriptions but it hamstrings your bot

quartz kindle
#

remove the presence updates and your cpu usage drops by 80% and your bandwidth usage drops by 90%

green kestrel
#

part of that problem is bots sending presence updates every 30 seconds

quartz kindle
#

yeah i made a framework to work around the issues of disabling guild subscriptions, as well as cache control

green kestrel
#

when you have a server of 20,000 bots...

blissful scaffold
#

I guess my bot is one of the few that uses the presence updates

quartz kindle
#

the result is that now my bot uses 50mb ram and 1% cpu on 2000 servers

#

compared to before, which was 10% cpu and 400mb ram lol

green kestrel
#

i had something similar to that, where i had a cache updater that ran every 30 mins and connected to discord with guild subscriptions on, cached everything, then disconnected... and the main bot ran with guild subscriptions off and queried the database the cron job updated

#

but it was unsustainable, because the updater was running for longer and longer

quartz kindle
#

yeah, i just dropped presences altogether

blissful scaffold
#

I noticed that my java bot only runs a garbage collection when it needs to, since I allowed it to use 2GB ram it often goes up to 1.5GB before going down to 200MB again

green kestrel
#

now what i do is i cache to a database, but when i receive the guild create message i send the users and channels into a queue, and a separate thread processes the queue doing INSERT INTO ... ON DUPLICATE KEY UPDATE

#

i dont have any code looking at presences

#

but the framework must still parse them just like any other message, otherwise you can get out of sync with your sequence numbers

quartz kindle
#

the only unfixable problem with disabling subscriptions is that you no longer receive member joins, which is a deal breaker for many bots

green kestrel
#

i did consider hacking the framework to find the sequence number using a simple regular expression

#

but the gains are minimal, my cpu usage isnt really caused by presence any more

#

not since moving to C++

#

bandwidth is, though

quartz kindle
#

yeah, my vps was using 500gb per month lol

green kestrel
#

and thats probably 5x more than it should be due to a framework bug

#

it busy loops where it shouldnt

#

the bottom leaves of the tree are native threads sharing the same ram as the parent process

quartz kindle
#

yeah c++ is really efficient

#

just much harder to work with

#

and im too lazy to learn it

#

lul

green kestrel
#

lol yeah its not the best language for bot dev at all

#

i wouldnt have chosen it if i didnt already know it

#

like last week i had a bug ... you know what sql injection is yes?

quartz kindle
#

yup

green kestrel
#

well i had code in my bot that takes an sql query with ?'s in, and an array of parameters

#

it was supposed to call mysql_real_escape_string on each parameter to escape it and then insert it into the query in place of the ?

#

it was doing that but the buffer for the output string was too small

quartz kindle
#

ah yes, i saw when you posted about it before

green kestrel
#

so anything with ' in would overflow the buffer by a couple of bytes and corrupt the stack causing a weird crash like 5 mins later

#

so by ensuring security i made security worse lol, only in C++ or C would that be a thing

quartz kindle
#

yeah, only C langs let you overflow memory lol

#

everything else is sandboxed af

green kestrel
#

yeah

quartz kindle
#

but like, if you're already using prepared statements, you dont really need escape strings as well

green kestrel
#

yeah my code doesnt use proper prepared statements

quartz kindle
#

ah

green kestrel
#

it uses a wrapper i made years ago that acts like prepared statements

#

i have a big fat TODO and FIXME in there, telling future Brain to convert it to proper prepared statements

#

but you know that future brain hes lazy af

#

takes him years to do what i tell him lol

quartz kindle
#

very relatable lmao

green kestrel
#

you know whats funny? that bit of buggy code i copied from an old project, i dev'd that project like 10 years ago... and i copied the code from my old branch

#

so after i found my bug i went and looked at the current code of that project

#

and they'd found and patched that bug years ago lol

quartz kindle
#

my bot is quickly approaching the 2500 guilds threshold and its still running on json, old framework version, and not sharded

green kestrel
#

eek

quartz kindle
#

and i've been delaying the rework in forever

green kestrel
#

im sharding with 10 shards on 750 servers

blissful scaffold
#

During my study I had to work with C++ for 1 semester and decided to stay with something simpler like Java

green kestrel
#

theres nobody else using aegis.cpp that has a bot with more than about 20 servers on it, so i sharded to be double sure the code works right at scale

#

didnt want to be tripped up at 2490 servers and then be shouting at the library dev in a years time or whatever

quartz kindle
#

hahah

green kestrel
#

i do want them to add something i call 'shard affinity' though

#

right now how it works is you tell it how many shards, and it spawns a bunch of asio worker threads.... shard affinity would tell it that this process is only to identify for shards within a specific range

#

that way i can run half the shards on one physical server and half on another

quartz kindle
#

the framework doesnt support that?

green kestrel
#

no

#

all shards on one process only, atm

quartz kindle
#

javascript's framework does, not sure about others

#

but it isnt hard to implement

green kestrel
#

yeah, the one i used previously was strictly one shard, one process

#

with a shard id on boot

#

thats the opposite end of the spectrum lol

blissful scaffold
#

I think Discord4J will implement it in the next major release

#

But I usually hate major releases because they break everything

green kestrel
#

yeah

#

ive been asked the question already:

so if i do a major rewrite and change the libraries api are you up for that
to which the answer is
i'd rather not
lol

#

you know how us devs are for wanting constant change

#

problem is there are a few little niggling bugs that will neccessitate basically a library rewrite

quartz kindle
#

its weird how you look at old code, and you see how much you have improved and how you could do everything 10x better now, but at the same time you're like "nah, it still works, i dont feel like redoing something i already did"

blissful scaffold
#

The problem is also that without code breaking changes it is sometimes really hard to make stuff better

green kestrel
#

like if i want to get the result of a DM, i can do user->create_dm_message("lol foo").get(); and a message that failed to send (e.g. blocked) results in a thrown exception, so i can wrap it in a try block then send a channel message going "fool"... problem is, that doesnt work

#

the promise implementation is broken

#

and maybe 5% of the time it'll segfault

#

so i cant use that atm, i fire-and-forget the dm, and hope the user hasnt disabled dm's from the bot

quartz kindle
#

dealing with segfaults is nightmare

green kestrel
#

yeah especially if its not in your own code lol

quartz kindle
#

yeah lmao

green kestrel
#

the other strange bug it has is randomly at exactly midnight it will suddenly start eating 100% cpu on all ASIO threads

#

bot still works fine, responds just as fast as before, but im sure somewhere at the datacentre theres some tech with a fan, and a book, wafting on the rack to keep my server cool lol

#

it does that till i restart the bot

quartz kindle
#

lmao

sage bobcat
#

One message removed from a suspended account.

blissful scaffold
#

I worked with Ruby for a year for a work related thing

#

But it has been a few years ago

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

This might help

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

unique nimbus
#

yes

sage bobcat
#

One message removed from a suspended account.

blissful scaffold
#

that guide might be of more use than me

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

blissful scaffold
#

I always try to forget any language I learn as quickly as possible after I stop using it

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

DVSAEZI Today at 14:29
do you remember how to do http requests

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

look through the website

#

it has a GET request example

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

and POST

blissful scaffold
#

you get an error when trying it?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

unique nimbus
#

try it

blissful scaffold
#

We didn't work much with http requests

#

and the times we did I used google a lot ๐Ÿ˜„

unique nimbus
#

google is amazing

quartz kindle
#

my only experience with ruby is with RPGMaker

#

which was like 15 years ago

modest maple
#

Who even still uses ruby

quartz kindle
#

idk, not me

blissful scaffold
#

The only reason why people ever used Ruby was with Ruby on Rails 5 years ago

quartz kindle
#

wasnt ruby on rails like a in-between php and node.js?

#

lul

barren estuary
#

Hey guys.. Am I allowed to ask why my bot as been declined.. because the tester as no admin rights for testing the admin commands..
I think it is obvious that the admin commands need the admin permission..

earnest phoenix
#

Maybe it's obvious to you

#

but not so much the user

unique nimbus
#

Specify that the user need administrator perms to use the command

#

ยฏ_(ใƒ„)_/ยฏ

earnest phoenix
#

contact the mod to resolve it

quartz kindle
#

there are people who have no idea what even roles are

barren estuary
#

yeah but why would I call this command category admin commands

quartz kindle
#

there are users who have no idea what roles are and what admin means

barren estuary
#

ok and what should I write.. ? only available with admin rights

quartz kindle
#

anyway, check who declined your bot, and dm them to resolve it

modest maple
#

Admin commands don't need admin perms

#

You should check for more specific perms

#

And most servers won't just give mods etc... Administrator

#

And the bot shouldn't need admin either

barren estuary
#

yeah you are right

viral spade
#

Hello,
please can someone point me the way, how do i distribute my bot?

The bot is running in a container already, and i think i should learn kubernetes for distributing it, but how do i tell the sharding manager what node to start what shards on? Also, should i make 1 shard per container or only 1 container for all bots on a certain node, with a sharding manager in it?

Help is much appreciated if anyone has knowledge on this!

barren estuary
#

@modest maple you can remove the admin permission from the bot. but than there aren't all commands available

blissful scaffold
#

@barren estuary your bot just says it is missing something, you need to be specific and say WHAT role the person needs or what permissions the bot needs when it is missing

modest maple
#

You shouldn't need admin perms

#

You can do everything without needing the admin permission

#

If you give a bot admin it's just asking for abuse

blissful scaffold
#

and yeah, don't use the admin permission for public bots

modest maple
#

One token leak and your bot has just fucked hundreds or possibly thousands of servers

#

And got itself rate limited and possibly banned for API abuse

barren estuary
#

than the server has to forgive roles called BotController or somthing like that.. because the admin commands change the server

modest maple
#

What

barren estuary
#

I will add this feature ^^

modest maple
#

No

#

Just get it to require the bare min perms

#

E.g

barren estuary
#

yeah but a normal member shouldn't change the welcome message or reactroles ..

viral spade
#

so you make a check for this in your code

modest maple
#

Just leave that to people with perms by checking

#

E.g kick and ban should require the kick and ban permission from a user to use

barren estuary
blissful scaffold
#

For example if your bot needs to ban people then give it the BAN_MEMBERS permission instead of ADMINISTRATOR

modest maple
#

Yh

#

There's no need to have an entire new role just to use it

#

And no need for a bot to have admin

#

Simple as

blissful scaffold
#

If the user that uses the command needs to be an admin then show a message that the user needs to be an admin, dont just say that the user is not allowed to do that

barren estuary
modest maple
#

The perms that discord would require

#

E.g

blissful scaffold
#

Say something like Sorry, you need to be an Admin to use this command instead of Sorry, I am not allowed to execute this command

modest maple
#

Welcome messages -> manage server

viral spade
#

@barren estuary then give it no permission and add them as you get errors because of it

#

test everything

blissful scaffold
#

Sorry, I am not allowed to execute this command also makes it look like the BOT needs the permission instead of the USER

barren estuary
#

and create a more readable error message

viral spade
#

usually you would allow anyone with MANAGE_SERVER permission to do so

barren estuary
#

alright.... I will overthink the permission system ^^

viral spade
#

you should simple use what discord offers you, dont make your own system

#

at least for starters

barren estuary
#

ok

#

I will do that..

#

And is there any way to get the bot set up.. back? I alway have to rewrite it after the bot has been declined

blissful scaffold
#

The most important things are

  • make it clear when the USER needs a role or permission
  • don't request admin permissions for your bot
  • show a clear message what permission your bot needs if it needs a permission that it doesn't have
barren estuary
#

โœ…

#

Thank you guys.. for your help ^^

tidal kindle
#

Yup kvetching

wicked pivot
#
if(message.content.startsWith(prefix + "voicetop")){
      let tri = Object.values(voicetime).sort(function(b,a){
        return a.voicetime - b.voicetime
      })
      let voicexp = tri.map(e => tri.indexOf(e) + 1 + ") " + message.guild.members.get(e.pseudo).user.tag + " - " + e.total + "milliseconde").slice(0,15).join("\n")
      let embed = new Discord.RichEmbed()
       .setTitle('Le top du serveur en terme de vocal !')
       .setColor('#dc143c')
       .setDescription(voicexp)
       return message.channel.send(embed)
    }``` can someone help me turn this into second minute and hour?
modest maple
#

Just do some maths

#

1000ms in a sec

#

60secs in a min

#

Boom

#

I think there is a module that turns ms into readable time

#

But I've forgotten

wicked pivot
#

haha yes I know ^^ 'but it is especially at the level of the formatting that I do not really know how to do it

#

ow this is of great interest to me

blissful scaffold
#

first you calculate how many hours, minutes and seconds it is
then you add those values to a string and you got your time

wicked pivot
#

I do not take the head suddenly I use the module "ms"

#

but there is a problem

earnest phoenix
#
client.on("message", (message) => {
if (message.content.startsWith("s!cv")) {
            if (!message.member.hasPermission('MANAGE_CHANNELS')) return message.reply("You Don't Have `MANAGE_CHANNELS` Premission ");
    let name = message.content.split(" ").slice(2).join(" ");
        if(!name) return message.reply ("**Write The Channel Name**");
        let args = message.content.split(" ").slice(1);
    message.guild.createChannel(args.join(' '), 'voice');
    message.channel.sendMessage('Voice Channel Created :white_check_mark:')
    
}
});```
#

when i write the command and put a name for the room

#

it just repeats write the channel name

wicked pivot
#
let voicexp = tri.map(e => tri.indexOf(e) + 1 + ") " + message.guild.members.get(e.pseudo).user.tag + " - " + e.ms(total)).slice(0,15).join("\n")```

```(node:2752) UnhandledPromiseRejectionWarning: ReferenceError: total is not defined```
#

cry

earnest phoenix
#

lol so what can i do now ?

sudden geyser
#

have you tried defining it

earnest phoenix
#

wdym

modest maple
#

Not u

earnest phoenix
#

k

wheat jolt
#
    var rows = await bot.db.query('SELECT * FROM staff_birthdays')
    if(!rows[0]) return msg.channel.send('***Nu am nicio zi de naศ™tere รฎnregistratฤƒ***')
    var monthNames = ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"]
    var description = await rows.map(async b => `${await bot.fetchUser(b.userID).toString()} **- ${b.day} ${monthNames[b.month - 1]}**`).join('\n')
    var embed = new RichEmbed()
        .setColor('000000')
        .setAuthor(msg.author.tag, msg.author.avatarURL)
        .setTitle('Zile de naศ™tere staff')
        .setDescription(description)
        .setFooter('ยฉ Fortnite Romรขnia', msg.guild.iconURL)
        .setTimestamp()
    msg.channel.send(embed)

http://pls-fuck.me/7jmCdzJ.png

#

hm?

modest maple
#

As for your thing, @earnest phoenix are you even making a VC

sudden geyser
#

I don't think you can await an array btw

#

and are you sure the error's coming from there

earnest phoenix
#

yes its a command that lets you create a voice chat

wheat jolt
#

@sudden geyser you're talking abt my error?

sudden geyser
#

yes

modest maple
#

@sudden geyser it's returning a promise

#

I needs to be awaited

sudden geyser
#

that's for each item

wheat jolt
#

wdym I await an array

sudden geyser
#

not the actual array

#

I'd believe it'd be something like Promise.all they're looking for

wheat jolt
#

I'll do with a for of loop i think

wicked pivot
#

when I don't put "ms ()" there is no error
@sudden geyser

sudden geyser
#

That's because total is not defined.

wicked pivot
#

yes end how can I define it knowing that this variable makes the list of nicknames with time go into vocal

#

ok that's settled

#

thank you x)

earnest phoenix
#

so can somebody help me now ?

sudden geyser
#

what input are you giving the command (aka what you sent)

blissful scaffold
#

@earnest phoenix does slice start at 0 or at 1?

sudden geyser
#

you're slicing it by two so it'd be the 2nd arg

earnest phoenix
#

so i should change the slices

#

i change the 2 to 1 and the 1 to 2

#

?

blissful scaffold
#

I think the first argument is slice(0)

sudden geyser
#

try slicing by one

earnest phoenix
#

how ?

blissful scaffold
#

instead of slice(2) do slice(1)

#

in programming languages you usually start counting at 0

sudden geyser
#

slicing by 0 would actually just not do anything if I remember correctly

earnest phoenix
#

so instead of 2 i do 1

#

and instead of 1 i do 0

sudden geyser
#

I think you're referring to indexing it

earnest phoenix
#

i will try

blissful scaffold
#

So if you got s!cv channel then split(" ").slice(0) would return s!cv and split(" ").slice(1) would return channel

earnest phoenix
#

i will test it now

blissful scaffold
wicked pivot
#
 let embed = new Discord.RichEmbed()
       .setTitle('Le top du serveur en terme de message et vocal !')
       .setColor('#dc143c')
       .addField("Classement des message", xppp, true)
       .addField("Classement des vocal", voicetime, true)```what ?
earnest phoenix
#

okay i just flipped the slices

#

i changed the slice(2) to slice(1) and the slice(1) to slice(2)

#

and it worked

#

but it doesnt create a channel

modest maple
#

I don't think guild.createchannel is valid

sudden geyser
#

Tony it means you passed an object instead of a plain string

earnest phoenix
#

but i tried it without

    let name = message.content.split(" ").slice(1).join(" ");
        if(!name) return message.reply ("**Write The Channel Name**");
#

and it worked

#

so guild.createchannel is not the problem

modest maple
#

You sure

sudden geyser
#

did it throw any error?

earnest phoenix
#

yeah

#

no

#

no errors

#

it just says that the channel is created

#

but i cant see the channel

sudden geyser
#

assuming by your code if it truly worked it'd be at the top of the channel list

earnest phoenix
#

yeah i know that

#

but

#

its not anywhere in the channels

#

wanna test it ?

wicked pivot
#

@sudden geyser I don't understand why it does this because I use the same variable for this command and its doesn't do this

uneven wyvern
#

How can u check if a Member has Premium in a guild?

#

@wicked pivot use await

earnest phoenix
#

@wicked pivot how did u get badges after name

prime cliff
#

oh client mods yikes

unique nimbus
#

^

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

blissful scaffold
#

DBL wont ban for it, but Discord itself might

uneven wyvern
#

How can u check if a Member has Premium in a guild? In js

quartz kindle
#

what premium?

#

nitro? booster?

uneven wyvern
#

nitro booster

quartz kindle
#

thats two different things

uneven wyvern
#

whatever but how can I check it?

blissful scaffold
#

I know in java there is Member.getPremiumTime()
Don't know what it is in js

#

it returns the time when the member boosted the server if it ever did

grim aspen
quartz kindle
#

discord.js v12 has member.premiumSince

#

but v11 doesnt

uneven wyvern
#

I'm on v12 so everything is fine

Would I just do if(member.premiumSince === true) //do something?

blissful scaffold
#

premiumSince returns a time, not true or false

quartz kindle
#

^

blissful scaffold
#

it might work with == but im not sure

quartz kindle
#

nope, it wont work with ==

#

but it will work like this if(member.premiumSince) { do something }

viral spade
#

I know i can tell the sharding manager how many shards to spawn. But can i also tell it exactly which shards to spawn? So i can start shard 1-5 on computer 1 and shard 6-10 on computer 2.

Is this possible?

quartz kindle
#

yes it is

#

are you using discord.js?

solemn fern
#

anyone use python 3?

#

I have a non bot issue right now and want to bounce some stuff around with you

modest maple
#

sure

#

@solemn fern

solemn fern
#

do you mind if I dm you?

#

I can post it here as well, but I figured I wouldn't clog it up here

modest maple
#

sure

wicked pivot
#
const discord = require('discord.js')
const fs = require('fs')
const voicetime = JSON.parse(fs.readFileSync("./data/voicecounter.json", "utf8"))
function write(){
  fs.writeFile("./data/voicecounter.json", JSON.stringify(voicetime), (err) => {
      if (err) console.log(err)
  })
}

module.exports = async (bot, oldMember, newMember) => {
    if(oldMember.user.bot) return;
    guild = oldMember.guild
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel

     if(oldUserChannel === undefined && newUserChannel !== undefined) {
      if(!voicetime[oldMember.user.id]) {
         voicetime[oldMember.user.id] = {
          lastLeft: 0,
          lastJoined: 0,
          total: 0,
          pseudo: oldMember.user.id
          }
      }

      voicetime[oldMember.user.id].lastJoined = Date.now();
}else if(oldUserChannel !== undefined && newUserChannel === undefined){
    voicetime[oldMember.user.id].lastLeft = Date.now();
    voicetime[oldMember.user.id].total += (voicetime[oldMember.user.id].lastLeft - voicetime[oldMember.user.id].lastJoined)
    write()
  }
}``` I have a problem I don't know the reason I have no error but when I do the thing associate with this event this to say I join a vocal then leave it a few seconds after all is written very well in the json but some second after returning to the original form
#

that is to say
{"363402633752477696":{"lastLeft":0,"lastJoined":0,"total":0,"pseudo":"363402633752477696"}}

sage bobcat
#

One message removed from a suspended account.

wicked pivot
#

because I don't need much

split hazel
#

In Sequelize, is there a way to log every single query, no matter if it actually executes, or errors during parsing

#

Sequelize errors that occur in parsing are absolutely useless when you have many tables

wicked pivot
#

this error is resolved now it came from me, but now the bot no longer calculates me this to say I can join and leave the vocal by staying 10 minutes the bot will add nothing to the json then there is no error

#

I correct myself, it marks everything I need in the json but when I order to display my "stats" it comes back as before

late hill
#

How are you displaying your stats

#

Also, your code doesn't rly seem to factor in that people can join and leave voicechannels while your bot is offline

prime cliff
#

You can't really factor that in unless you save it 001_NK_OwO

late hill
#

You can make sure that it doesn't throw errors

#

voicetime[oldMember.user.id] may not exist for those who joined while it was offline

#

meaning if they leave

#

You're trying to access properties that don't exist

wicked pivot
#

I understand very well but why I see the bot write in the json then after having made the command "stat" its resumes as it was before

late hill
#

How are you displaying your stats

#

You most likely use a cached version that's not updated

wicked pivot
#
if(message.content.startsWith(prefix + "stat")){

      if(!voicetime[message.author.id]){
        voicetime[message.author.id] = {
          lastLeft: 0,
          lastJoined: 0,
          total: 0,
          pseudo: message.author.id
          }
          save()
      }

        let user = message.author
        if (message.mentions.users.first()) user = message.mentions.users.first()
            let embed = new Discord.RichEmbed()
             .setTitle(`Les stat de ${user.username} en terme de message et vocal sur le serveur !`)
             .setDescription(`Les stats et top du serveur est rรฉinitialiser chaque semaines ne vous รฉtonner pas de ne avoir de messages oรน d'heure en vocal`)
             .addField('ร€ รฉcrit :', `${xp[message.author.id].xp} message sur le serveur !`, true)
             .addField('En vocal :', `${ms(voicetime[message.author.id].total, {long: true})} en vocal sur le serveur !`, true)
             .setColor(`#dc143c`)
             .setThumbnail(message.guild.iconURL)
             .setTimestamp()
             .setFooter(`demande de ${message.author.username}`, message.guild.iconURL)
             return message.channel.send(embed)
    }```
late hill
#

what's voicetime in this context

#

How did you define it

wicked pivot
#
const voicetime = JSON.parse(fs.readFileSync("./data/voicecounter.json", "utf8"))
function save(){
  fs.writeFile("./data/voicecounter.json", JSON.stringify(voicetime), (err) => {
      if (err) console.log(err)
  })
}```
late hill
#

that's probably executed once

#

You're reading the file once and then continue to use that data, while you're editing the data in other places with other variables

#

It won't magically update

wicked pivot
#

wait

#

before doing the event

{"363402633752477696":{"lastLeft":1578939696564,"lastJoined":1578939694781,"total":6706,"pseudo":"363402633752477696"},"610463356188622849":{"lastLeft":1578939726726,"lastJoined":1578939724670,"total":2056,"pseudo":"610463356188622849"}}```

after the event

```json
{"363402633752477696":{"lastLeft":1578943352667,"lastJoined":1578943349678,"total":52091,"pseudo":"363402633752477696"},"610463356188622849":{"lastLeft":1578939726726,"lastJoined":1578939724670,"total":2056,"pseudo":"610463356188622849"}}```

after the command "stat"

```json
{"363402633752477696":{"lastLeft":1578939696564,"lastJoined":1578939694781,"total":6706,"pseudo":"363402633752477696"},"610463356188622849":{"lastLeft":1578939726726,"lastJoined":1578939724670,"total":2056,"pseudo":"610463356188622849"}}```
late hill
#

Well yes

#

Because you're also calling save() when you check the stats

#

Which will overwrite the changes you've made because the voicetime variable in that file has never been updated

wicked pivot
#

so I had to define "voicetime" in the command?

late hill
#

You should read it just once and have all your voicetime variables be references to the same thing

#

You could simply use require() as require uses cache

#

You'd just const voicetime = require(jsonFilePath); wherever you need it

#

It'll be the same in all your files

#

(you'd still have to write when making changes, so that it can read the updated values again when your cache has been cleared)

wicked pivot
#

so would you advise me to change my way of defining "voicetime"?

late hill
#

Yes

wicked pivot
#

I read the file when the bot starts and I should make it read it only when I need it, ie when I do the stat command for example

#

ok i will try this

late hill
#

It'll only read the file once, any future require calls will just use the cached version

wicked pivot
#
const voicetime = require(jsonFilePath("./data/voicecounter.json", "utf8"))```this is good?
late hill
#

No

wicked pivot
#

why ?

late hill
#

You simply replace jsonFilePath with the path

wicked pivot
#

ow okay

#

sorry lol

#

any future call will simply require the cached version "" how do you do this?

#

(already it doesn't change the json it's a good thing)

late hill
#

In any file you need voicetime, require it the same way.

#

and yes

#

as said

#

(you'd still have to write when making changes, so that it can read the updated values again when your cache has been cleared)

#

You're purely updating the cached version if you're only editing the object from require

wicked pivot
#

I don't see how to do it x)

late hill
wicked pivot
#

I can quote you the moment or I use this json where even modifies it

#

sorry i use google translation it's a bit complicated x)

late hill
#
//FILE 1
const voicetime = require("./jsonFile");

//FILE 2
const voicetime = require("./jsonFile");

// Both voicetime variables share a reference to the json
// Changing voicetime in one file, will also make it change in the other
wicked pivot
#

So in all the files where there can be a modification of the values โ€‹โ€‹in the json I put this?

const voicetime = require("./data/voicecounter.json", "utf8")```
late hill
#

yes

#

doesn't have to be a modification

#

if you want to use it in any way

wicked pivot
#

OK I'll try, thank you for your perseverance x)

late hill
#

You don't need the "utf8"

wicked pivot
#

Error: Cannot find module './data/voicecounter.json'

late hill
#

make sure the path is right

#

if you're requiring it from a different file, the relative path might be different

wicked pivot
#
//const voicetime = JSON.parse(fs.readFileSync("./data/voicecounter.json", "utf8"))
const voicetime = require("./data/voicecounter.json")```both start from the same file
late hill
#

what

wicked pivot
#

both start from the same file however with the variable I use before finding it and not with the new

late hill
#

oh like that

#

yes

#

require uses a relative path

#

readFileSync doesn't

wicked pivot
#

ok thanks it works

pure gust
#

hey guys, could i get some assistance?

modest maple
#

say ur question dont ask2ask

pure gust
#

im starting to use embeds and i need help with it

#

yeh i was writing it xD

#

my issue is to add fields that are besides each other for example

Server Name - LOGO

Server Status Online Players
Online/Offline 12/64

#

and to get the offline/online status of a gameserver

modest maple
#

what lib?

mossy vine
#

inline

pure gust
#

wdym lib? and how would i do that cybernt

twin pendant
#

are you using discord.js, or discord.py, or something else

pure gust
#

discord.js

twin pendant
#

ok, so remove the ,true at the end of the .addField thing

pure gust
#

lolz i havent even got the true xD

mossy vine
#

doesnt he.. want to add that?

twin pendant
#

OH

pure gust
#

well yeh i guess to make it inline

#

like next to the other field

twin pendant
#

i thought you said they were inline and you didnt want them inline

#

well yea add the ,true then haha

pure gust
#

nah opposite xD

mossy vine
#

are you using RichEmbeds/MessageEmbeds or raw objects

pure gust
#

richembeds

mossy vine
#

then do what gorillaa said, add another argument to your .addField() which should be true

pure gust
#

yeh so what field would i write the true statement in?

#

ill send pic

twin pendant
#

like .addField(`title`, `content`,true)

mossy vine
#

whichever you want to make inline

pure gust
#

i want the online players to be to the right of the server status

mossy vine
#

then the second one

pure gust
#

that didnt work

#

it still appears below it on the output in the discord server

twin pendant
#

send what you changed it to

pure gust
twin pendant
#

try add it to both

pure gust
#

okay

grizzled raven
#

two fields need to be inline

pure gust
#

?

#

both worked

#

thanks, another question, any idea how to get the server status of a server ( fivem) or would i need to ask a js specific developer?

twin pendant
#

all good, and there might be an api for that

pure gust
#

wdym

twin pendant
#

an api is something that your bot would send a request to and get info

#

might work idk

pure gust
#

thanks dude

twin pendant
#

all good

#

guess i gotta return the favour from when i asked other people for help when i was a beginner

pure gust
#

yeh XDDD

#

im new to actually coding with a proper language

#

unlike the shit we use in school

twin pendant
#

mhm nice

pure gust
#

any idea how to make the text colour within the fields different?

#

coz the way it looks isnt the best

earnest phoenix
#

you can't

twin pendant
#

dont think you can normally unless you make it a code field

earnest phoenix
#

at best you can use code blocks