#development
1 messages ยท Page 767 of 1
It sends Not a valid add-inID for everything
why do you have an infinite loop?
also if the first entry is not true, it'll always send the error message. What elements does addOnsA feature?
should I make it so the loop stops when I is like the length of
at least make it limited by the array size
let addOns = args.slice(2).join(" ")
i = 0; i < addOnsA.length; i++
less than array length
because array length starts at 1, not 0
well, its 0 if the array is empty
'NoneType' object has no attribute 'create_ytdl_player' i do notunderstand
you're trying to do <null/undefined>.create_ytdl_player
Are you familiar with Python data types
I do not understand because it is connected to a channel when I am running the command
Try to reconnect
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
I did I even shut down the code and restarted the entire bot
shivaco I have tried reconnecting and even restarting everything and it still does not work
Did you reconnect to the vc through the bot code after restarting it
I reconnected it using the command
@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?
it doesnt matter
oh
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
you can get the bot member from message.guild.me
so message.guild.me.highestRole
gives you the highest role of your bot
ok
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
shivaco any other suggestions
'VoiceClient' object has no attribute 'create_ytdl_player' how can i fiz this
not many
it's a role, not a function.
what would I need to change now?
highestRole is already a role
just remove the entire code block
you can call directly highestRole.position
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
check if its bigger than 0
so keep if (role.position < 0){
so keep it? if the highest role position is 0 then yes?
if its 0 then it means its the highest
if its bigger than 0, it means its not the highest
so what would I do?
check if its bigger than 0
if (role.position > 0){ so this then?
yes
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
isnt the highest role 0? or are roles reversed in order?
0 is the lowest role
then what is the highest?
well then just do if(role.position === guild.roles.size-1)
ok
do >= if you have anxiety like me
yeah, message.guild
Well this bot will be in many servers not just one
just replace guild.roles.size with message.guild.roles.size
ok
I want the bot to check if Its role is the highest, if it isn't send the embed
oh yeah
ok
what is wrong ?
yeah just change the operator to <
yeah 2 people explaining how to compare numbers must be confusing
yea..
me writing .size -1 doesnt mean "remove message.guild.roles"
ok, lemme try it
it worked
Thank you guys for the help with the code and helping me learn something new
'VoiceClient' object has no attribute 'create_ytdl_player' how can i fix this
You are taking code from 0.16.4
it is 1.x.x now
I forgot what
create_ytdl_player doesnt exist anymore
so how can i fix it
read
create_ffmpeg_player/create_stream_player/create_ytdl_player have all been removed.
The goal is to create AudioSource instead.
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()
Because it's all outdated c+p code
did you take it from here
it looks nearly identical
this is fun, working on 3 different layers of an app that has to be done by thursday
as I said before we don't use create_ytdl_player anymore
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
it looks nice at least
That's pretty clean cry
We saw the error
Out of context without Peter's message it looks like cry is being told not to copy paste code
ikrrr i'm so proud of myself for doing clean design
No need to keep sending it
lol shivaco
Xd
it's surprisingly not that hard
electron docs are really good
i've never seen cleaner docs
You are talking to someone who struggled with making loops in python for a while
F
yes
I mean I am smarter now
and just made playlists work for music
but yes
I will see later
I've spent a fair bit of time today compiling python scripts xD
e-education
modernization of teaching methods
yeah
it's for a comp, basically allows hosting classes online, keeping track of exams, homework and your school timetable
but I can't CSS for crap and make good designs
the beauty of the slavic languages, know one and you automatically know many
this
its serbian/croatian i think
croatian yeah
Russian (ััััะบะธะน ัะทัะบ, tr. rรบssky yazรฝk) is an East Slavic language
Wikipedia N.1
They're kinda similar in pronunciation and spelling
Yup
ye
i know slovenian, so croatian is not hard to understand
but if someone speaks croatian to me i wont understand shit
lmao
just your standard British boi passing by
I mean I am both Russian and British
but I can't speak/understand Russian for crap
Need to learn
Node.js, // discord.js, I need help
2 of my bot commands aren't loading .-.
idk what to do about that
send message, clearxp, addxp, trainingon, trainingover commands
oh and my warnings command as well
Are you sure you're actually registering them?
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'```
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
how can i fix it
i can not find it
we already explained you a couple times today what a NoneType object is, that object does not exist
I get object does not exist but how do I fix it
the screenshot you just send seems to have no relation to the code you showed
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()```
https://discordapp.com/channels/264445053596991498/272764566411149314/666048951283089448
read that and the links before and after that message
create_ffmpeg_player/create_stream_player/create_ytdl_player have all been removed
I have read everything yet I have not been able to figure out how to fix it cuz I replaced it was ffmpeg
Then you also saw this:
The goal is to create AudioSource instead.
and read the documentation links that are posted there
Yes
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
The first thing in the voice changes document is this:
Connection is done through VoiceChannel.connect() instead of Client.join_voice_channel.
I don't want that I don't want it to join using this command
This code snippet should be all you need to get an idea how to do it
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
This is more complicated and has taken longer than it should have I'm just going to pay someone to do it
Jesus suffering fuck
Hey Shivaco, are you a python dev and do you want to make some money? 
Yes I am and probably
Culan is looking for a dev
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)
The bot this would be in is public and will be on the list when approved
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๐
tip, use different bots for debugging/developing and an actual production build
I always test with a different bot
๐คฆ๐ปโโ๏ธ that is actually a good tip but never crossed my mind ๐คท๐ปโโ๏ธ
Lol
that way my main bot is only offline for a few seconds while updating to a new version
@earnest phoenix test on prod 
I will do that ๐๐ thanks again
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
I always use process.env.BOT_TOKEN anyways ๐
Always have
Token is defined via variables outside the bots code
same, my bot is my code
I do make open source ones though so ๐คท๐ปโโ๏ธ if anything .gitignore is useful
i also store the code on a git server that i own
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
(it's just a simple gitlab docker container that runs on my nas)
if you know how docker works then its not hard at all
you do need more than 2GB of ram because it loves ram
Yeah I should be good there
I am running Synology Gitlab on my Synology NAS, I don't know how easy other gitlab docker containers are
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)
Like this but that supports the full description of the commit
so that it posts a message on your server every time you commit something?
interesting
yes
Yeah it's been a pain so far due to the fact that I'm not the best with webhooks yet but ๐คท๐ปโโ๏ธ
I know thats not hard to set up I meant I want my own
and you can find a simple guide on google
Custom one
its the same
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
Hahah so it was a good mistake
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
Interesting
I have done something similar but it was with FiveM if you know what that is
we use proboards and they allow you to create plugins
Hmm nice so setup was pretty simple?
so i created a simple JS plugin that sends simple JSON files to the bot every time someone uses the forum
Interesting
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
So then they can go and check the post yeah that seems pretty useful
yeah, and i learned to love AJAX calls ๐
Lol
or whatever its called, im not a js dev
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
I think I used LUA once in minecraft for a computer mod, it was an interesting language
It is interesting for sure lol
but it's 6 years ago or so and i forgot 90% of it
I still actively work with it as i still make scripts for FiveM and post them on their modding/public script forums
I will be leaving now, it's close to 4am here ^^
Ahh good night ๐ thanks again for your help
no problem, good luck with your bots
how do you get the maximum cpu for the process
@earnest phoenix what language?
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")
๐
Lol I sent that cause you beat me to it
But yeah makes sense ๐ nitro = instant IQ boost
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
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
yeah
if you can maybe put the entire app into a class then just make the db a property
readonly*
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.
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
How to host 24/7 free a discord bot without glitch or heroku or self host
then too bad 
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
Good but what to do after 2 years lol
pay
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
listen to the member leave event and delete its xp
yes i know the event "guildMemberRemove" of course but i don't know how to delete his xp
I would like to use a SQL database but I don't know how it works too x)
same
but how are we supposed to help you without knowing what kind of database u r using?
json
JSON is not a database
but it works as one
you can use delete thing like ```js
delete JSON[โ123โ]
json should never be used as a database
I used it before and i got issues with it saving so I switched to MongoDB
what else can i use? end what do you advise me?
okay i will watch this
you can use the Mongoose or MongoDB driver for MongoDB if you are using JavaScript
I'm using JavaScript so I'm going to watch this
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()
}
})```
if you want simple and efficient, go with sqlite (requires learning sql)
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
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
- load the file once at bot start
- keep the entire file in memory as an object
- only write to file when changes occur
- dont write directly to file, write to a temporary file first and then rename it
- keep backups
load the file once at bot start "
How?
are you using javascript?
let database = JSON.parse(fs.readFileSync(your file))
oww okay it's already done ^^ '
const xp = JSON.parse(fs.readFileSync("./exp.json", "utf8"))```
alright, now all your read operations should be done in memory, ie: always use xp[something] and never use fs.readfile again
this is what i do ^^
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
because there is a risk of error I imagine?
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
it's taken note
when i try running my join command i get
**Error while joining** FFMPEG not found
however, i have downloaded ffmpeg
and yeah, to answer your original question, you can easily delete an entry by doing delete xp[something]
and then saving the file
already done that
did you install it in node as well?
yes
did you rebuild the relevant audio packages?
yes yes I know but I would like to check if the user has XP and if he deleted it
let me check
to earn XP you have to write on the server in questions do you agree with me?
rebuilt them successfully, still getting the error
did you add ffmpeg to PATH?
did you restart your system after adding it?
yes Tony
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
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
{"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)
}```
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
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
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)...
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
dont put +1 each second
record a timestamp for when they join and when they leave, and calculate the difference
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"
}```
no
its too complicated and prone to errors
you should only save one type of data
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)
.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
someone can help me ?
how can i chnage from triangle to circle
canvas?
I don't know canvas but maybe https://www.w3schools.com/tags/canvas_arc.asp will help
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?
Emoji wont exist or its uncached.
!owowhatsthis
Animated emojis look like this
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?
I heard someone else here say you cant, but idk how true that is
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i 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
One message removed from a suspended account.
^
no hard figures on that then? i'd be curious to know
One message removed from a suspended account.
One message removed from a suspended account.
last i checked a mid range rpi struggles to even run a desktop environment smoothly?
someone can help me ?
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.
It really depends on what you expect the bot to do
One message removed from a suspended account.
yeah this isnt something i plan to try @sage bobcat i was curious
One message removed from a suspended account.
One message removed from a suspended account.
i have something rpi-like with 4 network ports on it at home, but i use it as my router
One message removed from a suspended account.
One message removed from a suspended account.
ive just passed 750 servers
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
One message removed from a suspended account.
I would like to make a system that counts the number of times spent in a vocal
im currently using a dedicated server and wouldnt 'downgrade' to an rpi, it would be silly for me to do so
problem I do not really know how to do
im currently battering the dedi, teaching my bot half of project gutenberg
One message removed from a suspended account.
if a dedicated server is already struggling then don't run it on a RPI ๐
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
My server got a heartbeat thanks to the bot I'm running on it
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
the problem with discord is that they hammer your server with presence updates that most bots dont even use
my traffic only shows the spikes when I send the backups to my local machine every night
it overpowers all other traffic
you can turn off guild subscriptions but it hamstrings your bot
remove the presence updates and your cpu usage drops by 80% and your bandwidth usage drops by 90%
part of that problem is bots sending presence updates every 30 seconds
yeah i made a framework to work around the issues of disabling guild subscriptions, as well as cache control
when you have a server of 20,000 bots...
I guess my bot is one of the few that uses the presence updates
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
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
yeah, i just dropped presences altogether
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
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
the only unfixable problem with disabling subscriptions is that you no longer receive member joins, which is a deal breaker for many bots
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
yeah, my vps was using 500gb per month lol
heres what im looking at cpu wise
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
yeah c++ is really efficient
just much harder to work with
and im too lazy to learn it
lul
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?
yup
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
ah yes, i saw when you posted about it before
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
yeah
but like, if you're already using prepared statements, you dont really need escape strings as well
yeah my code doesnt use proper prepared statements
ah
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
very relatable lmao
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
my bot is quickly approaching the 2500 guilds threshold and its still running on json, old framework version, and not sharded
eek
and i've been delaying the rework in forever
im sharding with 10 shards on 750 servers
During my study I had to work with C++ for 1 semester and decided to stay with something simpler like Java
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
hahah
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
the framework doesnt support that?
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
I think Discord4J will implement it in the next major release
But I usually hate major releases because they break everything
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
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"
The problem is also that without code breaking changes it is sometimes really hard to make stuff better
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
dealing with segfaults is nightmare
yeah especially if its not in your own code lol
yeah lmao
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
lmao
One message removed from a suspended account.
I worked with Ruby for a year for a work related thing
But it has been a few years ago
One message removed from a suspended account.
This might help
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
yes
One message removed from a suspended account.
that guide might be of more use than me
One message removed from a suspended account.
One message removed from a suspended account.
I always try to forget any language I learn as quickly as possible after I stop using it
One message removed from a suspended account.
DVSAEZI Today at 14:29
do you remember how to do http requests
One message removed from a suspended account.
One message removed from a suspended account.
and POST
you get an error when trying it?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
try it
We didn't work much with http requests
and the times we did I used google a lot ๐
google is amazing
Who even still uses ruby
idk, not me
The only reason why people ever used Ruby was with Ruby on Rails 5 years ago
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..
contact the mod to resolve it
there are people who have no idea what even roles are
yeah but why would I call this command category admin commands
there are users who have no idea what roles are and what admin means
anyway, check who declined your bot, and dm them to resolve it
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
yeah you are right
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!
@modest maple you can remove the admin permission from the bot. but than there aren't all commands available
@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
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
and yeah, don't use the admin permission for public bots
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
than the server has to forgive roles called BotController or somthing like that.. because the admin commands change the server
What
I will add this feature ^^
yeah but a normal member shouldn't change the welcome message or reactroles ..
so you make a check for this in your code
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
for example the messagecommand
For example if your bot needs to ban people then give it the BAN_MEMBERS permission instead of ADMINISTRATOR
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
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
no idea which permission should be allowed to execute such commands
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
Welcome messages -> manage server
@barren estuary then give it no permission and add them as you get errors because of it
test everything
Sorry, I am not allowed to execute this command also makes it look like the BOT needs the permission instead of the USER
ok I will add a line below.. where the permission will stand ^^
and create a more readable error message
usually you would allow anyone with MANAGE_SERVER permission to do so
alright.... I will overthink the permission system ^^
you should simple use what discord offers you, dont make your own system
at least for starters
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
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
Yup kvetching
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?
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
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
first you calculate how many hours, minutes and seconds it is
then you add those values to a string and you got your time
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
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
lol so what can i do now ?
have you tried defining it
wdym
Not u
k
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)
hm?
As for your thing, @earnest phoenix are you even making a VC
I don't think you can await an array btw
and are you sure the error's coming from there
yes its a command that lets you create a voice chat
@sudden geyser you're talking abt my error?
yes
that's for each item
wdym I await an array
not the actual array
I'd believe it'd be something like Promise.all they're looking for
I'll do with a for of loop i think
when I don't put "ms ()" there is no error
@sudden geyser
That's because total is not defined.
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)
so can somebody help me now ?
what input are you giving the command (aka what you sent)
@earnest phoenix does slice start at 0 or at 1?
you're slicing it by two so it'd be the 2nd arg
I think the first argument is slice(0)
try slicing by one
how ?
instead of slice(2) do slice(1)
in programming languages you usually start counting at 0
slicing by 0 would actually just not do anything if I remember correctly
I think you're referring to indexing it
i will try
So if you got s!cv channel then split(" ").slice(0) would return s!cv and split(" ").slice(1) would return channel
i will test it now
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 ?
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
I don't think guild.createchannel is valid
Tony it means you passed an object instead of a plain string
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
You sure
did it throw any error?
yeah
no
no errors
it just says that the channel is created
but i cant see the channel
assuming by your code if it truly worked it'd be at the top of the channel list
@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
@wicked pivot how did u get badges after name
^
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
DBL wont ban for it, but Discord itself might
How can u check if a Member has Premium in a guild? In js
nitro booster
thats two different things
whatever but how can I check it?
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
I'm on v12 so everything is fine
Would I just do if(member.premiumSince === true) //do something?
premiumSince returns a time, not true or false
^
it might work with == but im not sure
nope, it wont work with ==
but it will work like this if(member.premiumSince) { do something }
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?
anyone use python 3?
I have a non bot issue right now and want to bounce some stuff around with you
do you mind if I dm you?
I can post it here as well, but I figured I wouldn't clog it up here
sure
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"}}
One message removed from a suspended account.
because I don't need much
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
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
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
You can't really factor that in unless you save it 
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
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
How are you displaying your stats
You most likely use a cached version that's not updated
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)
}```
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)
})
}```
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
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"}}```
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
so I had to define "voicetime" in the command?
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)
so would you advise me to change my way of defining "voicetime"?
Yes
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
It'll only read the file once, any future require calls will just use the cached version
const voicetime = require(jsonFilePath("./data/voicecounter.json", "utf8"))```this is good?
No
why ?
You simply replace jsonFilePath with the path
ow okay
sorry lol
it worked once
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)
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
I don't see how to do it x)

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)
//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

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")```
OK I'll try, thank you for your perseverance x)
You don't need the "utf8"
Error: Cannot find module './data/voicecounter.json'
make sure the path is right

if you're requiring it from a different file, the relative path might be different
//const voicetime = JSON.parse(fs.readFileSync("./data/voicecounter.json", "utf8"))
const voicetime = require("./data/voicecounter.json")```both start from the same file
what
both start from the same file however with the variable I use before finding it and not with the new
ok thanks it works
hey guys, could i get some assistance?
say ur question dont ask2ask
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
what lib?
inline
wdym lib? and how would i do that cybernt
are you using discord.js, or discord.py, or something else
discord.js
ok, so remove the ,true at the end of the .addField thing
lolz i havent even got the true xD
doesnt he.. want to add that?
OH
i thought you said they were inline and you didnt want them inline
well yea add the ,true then haha
nah opposite xD
are you using RichEmbeds/MessageEmbeds or raw objects
richembeds
then do what gorillaa said, add another argument to your .addField() which should be true
like .addField(`title`, `content`,true)
whichever you want to make inline
i want the online players to be to the right of the server status
then the second one
send what you changed it to
try add it to both
okay
two fields need to be inline
?
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?
all good, and there might be an api for that
wdym
an api is something that your bot would send a request to and get info
https://www.npmjs.com/package/fivem-api i googled fivem api and found this
might work idk
thanks dude
all good
guess i gotta return the favour from when i asked other people for help when i was a beginner
yeh XDDD
im new to actually coding with a proper language
unlike the shit we use in school
mhm nice
any idea how to make the text colour within the fields different?
coz the way it looks isnt the best
you can't
dont think you can normally unless you make it a code field
at best you can use code blocks



