#development
1 messages · Page 559 of 1
Jesus, sharding is actually fairly simple yet annoying af. I remember those days when I was fucking clueless to sharding 😂
i havent sharded yet actually
How many guilds you at?
~560
You could say that I "shard" but it only spawns 1 instance, so it doesnt actually make a difference
@oak sentinel
ooo
I just dont wanna deal with it later tbh
It's certified too lmao
I just dont think his bot reaches a high amount of people do to it's nature and uses
guilds*
higher*
I mean 560 is good 
The way I worded that made it sound like I was putting your bot down mb
lmao nah
its better this way actually, because its code is a damn mess, and its not compatible with sharding
so i have more time before i need to refactor it
im still using a json database lmao
thats my fear that when I shard it will just break, but it shouldnt because all of the dbs are connected. but if it does idk what I'll do 
you can create another bot account to test it
or you can run it in the same bot account but in a different folder/process
and rename all your commands
i did this a few times
I have a bot that just runs a bunch of processes that I test on
Its not efficient at all
but I dont feel like making a new bot account for every test on other bots

rethink is the best for sharding bc of pools
but i just added sharding and hoped it'd work
lmao
also rethink is realtime
i think having a database server for a discord bot is overkill, unless you're on hundreds of thousands of guilds
hey again,
i just added sharding (discordjs) by simply put the bot file into the shardmanager module. my bot should make 2 shards and is on 2 servers. Now it is working, two instances are being made, but they seem to share their servers, everything i do gets triggered twice. you know what could be the problem?
Thnaks you it works now. i think.
Well they'll be on the same shard
either way
Shards are assigned to guilds like this (guild_id >> 22) % num_shards == shard_id
where is the serversize info in the shardingmanager object? cant find it
ye, or the total server count on all shards. just need it for sending serverstats
You'll need to broadcast eval to do that
afaik you have to add up the total amount on each shard individually
when sharding it seems easy to send a message to a certain channel, that is not on the same shard. simply let all of the other shards look and send if found. but what about sending msges to certain users? if some are on multiple shards, then they get multiple times the message?
DMs always go through shard 0
hmm how does that help me? i want to send a dm message to a specific shard-extern user with userid, from within another shard
all dms are always on shard 0, no exceptions
and sending a message in a specific shard is not an issue if both shards are from the same process, that usually happens if you are using lib's auto sharding
if you want cross-shard scripting, you need broadcastEval
ie: to send dm > broadcastEval > send message if shard.id === 0
it will be broadcasted to all shards but only executed on shard 0
How would I get the Message author in python rewrite
@quartz kindle ok nice but does shard 0 cache all users from all shards?
I am getting Undefined Variable 'Message'
not really
have you checked the rewrite docs?
so if i send a message like you said to shard 0, which does a bot.users.get(id).send(msg), it will always be able to retireve that user and send that message, even if this user is not on a server of shard 0?
i think you can broadcast the user object
like broadcast message.author.send("message")
im not sure tho
let me see if i find an example
shard 0 is not guaranteed to have the user cached
what you can do
is fetch the user by id
and then send a DM
i cant broadcast the user object. all i have is a userid integer in some shard
yes
you can fetch that
there should be a method in the client
to get the member object from discord
then you can send a DM
or, if d.js exposes raw access to the REST api, you can just send the dm with the user id
i remember seeing an example of sending the user object to the broadcast together with the message, but yeah you can use .fetch and then dm
you mean there should be method to retrieve the shard-extern userobject inside the shard with the client object?
oke gonna check that thanks!
that sharding business is nasty
that only happens because the lib requires an user object to dm
you could do just java catnip.rest().user().createDM("userid") .thenCompose(dm -> dm.sendMessage("hello world"))
if the lib exposes raw rest access
<imagine that being in $YOUR_LANG>
pretty sure eris exposes a bit of the rest api right @inner jewel?
i dont think d.js does
that's probably GET /users/:id
d.js = macbook confirmed
pretty sure djs exposes that one too
d.js's .fetchUser() uses the rest api if a user is not cached
fetchUser(id, cache = true) {
if (this.users.has(id)) return Promise.resolve(this.users.get(id));
return this.rest.methods.getUser(id, cache);
}```
ew stable
Ah ok
message being whatever you named incoming messages
Wdym?
whatever the message object is defined as
notamessage.author
})```
@amber fractal This is discord.py not js
if you do (self,shit)
wait
it will be shit.author
Ah ok
Still basically the same
I would need to make a onn message event
yes
I was meaning to do that last night and totally forgot about it
someone told me I needed one last night
oof
Those messages sent out of order btw
@quartz kindle Is that image you sent in a @client.event() ?
let sentArray = await bot.shard.broadcastEval(`
...
}
is there an easier way to access the client ('bot') object than passing it down functions from the initial 'message' trigger
@quartz kindle anyway to get that cached users with eval?
client.fetchUser(id).then(u => u.send(...))
ah i thought i should send the dm through shard 0?
no need to
ok nice
all messages are sent via REST
which has no concept of shards
DMs are received on shard 0
@viral spade message.client
i see. so i would have always sent that broadcast to itself?
@fluid basin thnaks! i was hoping for exactly something like that
no need to broadcast anything
no just saying if i had broadcasted it to shard 0 to send the dm it would have always broadcasted only to itself
whatever thanks very much
well not sure if using client would miss out on any custom variables you added to bot
uhhh
you seem to be misunderstanding
DMs being received on shard 0 means that only shard 0 receives the message events for dms
if you want the safest method, in your onmessage handler just add message.bot = bot; and use message.bot in the module
d.js already has message.client
hmm I wondering if like custom arguments would get passed
iirc it does I think
like bot.asgdhdhebidnei = "lol";
yes if you meant this my custom functions, am too lazy to use something else when i can do this
@inner jewel hmm i wanted to send every dm from shard0. so when another shard receives a dm, i wanted to broadcast it to shard0, who then sends it. As every dm gets received by shard0 anyway, it would have only broadvasted to iteself, no?
there isn't any concept of shards when sending
you just say "send message to channel <id>"
ya it should be user
no
you always send messages to channels
a dm is just a type of channel
djs doesn't expose this
but there are two requests when sending a dm
first to create the channel (which just returns the existing channel id if already created), then to send the message
ok nice. thansk very muh
do i have a possibility inside a shard to get info what shard i am?
how would I get the current shard's id in discord.py?
oh wow, we have a similar question

whats the difference between using classes and using just pure javascript without class or super or constructor thingies
one you have classes the other you don't
whats the profit of having classes
i havent tried using classes yet, im still practicing using prototypes
i'll try them on my next project
fp
do u think using classes would decrease the memory usage
the difference won't be noticeable
depending on what you have now, it might increase or decrease
but won't change much
i read that classes translate to prototypes and basically is the same, just different syntax
classes arent prototypes
afaik, everything in js is prototypes, so yeah, classes get internally translated to prototypes
@earnest phoenix logChannel is null (ie: channel doesnt exist)
then your code is wrong
someone know how to create a class per server ? in website
Because he show only one server
blblblblbl
ping me
with a loop
owh
@inner jewel i'm lost
Yu
how can you make the bot send a message when it joins a guild?
Your librarys docs probably explain this
Yes, there is an event for it
@silver lintel
//joined a server client.on("guildCreate", guild => { console.log("Joined a new guild: " + guild.name);
This is return console.log
So you can send a message to the server owner
message.guild.owner.send("")
don't do that
https://pastebin.com/083c4xvW Fixed all errors but now my bot wont reply with the message
Could someone help me plz
const discord = require('discord.js')
class AFKCommand extends commando.Command
{
constructor(client)
{
super(client,{
name: 'afk',
group: 'status',
memberName: 'afk',
description: 'Adds AFK to your nickname, so others know you are AFK!'
});
}
async run(message, args)
{
message.member.setNickname(`[AFK] ${message.author.username}`)
}
}
module.exports = AFKCommand;
console.log('AFK command is online')``` help it isnt working?
@silver lintel always send the lib and version, and the error
I keep getting this error and not sure how to fix it
TypeError: Cannot read property 'command' of undefined
if(err) console.error(err); //error if failed reading commands
var jsfiles = files.filter(f => f.split('.').pop() === 'js'); //Checks that it is .js
if (jsfiles.length <=0) {return console.log('No commands found...')}
else { console.log(jsfiles.length + ' commands found.') }
jsfiles.forEach((f, i) => {
var cmds = require(`./commands/${f}`);
console.log(`Command ${f} loading...`);
bot.commands.set(cmds.config.command, cmds);
})
} )```
@earnest phoenix What do your command files look like
I don't know what bot.commands.set would do but like
From the error it seems that cmds.config doesn't exist
@silver lintel Because channels don't have a guild property
In discord.js there are channels and guildChannels
so what do i do?
shouldn't the channel object be of the appropriate channel type and Channel object is just a basic base for the other types to extend on
at least when getting them from client.channels they should have the correct type
i dont think thats how it works
´.kick()´ returns Promise<GuildMember>
it doesnt return a message
just reuse the previous message object
so what should I add?
just dont replace the message object
message //message object
...kick().then(message => { // message object replaced by a guildMember
// message here is a guild member, not a message
});```
is there anyone can help me for my problem on pycharm
Explain the problem, then we might be able to help. 🙂
ok, main problem is my pip version is 10.0.1 but for download another module i should upgrade my pip to latest version however for upgrade i need latest pip version
so as you can understand it is look like something impossible
That isn't a pycharm problem.
yes but cmd says C:\Users\MİHROŞ>python -m pip install --upgrade pip
'python' is not recognized as an internal or external command,
operable program or batch file.
If it doesn't work check out this page:
https://datatofish.com/upgrade-pip/
You need to just execute this if that error occurs:
-m pip install --upgrade pip
@ruby talon firstly thank you vry much its look like i solved pip version but now new problem occured and this time i totally dont get it
it says
DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip_internal\cli\base_command.py", line 176, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip_internal\commands\install.py", line 315, in run
resolver.resolve(requirement_set)
File "C:\Python34\lib\site-packages\pip_internal\resolve.py", line 131, in resolve
self._resolve_one(requirement_set, req)
File "C:\Python34\lib\site-packages\pip_internal\resolve.py", line 297, in _resolve_one
dist = abstract_dist.dist()
File "C:\Python34\lib\site-packages\pip_internal\operations\prepare.py", line 90, in dist
self.req.source_dir))[0]
IndexError: list index out of range
it looks like i have to upgrade my python
read 1st line
?
3.6 is fine, honestly
my bad
Hey i got a tricky question today. i hope i can articulate it well.
in my app.js/index.js (d.js) i spawn 5 ShardManagers (= 5 Discord Bots, each may be in different servers). When a user types a certain command in any of those (on 'message') i need to take one of the ShardManagers that a) has a shard that is on that server and b) is not already busy in that specific server. Then ofc mark it as busy for that server, until its job in that server is done. When such a message event occurs, multiple bots are very likely to "compete" at the same time to do the job, but only one must succeed.
- How do i access the 5 Shardmanagerobjects in the shards on'message' trigger function? Over some proccess (process.shardmanagers = []) wide variable that i create in app.js maybe?
- What datastructure can i take for the "busy list", as it needs to be thread save. When using mysql i can "INSERT IGNORE (serverid,botid)" and only on success i execute the server intern work. Other bots firing the Insert "at the same time" will get an error and i can be sure only one succeeded i think. However doing this in persistent memory is not necessary because the list is small and a job takes only a few seconds. Is there a thread save way of doing this in a processwide in-memory variable or database?

Shards only handle specific servers, no server would have multiple shards anyways
ye i know
wow thats a big oof
Then why did you say that multiple bots would "compete"?
yes a server has multiple shards, because they add multiple bots
Wait
they have multiple shards within app.js, not withing one shardmanager
Wot?
one server can be in multiple shardMANAGERS

The real question is why do you need five different bot accounts with five different tokens in a single NodeJS process 
because the job is a voice channel activity and a bot can be in only one voicechannel at the same time per server. when two people from the same server trigger the command, i want to let bot1 join voicechannel for user1 and bot2 to join the other channel for user2
i said its a tricky question^^
@ruby talon there is a problem
By the way, about the 2/, if I understand well, you want to use MySQL to create a TODO-list of things your bots must do ?
(Like a queue)
no
py charm doesn't read python 3.7 @ruby talon
it is a busy-list. when user triggers a command the node process should look for a bot that is not already busy in that server
and send it to that server to do the job, meanwhile add it to the busy list so it gets not send again while its doing its job
Queue is not possible because the job has to be done instant or not at all, if no bot is available for that server, all are busy
so in my pycharm i have got new problem (not surprisng) it says : error: [WinError 5] Access denied: 'c:\users\mi\u0307hroş'
Basically it has no access
Kinda what the error said tho 
thank you but problems ar not ending
i am getting crazy
since 2 weeks i am trying to figure this out
now it says ModuleNotFoundError: No module named 'setuptools'
but these are setup tools
they have to be there
now i will install them manual from cmd
at least ill try
by the way i dont know anything abou programing or writng code
i was trying to learn something bu these problems occured
and i coulnt make it
can anyone help me
@daring flume ur trying to import a file that python does not find.
This might be because the file is not in a package, its not in the library folder thing, maybe wrong name
but i am just hitting the "Install packaging tools" button
i guess i am trying to install pip and setuptools modules
pycharm
https://medium.com/@GalarnykMichael/setting-up-pycharm-with-anaconda-plus-installing-packages-windows-mac-db2b158bd8c
This might help you further.
Since I don't use PyCharm as my main editor I don't know the 'ins' and 'outs'.
@viral spade if i understood correctly,you're trying to manage multiple bots like a "pool", correct? if so, there are several ways of achieving this:
- simply have each bot use a different prefix and let the user decide which bot goes on which channel. this is the most commonly used method
- you would need one bot dedicated to "listening" to commands, keep a list of which bot is assigned where, and order another bot to do the job, either by creating an internal api, using a discord dm, or by setting up some form of IPC
- you can give each bot a certain "priority" and check if a bot with a higher priority is busy or not, and only execute if none of the bots with a higher priority are available. you can keep track of busy statuses in a shared real-time database
just a few examples
@quartz kindle thanks! yes i also thought about each option already.
- is not user friendly enough for me.
- seems unnecessary complicated and it would be nice to have each bot an "equal", this way it doesnt matter which invitelink the user uses and it doesnt depend on 2 invites ( 1 listener and 1 executer to be functioning)
- is my way to go and best, dont you think? but i dont really need a priority, i just ned any (server-specific-)ready bot. its the shared real-time database i was talking about in my question when asking for a proper datastructure that ensures that if two bot fire an insert command at the same time, only one succeeds and there is no error or race conditions. Is there an in-memory option for this? can i store in in my app.js in a process wide variable and access it from the shard intern trigger functions?
@quartz kindle bots can't DM each other
oh lul
they used to be able to
but get 2 broken bots dming each other in a loop forever
and you can imagine why it's not allowed anymore
@viral spade redis is pretty much the best in-memory database solution, and it has tools to check for modifications and abort writes if the value changes in the middle of an operation
so you could do something based on race-conditions: both bots attempt to change a single value, whichever one succeeds continues the execution, while the other interrupts
what about the array of bots? can i do it processwide in my app.js file and accesss it in my shards trigger functions later?
if you use external sharding, no
what do i use?^^
i know globals are not shared, but proccess values should be ok no?
i believe shardmanager is external sharding
no
no memory is shared
each process is completely isolated
no variables can be accessed from another process
but from parentprocess maybe?
no
you can use redis for inter-process variable sharing
there's no way. period.
if you're not sharing complex objects
but i cant use redis for saving the shardManager bot object??
no
i believe those are child processes
the proccess.env test seems to be accessible anywhere
they are all part of the same process
it's being read by each process
so i have this a s proper shared memory?
so its just copied on creation?
im not sure about the details, but i believe node's child process is still part of the main process as far as memory usage goes
but you can't share any data in memory
unless you decide to play with /dev/shm or whatever
but then you get a ton of new issues to deal with
and have the fun of having to deal with thread safety yourself
child_process.fork(): spawns a new Node.js process and invokes a specified module with an IPC communication channel established that allows sending messages between parent and child.```
is that what the shard manager uses?
@inner jewel
okey so you think i should take some ipc nodejs module for that? then i can access client objects accross clients?
okey, maybe some webhook?^^
why exactly do you need to access the client object in another process?
just send a message to it
could even use eg redis pubsub
send("bot-1-shard-1", {someData: "goes here"}) or something like that
ok that redis pubsub seems nice.
how about this way now:
When a user sends a command, the receiving shard releases a pubsub to all shards(accross bots,including itself ) "hey do x in server y (from command messageid z)".
All shards will now look: do i have that server on me? and if yes try to add its own botid,serverid,cmdMsgid to the database. As i'd make [botid,serverid] aswell as [cmdMsgId] unique keys i can be sure that if the shard succeeds inserting it 1. has no other job on the same server atm (bc [botid,serverid] is unique) 2. no other shard has taken the job already (bc [cmdMsgId] is unique).
All other shards will fail as cmdMsgId is then already in the db.
The succeeding shard will then perform its operation and afterwards delete the inserted entry again from the db.
could it work like that?
yes, you can use the message id as the unique key
you dont even need to use redis's watch or anything like that, you can just use SETNX - Only set the key if it does not already exist.
i guess i get a promise/callback which will only resolve in one of the shards then. However i was just reading it seems difficult to have composite keys in redis, thats a problem.
redis responds with 0 or 1 if the operation succeeded or not
what do you mean composite keys?
[botid,serverid]
they should be a key but only together. [botid,serverid2] is a different key
as every bot can be in one voicechannel per server only
yeah but if you use botid as a key, all bots will execute, because all keys will be different
no because only one bot get the [cmdMsgId] unique insert
you should use messageid as a key, that way only 1 bot can respond to any given command
redis is a key->value store
thats the problem
what exactly do you need?
tahts why i said it seems to be difficult, not impossible
i need two unique keys, one of them composite
redis does composite keys as a single key string
As i'd make [botid,serverid] aswell as [cmdMsgId] unique keys i can be sure that if the shard succeeds inserting it 1. has no other job on the same server atm (bc [botid,serverid] is unique) 2. no other shard has taken the job already (bc [cmdMsgId] is unique).
i need both keys to achieve both things, no job done twice, no job given to a busy bot
but a job is based on a command
you wont ever have a situation where you need more than one bot respond to a single command
do you?
but it can only be executed by a bot that is not already busy on the server that the command came from
I need help to male a bot
without the composite key, if two trigger come from the same server at the same time (= two different cmdMsgIds) it would otherwise send the same bot twice to a voicechannel at the same time (maybe the same, maybe not).
With the composite key, If the second trigger occurs, the bot that got the job last time will not be able to insert its [botid,serverid] because it is already in the db (but with a different cmdMsgId)
But at the same time the bot will be able to insert and do the job, if only the serverid differs. In this case he does two jobs at the same time on two different servers, which is nice.
@viral spade with redis, there is no such thing as tables or any form of linking data, you need to create indexes and keys yourself, so you would need to manage multiple sets of keys, for example having message key thats basically the job id, and another key that saves bot id and server id. or something like that
you can also try using sets and hashes, which are the redis equivalents of arrays and key->value objects
i just checked it out a bit but it doesnt seem like i can easily achieve this unique key structure in redis
sets and hashes those are nice when you have one primary key, no other uniques, right?
you can have a set like this: botID -> busyguild1,busyguild2,busyguild3,etc... so your bot checks if itself is busy in a guild first, and then execute the jobID key attempt
you mean two different sets?
yeah something like that
each bot has its own set, then another set for jobs, where they race against
problem is with the race conditions. this way id need to have multiple steps to update the db no?
How much memory would you recommend for a discord bot vps?
- insert to busybots: botid -> unique servername
on error do nothing
on success
2. insert to cmdmsgids: cmdMsgId
onerror remove botid -> servername again
on success
do job
remove botid -> servername & cmdMsgId
like this? then all the triggered bots will insert themselfes to busybots, and remove themselves again (except the one finishing the cmdMsgId insert). not beautiful but also not terrible. what do you say?
@sand crown really depends on what the bot is doing. my bot with 500 servers need about 30mb in total with 2 shards (but i guess most of that is overhead). i wouldnt worry about it too soon, or if you have a very special algo that needs a lot of memory. You can also always take a cloudhoster that allows you to add more ram as you need it.
Which host would you recommend? And can you define shards, very new to the site and this community.
Sharding is wehn bot reaches 2500 users and you need multiple instances because of the server limit
also something to worry about not now^^
My bot is at top 4 trending. Has been added to well over 550 guilds in a few days
i really dont know the landscape but i was just fine with digitalocean vps
I'm just worried the ram usage will be too high, and the bot will start to lag.
Sent you a dm Lin
@sand crown but yeah in that case id worry about sharding. actually i did already 😃
sharding is splitting your bot into multiple gateway connections
which allows both you and discord to better balance the load
Just had Linck explain it, thank you tho 😃
you don't need to have 2500 guilds to shard
you're forced to shard at that
but you can shard whenever you want
Will a notification take place when sharding should be done?
no
wym
discord wont send you anything, it will just not allow you to connect to the gateway
yes
Alright, thank you @inner jewel
@prime cliff
Hi
Um
So
What's the equivillent of JS objects in C#?
Please don't say classes
But it is class 🤔
classes...?
Ok
Fine
So 2 part question
I'm working in Unity
I want my script to be efficient
Starting C# with unity wew
What's an efficient way to make a key map?
c# unity is uh barely native c#
For general usage of mapping something you can use a dictonary
for example you can map specific objects to a key
Dictonary.add(1, OBJECT);
Dictonary.add(3 OBJECT);
And you can call them with Dictonary[1]; or like below Dictonary["test"];
Dictonary.add("test", OBJECT);
Dictonary.add("hello", OBJECT);
Hm
How would I make it customizable from the inspector tho....
Also, what's the type for a func?
Do i just do void?
Nope. Doesn't work
I think what I need is struct. No?
void means that the function does not return anything
@deep inlet you should lookup some guides or tutorials on C# if you want to learn it properly C# has some nice features that you can learn to use
All of them are usually using if statement chains for newbies
When I wanna be efficient off the bat
is there any way to fix this whitespace thing?
i tried width:100% on body but that didn't work
yeah dbl page
i have the content stuff set as #000000
but the very bottom doesnt wanna change
is it youtube? i checked it out and looks fine here lol
looks like this is the cause
Lol
looks fine if you have adblock
adblock blocks that
i do have adblock 
does that hide ads though
yeah
oh
then
you can target only that one
if the number of ads is always the same
try css body > div:nth-of-type(3) { display: none; }
should only block the 3rd div
it doesnt look like an ad, it looks like some kind of tracking
you can't hide the ads
if i turn off adblock nothing appears down there from what i see
so i should be fine to hide it?
its a 1x1 image contained in a div
hm
but the div is height 24 for no reason
@quartz kindle even using that hide code it won't fix it
try this
body > div:not([id]) {
display: none;
}```
its the only div without an id
nope
rly? hmm works here
what if you do css position: absolute; top: 0;
then something is wrong with your targeting, or your structure is different than mine
does it work if you do it on the inspector?
wait... why is your css full of html tags? is this normal?
maybe the markdown parser did that
yup
probably md parser
hey can i have a little help? in the console my bot is spamming missing permission i have restarted a bunch of times. I ain't making the bot do anything i check, Any ideas?
someone's probably trying to use your bot in a channel where it can't talk
what library are you using?
discord.js
i regenerated token a second ago to see if was dual projects or something
nope still same
and bot doesn't join channels.
I know
okay so in your message event you can add a check
if (!msg.guild.me.hasPermission('SEND_MESSAGES')) return;`
put that right at the start of your message event
try asking in the discord.js server then and explain
you should always check for permissions before executing the action
discord api then? lol
Send a screenshot of your console, it might be different
is that all?
yeah?
It doesnt give you a file or line?
show your code
I think he said commands arent even being called
there could be something in his code he overlooked
No i didn't say that
but yeah they aren't being called due to simple mistake i made, They did work beforehand and was still getting error.
still, its something in your code
async errors are a pain™
literally what
i rewrote it all
still same error.
was getting error when was no code. 🤔
send your code anyway
it's in multiple files
that can be literally anything
as use module.exports
any action on the discord api where the bot doesn't have permissions
d.js just does the request without checking permissions
and it doesn't capture the stacktrace at the request start so there's no way of knowing where it was done
yeah, the only way is to check the entire code
sure
const prefix = ".";
const args = String.prototype.slice.call(message.content, prefix).split(/ +/g);
const command = Array.prototype.shift.call(args).toLocaleLowerCase();```
What about it?
- you don't check if the content starts with the prefix
i literally do
below it
X.prototype.y.call(a, ...) -> a.y(...)
keeps a pattern throught out my code
yeah i understand
i just like it
as everything looks the same
also
delete require.cache[require.resolve(`./Commands/${command}.js`)];
require(`./Commands/${command}.js`).run(client, message, args, ops);```
do you really need to re-require the file every single time?
if i make a change to the file
and requiring on user input is dangerous
i could eg !../../config.json
or whatever
but that way is longer
you're literally allowing anyone to access any file on your machine
as for the missing permission errors, see if they stop if you remove the invalid command reply
which btw is also a bad practice to warn on invalid commands
no
if someone adds .. to the command name
they can exit that folder
and read from anywhere
Commands/..file.something
ok
../ still works even if you define folders before it
Right.
if else statements are annoying asf though
that's why i use require
like that
you can use a map
there are many other ways
fs.readdirSync
read it once when starting the bot
fs.readdir is async
there's no issue with sync code
its fine to use require, but put the re-require part in a separate command, like a reload command thing
const commands = new Map();
fs.readdirSync().loadthecommandsintothemap```
no need to be async there
and it's useless too
require is sync as well
so
so if async is better you should stop using require :^)
If you are doing it during startup it won't mess up the user experience if it's sync
Won't mess it up if it's async either
well, yeah, but you're basically wasting it
there's no issue in making it sync if only at startup
is import async?
and makes writing code easier
Your perception of async and sync is wrong
change my mind
i think import is also sync
mjs import is async
mjs?
module js
its like a special thingy to indicate that the js file is a module
its something called ES Modules
no, its an experimental feature in node
oh ok
but bottom line is: sync and async are both useful depending on the situation, there is no reason to chose async over sync when async does not give you an advantage
if you really really want async, you can use readfile() and parse it
ok
And in this map of commands i am storing what?
the whole file or?
fs.readdir('./Commands', "utf8", async (err, files) => {
if (err)
return console.log(err);
let cmds = files.filter(file => file.split(/\./g).pop() === "js");
if (cmds.length <= 0) return console.log("No Files");
cmds.forEach(async (f, i) => {
commands.set(f, f);
}); ```
that's what you were wanting me to do?
coomands.set(f.split(".")[0], require("./commands/" + f))
Why am i requiring there?
to load the command
into the map?
yes
ok
then i do javascript if (commands.has(command)) { commands.get(command).run(. . . .); }
?
yes
Ok, all fixed. until next time!
How could I check if something still exists in python?
like
a mentioned user
python rewrite btw
Wdym exist?
Like
you know how JS has
if(!member) return msg.reply("Message here")
I want to do that but with d.py rewrite
mutetime = arg[1]
if (mutetime < 0) != True:
await ctx.send("Need to supply a mute time: !mute [20s] [reason]")
Would something like this work?
Someone wanna help me make a command where i can grab information from a website page and post it into an embed message?
what language?
Sushi
Ah ok
?
or py
Py
discord.py rewrite to be exact
you don’t put parenthesis around if statements in py
Oh yea
xD
I keep forgetting that
so used to js
But do you think that would work if I removed the ()
yea
Ok
Hm I wonder if I could create a function
🤔
that basically does the same thing as ms
you could just write basic code for that
function ms(time){
time * 1000
}
yea
Honestly better then milliseconds
eh true
Forgot how to use asyncio though
await asyncio.sleep(seconds)
@blazing star mb im into these codes LOL , im doing discord.js
huh
ok thanx
cheerio is for webscraping
does it work for any website or for 1 specifically
Ye
but like
Steam
I didn't use cheerio or http lib to get info on a game the user listed
no
be honest
cool story
you're a bot

"im a bot at coding"
lmao
the irony
don't we have a starboard bot here?
yes
my bot writes itself cuz its better off

wow
lol I kinda want to put what he said on starboard
that’s some high tech shit there
nice
xD

buttt who trynna hit me with the 
Bot fixing itself in 2k19 wow
for this website sniffer

yes
i mean
and guide
docs
But
if u dm me u can do w/e u want
for 20$
lol
XD
:<
pay to get
inb4 $20 to remake mee6 but with role rewards
LOL
Shit that would cost way more then 20$
you can give me a 1+1 lesson on this cheerio for my friendship as payment
Fuck yo friendship
dam
i could remake mee6 but who in their right mind would
Money is what talks to me
lol
nakama power??
@sick cloud same
i haven't made a music bot in ages tho
Mee6 is trash
should i
Some of their mod cmds don't work well
music bots more like 95% of the bots since lavalink became a thing
Let’s do the mee6 in the garbage disposal
Discord sponsor mee6
@blazing star Wanna collab on a bot xD
soo is that a NO on the 
Jkjk
dam

bouta ask some mods to spoonfeed me
just write your own audio node like the cool kids 
@earnest phoenix Pretty much
we need DamBot
no WaterBog
newest economy
nah water would be money
you have 9 water
yes tony
so how about i get some really GUD help?
ik you guys have nothing else extremely better to do :/
i could be making a music bot
I actually have better stuff to do
Use module docs you can do better stuff too then
or can i get a good example that i can work off of and edit it to make it my own?
just use HTML to json
because i just dont know how to piece it
use html to json it's easy
webscraping is easy once you know why to do
so you don't have to scrape
or that
if you want to scrape you'll need some knowledge of html
yeah
ok
then learn how to use google and read docs
Just use stackoverflow Lol
actually stack overflow is useful
yeah
TCD is too
stackoverflow should insert zero width spaces in every codeblock on answers
Use your free time and learn stuff
docs help
follow next one
@blazing star hey ❤
uh, hi
i got it but imma need some assistance if u dont mind
then read the docs
i got cheerio to work but idk how to put the info its collecting into an embed message
cool
https://hastebin.com/tesuvuduwi how can i put the info that i collected from the web scrape into my embed?
@earnest phoenix console.log the data u got from the website
I cannot answer that if I dont know the data you fetched
yea i cant find it anymore :<
the basis to put what you want on that embed
is to know what is the data gave you and fix the code according to that
if its a json response it would be easy
it was but i cant get it to show anymore RIP
but if its not, then thats where you may need to manually format it
@inner jewel thanks so much for that ipc recommendation earlier! it seems to be exactly what i need so far! i used node-ipc though, not redis pubsub.
@earnest phoenix dont u have to put something in here?
.addField('Post#1',HERE)
like
.addField('Post#1','')
Yes but thats what im trying to figure out
its the description
i have no idea how to word it
what do you mean?
