#development
1 messages Β· Page 1396 of 1
ok
how would i have my source code on github such that my token does not get leaked
either read your token from an environmental variable
or .gitignore a file with your token in it
the approach with an environmental variable is more preferred though
i think ill have a different version of my code without my token online
and one on my local machine with the token
literally just read from an environmental variable
lol
having different versions is so dumb
what's the point of using github then
from discord.ext import commands
import os
import json
import random
os.chdir("C:\\Users\\forth\\OneDrive\\Documents\\kigles\\eco.py")
client = commands.bot(command_prefix = "!")
@client.event
async def on_ready():
print("Bot is ready...")
@client.command
async def balance(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bnk_data
wallet_amt = users[str(user.id)]["wallet"]
bank_amt = users[str(user.id)]["bank"]
@client.command
async def beg(ctx):
await open_account(ctx.author)
users = await get_bnk_data
users = ctx.author
earnings = random.randrange(101)
users[str(user.id)]["wallet"]
em = discord.embed(title = f"{ctx.author.name}'s Balance",colour = discord.Color.blue())
em.add_field("name = Wallet",value = wallet_amt)
em.add_field("name = Bank",value = bank_amt)
await ctx.send(embed = em)
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0
with open("bnk.json","w") as f:
json.dump(users,f)
return True
async def get_bnk_data():
with open("bnk.json","r") as f:
users = json.load(f)``` keeps giving errors 
unindent does not match any outer indentation level (<unknown>, line 57)
k
can u help me to understand something?
are there any free hosting options available?
reponseDuServeur = objHTTP.responseText
Debug.Print reponseDuServeur
Quoi = Len(reponseDuServeur)
Debug.Print Quoi
"OK" is the server's response
and Quoi is 8
Len() gives the length of the string
so why is the length = to 8
OK is just 2 so wtf
<?php
$auth_success = "OK";
echo $auth_success;
?>
php script that returns "OK"
keeps giving me this error no matter what i do and its quite annoying
Indentation is like the basic of python
it seems like you have bad indentation on the first if else statement
sorry if im intruding-
Why are you returning there? The code below would be unreachable? 
Sure
k
Ye but, what's the point of that return though
Ig the with open should be indented inside the else statement
So should the return True. Nm, I still don't get what's the point of it 
from discord.ext import commands
import os
import json
import random
os.chdir("C:\\Users\\forth\\OneDrive\\Documents\\kigles\\eco.py")
client = commands.bot(command_prefix = "!")
@client.event
async def on_ready():
print("Bot is ready...")
@client.command
async def balance(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bnk_data
wallet_amt = users[str(user.id)]["wallet"]
bank_amt = users[str(user.id)]["bank"]
@client.command
async def beg(ctx):
await open_account(ctx.author)
users = await get_bnk_data
users = ctx.author
earnings = random.randrange(101)
users[str(user.id)]["wallet"]
em = discord.embed(title = f"{ctx.author.name}'s Balance",colour = discord.Color.blue())
em.add_field("name = Wallet",value = wallet_amt)
em.add_field("name = Bank",value = bank_amt)
await ctx.send(embed = em)
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0
with open("bnk.json","w") as f:
json.dump(users,f)
return True
async def get_bnk_data():
with open("bnk.json","r") as f:
users = json.load(f)``` keeps giving errors 
Closest thing I can find
To my current one
man, the indentation is so awful
Thanks Indian man that I copied this from I mean what
@client.command->@client.command()commands.bot->commands.Bot- your
get_bnk_datafunction only load the json, but not returning anything, so the users would be None?
users = await get_bnk_datathis is not how you call a function- fix your indentation \π³
There's like so much wrong with your code, ig you should def learn python before making a bot
bruh
why did it ping
im assuming i can ask this here cuz its more of a development issue i think but my bot keeps spamming command answers, but idk if its something wrong with the code. the thing is, it only spams on some commands and all of the phrase reactions but on others it doesnt. sorry to bother anyone ;-;
im new to bot development and started it as a little project for a server i am in but i kind of want it to go on top.gg for everyone to enjoy but i dont want to apply if its gonna spam every command
its not intended to spam either lol
hm?
ok, can you provide the coding of one of the commands that it is spamming?
yeah
@vernal rivet sorry how can i do that
do what?
do you terminate the bot and restart it after each changes?
the command itself works but it just spams
what are the ways to print an aggregate function to an embed? thank you!
@torpid axle you're aware you can just get(command), right?
i dont know how
if else checking defeats the purpose of using a map
lmao
sorry if this is really simple and im just being a dumb dumb im new to all this
then your problem is that you have multiple instance of it already
let cmd = client.commands.get(command);
if(cmd) cmd.execute(message, args)
its that simple
ah
no more if else
in the console, just do ctrl + c and if it askes you if you want to terminate it, just type y, and enter
ooh oki ty
but tim, what if i want to abuse switch cases, and make people suffer by staring at it 
i wrote 1.5k lines of c++ today, im tired af
oofers
not even doing anything special, just boring
same :feelsbadman: i have a bunch of exercises i have to do for CS but they're all boring
rip
i still have like 2k more to go lmao
wrapping a c lib to js with node-addon-api
there tim
hello, good night
Ever worked with crc buffers?
I can give you some work which is challenging 

its the best code i ever made its bootiful right?

its me again sorry but when i do ctrl + c it doesnt terminate ;-;
mhm, you want to terminate it, then restart it
sorry - i meant it doesnt
i need a multibot with predefined answers. And each bot will have a list of answers.
how many consoles do you have open?
1
does it say something about terminating?
the console is the terminal right? sorry its been a long day
yes console = terminal, terminal = console
wait, does your bot listen to the console?
it should lol
i mean do you have any process.stdin in your program?
is this vscode terminal?
yeah
oh, ok that explains the coloring of that ctrl + c
ye
it works fine for me, i am trying this in my vscode, and it works
so my friends say i need to require somethin in main file to make my Welcome And Leave command work
but i dont get what they are saying
no process.stdin, was a question if it wasn't responding, but it should still terminate
i need a multibot with predefined answers. And each bot will have a list of answers. do you know an bot?
ah
you have to require a file to use the file in your program.
yeah its not terminating
what does your terminal look like?
Do you know if they are talking about a file, or a package?
A File
it was tho lol
how do i make the bot count how many servers its in on its status
localhost? just restart your pc if terminal doesn't work
oh- it takes a bit to go offline
for example: Watching 300 servers
your fine
ty for helping me ;-;
np
hello is anyone here know how to embed / print out aggregation results in mongodb using js? thank you!
they are saying that you need to require the file to use what ever is in that file.
np
oh so like js const welcomeandgoodbye = require(./greet-bye.js)
yert, uhhhhhh can you please use camelCase please π it hurts my eyes without camelCase, or snake_case
trigger words for the response are still spamming
Did you check docs? There is a clear solution in there
Check the Client section at guilds, and go from there.
are they in a for loop?
this is an example of one
you're not ignoring bots
^^^
?
you don't have check to see if the user is a bot or not, so if the bot response with a command name, it will execute, and cause a infinite loop
is there a command name that searches for >:(?
i dont think so
no
sorry ;-;
imma try to solve this on my own so yall dont have to waste your time with me lol
stilll confused
wdym 'guild section'
there is no section titled the guild section
i figured it out :>
i needed to add .toLowerCase()
ty again for all of your help ^^ i can now apply without worrying about the spam
@vernal rivet so client.guilds.size?
client.guilds.cache.size
k
don't join with a newline
it isn't
module.exports = {
commands: ['say'],
description: 'Repeats What u say.',
usage: '<message>',
minArgs: 0,
maxArgs: null,
permissions: [],
requiredRoles: [],
callback: (message, text) => {
message.channel.send(text)
}
}```
but it wont wotk like !say ello ello
show your command handler
const path = require('path')
const fs = require('fs')
const EventEmitter = require('events')
EventEmitter.defaultMaxListeners = 1000```
what
lmao
nvm there
yea
You can use a host on web
or vps
i asked about the keyword

read this
Can anyone tell why my bot is late responding to commands even if the ping is lo
like , if i type (!) rythm would become functional
what do you think is the real problem?
IDK
how are you measuring the ping?
I have restarted my bot but the same problem
I think some problem is with VPS I use
where is the vps located?
Oof
Site
lulw, I had experienced that becuz i was storing prefixes on db and the db was being hosted in the other side of the world 
Lol l
oof site
thatβs a place?
lmao
Nah
you lied to me
/s
@earnest phoenix I haven't told the name
Of site
Lol
i was being sarcastic
Lol
Is my site i used
in any case i didnt ask about the site
i asked about location, as in geographical location
your vps is located in india?
Ya
that would increase the ping a bit
Hmm
discord is located in new york
rip that ping of yours lmao
Hello
It is 33
Someone can helpme with some?
websocket ping is different from rest ping, still 130 ping is good enough, your bot shouldnt be slow
I want what my bot of discord read all messages and when he see the word Mati do something
huh
check if message content includes Mati
which language and library are you using?
discord.js?
Yes
client.on("message", message => {
if(message.content.includes("Mati")) {
// do something
}
})
if you want it to be a command
then no
then put it outside the switch
Okay
STR is?
Yes yes
I understand what do you want say
But my question is what is the meaning of STR
string
Oh
Okay
Thanksss
That doesn't do anything
@quartz kindle
I'm doing something wrong?
its san francisco
@quartz kindle If you are going to write, send me a DM
π¦
But if that don't start with Mati?
sure
like the code?
client.on('message', message => { if (message.content.toLowerCase() === 'patoto') { message.channel.send('Yes!'); } })
it sent weird but thats the thing lol
Is it possible to wait for the "end" event to fire on a stream being piped to an express response
I've been trying but it never seems to recognize the event has been fired
I may be stupid and it isn't possible hence my asking here
for example <stream>.pipe(res).on("end") // do things
That not work
Yes
oh-
sorry-
hold on a sec
nu that should work
dont copy and paste - go from the screenshot i sent lol
π¦
whats your script?
are you publishing the code before trying to see it works cuz that might be the issue
i have multiple trigger commands for that and they all work
also it wont work if you have any other words
you have to just have that one word
I don't know
go to the console and type node .
Send me DM
?
why DM lol
i dont do DMs or friend requests cuz i dont know you personally ;-;
sorry
but you should publish your code by going to the terminal and typing node . and then test it out
Are you new to programming?
me?
No, ask to me
ah
In JS yes
I know java
Do you know basic programming?
Obviously
im only new to js and discord bot programming but im really good in python lol
But this iss different
i was responding to koreanpanda lol
@torpid axle Me too
oh lol
i can send it here tho
Idk, may be is better
:/
Ok so what are you trying to do?
I need help.
For some reason it thinks
let loomianData2 = {}
is a function. I think im missing a close but Im not getting any syntax errors or popups
I'm trying what my bot reads the messenges and when one say the word "Mati" say something
Like
Yesterday Mati helps me with my homework
And the bot says
Mati is stupid
Ok so that's all boolean logic you have to do
xD
Ok I am probably reading this wrong, but you are wanting it to say something if it reads "Mari" or not?
Yes and no
idk if this is part of development but im not asking about terminating bots or anything lol
what if i wanted to do economy with my bot?
If someone say the word "MATI", the bot writes someone
how would i even begin to start coding that?
Databases
Well then message.content.toLowerCase().includes("mati")
^^^
You probably forgot includes is case sensitive
Returns a boolean value
hey
Yes?
a man has fallen into the lego city river
Like this?
try it and see
^^^^^
If thatβs the right djs syntax then probably yes
But be careful the internet will explode if this code is wrong

Lmao
Nop hahahha
Did you run the bot?
Yes
Someone using ytsr can tell me why when the safeSearch option is set to true this error happens: TypeError: Cannot read property 'user' of undefined
"what the fuck is this thing that user is apart of. You expect me to know what the fuck you are talking about?!" That's the computer right now
F
Okay, I know that, but I can't find the problem.
Does d.js even ask you to choose the intents you want to use?
Only jda that I know of does
And no d.js never asked you to specify what intent you want to use. Even then the intent would be sending messages. That's something that would be included already
Yeah is probably only required for privileged intents
Best solution is to console.log the message object and test it again. If it doesn't show in the console then you are missing a permission. If it does send then something is wrong
Funny enough, I've had users ask me why my bot wasn't working, only to find out they removed her WRITE_MESSAGE perm
I wonder why that's a perm to start with
Perm or intent?
Permission
Is to prevent users to talk in places that they shouldn't talk in
Yeah but, for bots?
Yeah, ig it'd be extra work for nothing
Just define the required permissions in your bot invite URL
If anyone removed them later thatβs nothing you can change
Greetings fellow hackers. For my bot that has recently been added to top.gg, I started to experiment a tad bit with the dblapi. Since my bot isn't really one with a reward system, I tried to make it send a message to a specific channel every time the bot was upvoted, yet I was unsuccessful at this, can anyone help me figure out what my issue is?
Code:
const bot = new Discord.Client({fetchAllMembers: true})
const dbl = new DBL('TOKEN', { webhookPort: 5000, webhookAuth: 'password' }, bot);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
bot.channels.cache.get('778460112313647175').send(`User ${bot.users.cache.get(vote.user).tag} just voted for Tic-Tac-Toe!`);
});
incase anyone ever has this issue and looks it up in here- if you end up with a node stream always returning true on writes even if it hits the highWaterMark - you can count ticks between chunks written and override it by emitting the drain event every 50 ticks (anything sooner you'll run into a choppy stream) - make sure to pause the stream first, then resume after the drain has taken place. if you don't pause it, chunks keep writing and the drain never occurs
Oh and you're most likely using a simple webserver to serve the stream and piping it in- you have to call the drain event on the pipe as well, as node doesn't recursively drain pipes
I'm posting this here because there's nothing on stackoverflow on this π
@boreal flume cant help much without errors or some more info
Error?
there could be 3 things i can think of right away.
1 You didnt port foward(so no events are incoming)
2 You dont have the channel cached
3 You dont have the user cached
do me a favor do
The users are cached
are you use the user who voted will always be there though?
what if someone vote for your bot that isnt cached?
or not even a user that you have shared servers with
do all 3 checks tbh
console.log({channel: bot.channels.cache.get('778460112313647175'), user: user});```
add this there
It gives me the channel for logging it
right under 'vote'
then trigger a vote
console.log({channel: bot.channels.cache.get('778460112313647175'), user: user, _user: bot.users.cache.get(vote.user)});```
^^ updated
@boreal flume
Also @boreal flume This would be better in #topgg-api :)
Nothing is logged when I trigger a vote
What do you mean by port forward?
thats the actual term
Open the door
port foward it
Basically
But what does it mean...
google port fowarding + your router model
enable incoming stuff for your host/pc
its kind of annoying to explain
My bot runs off a server
then you must have that port open before it can recieve packets
Ubuntu?
AWS
google AWS port fowarding
dont use port 80
80 is http
node and port 80 is a BAD idea
Don't use 80, 443, 8080 and 8000
^^
And 4321 if you use postgres
There are only two ports open on the server
then open one more
80 and 443
or use nginx of some other tool to attach on those common ports
80 and 443 are open by default
just google how to open mroe ports
And how do I open ports?
surely your vps allows it
im fairly certain aws has a panel they can use it
Never used aws, so idk
it shuld be a matter or literally just typing on google how to open ports on aws
aws is too big to not have port fowarding
Is it linux-based?
Does ufw status do anything?
hi guys recently i had a little problem, i added a ban / kick command to my bot, but the problem is that when someone join my server, the bot automatically send this message : (message.author.username + ", vous n'avez pas la permission nΓ©cessaire pour utiliser cette commande !")
which is a respond to someone who use a ban command without having the administrator permission
the thing is that the message is automatically sent when someone join the server like a join message
but the message is for members who don't have admin permission and use the ban command
HEY CAN ANYONE HELP KOYA BOT IS NOT SHOWING WELCOME MESSAGE
Command not found
@earnest phoenix is your ban command inside an on member add event
ask on their support server lmao
hmm, random scope
Hm, then idk
See if there isn't some port or firewall panel in aws
@earnest phoenix you forgot an else
I found some stuff about opening ports from the command line
Like, something MUST be controlling ports somewhere
where pls
aws lightsail open-instance-public-ports --port-info fromPort=5000,toPort=5001
Note: AWS CLI version 2, the latest major version of the AWS CLI, is now stable and recommended for general use. For more information, see the AWS CLI version 2 installation instructions at: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --instance-name is required
Try that then
But when I put some random instance name, it say my region must be set
I will figure it out some other time lol
like that
Your embed field's value has over 1024 characters
i put the embed field value into lettercount, it shows like a half of 1024
does it count every single field
bruh, you know you can't rely on it
you counted your code chars, not the actual returned values
let me put every value into lettercount
No, don't
Why not just make it all into the description, and separate the sections by Bold Text, as most of your characters you are counting are coming from long code text that returns much smaller amounts of character
The embed description I believe has a character limit of a tad over 2k
The field value is supposed to be a string @tribal siren
You need to join the array (with "\n" in your case)
me ?
guess so
what should i do
You should add that permission check inside the command
if (content.startsWith()) {
if (!member.hasPermission()) return send("no permission");
let mention = ...
}```
if (!client.cooldown.has(`${message.author.id}`) || !(Date.now() - client.cooldown.get(`${message.author.id}`) > client.config.cooldown)) {
let xp = db.add(`xp_${message.author.id}`, 100);
let level = Math.floor(0.3 * Math.sqrt(xp));
let lvl = db.get(`level_${message.author.id}`) || client.db.set(`level_${message.author.id}`,1);;
if (level > lvl) {
let newLevel = db.set(`level_${message.author.id}`,level);
}
cooldown.set(`${message.author.id}`, Date.now());
}
}```
i was making rank system using quick.db

await channel.overwritePermissions(role, {
SEND_MESSAGES: false,
ADD_REACTIONS: false
});
});```
why it no work
error
Whats the error?
your name kinda weird fonted
forEach is not defined
?dnw
try message.guild.channels.cache.forEach
ok ill try
did it work?
No problem! Glad to help!
is there a way to check if the bot can send a message in a channel? (discord.js)
i want to save computations by just ignoring things in channels that the bot can read but not write
You could use <TextChannel>.permissionsFor(...).has("SEND_MESSAGES"): https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=permissionsFor.
Keep in mind, this method only works on text channels (no DMs)
If you want to check for that, you must try sending your message (and catching if an error occurs).
well i was wondering if there was a way to check without just trying and seeing if it worked
im not worried about dm's so ill just blindly allow dm's since the only reason my bot is dming is if it was called for which, yes, you have to just send something to see if it works π
Can I set custom status for the bot, without Playing
client.on('message', message => {
if (message.channel.type == 'dm' || !message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
// your code
})
thonk
(message.author.bot || (message.guild && message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES"))) thats what i came up with
wait im dumb
lmaoooo
But I think you should let the user know, that your bot don't have permission to send messages.
i mean to dm yeah its easy but i get irritated when bots dm me so it would be silly to do it
let channel = message.guild.channels.cache.find(channel => channel.name.toLowerCase() === 'general');
if (!channel) channel = message.guild.channels.cache.find(channel => channel.name.toLowerCase() === 'general-chat');
if (!channel) channel = message.guild.channels.cache.find(channel => channel.name.toLowerCase() === 'chat');
``` how do i make this code better
yeah π¦
π¦
needs cash
hmm
e
yeah thats weird
Noo costs moolah
Host your own Discord Bot with 24/7 friendly support on Quality Hosting servers with DDoS protection and enterprise level DDR4, SSD XEON E5 servers. Starting from β¬0,56/mo.
hmm needs cash too
noo
hmm
get a raspbery pi
Don't use hosting specifically geared towards discord bots
i'm use this code but, someone send dm to my bot and gotta error
I updated the code, now it will not respond for the dms. @neon heart @sturdy gazelle
why am i getting pinged?
oh i figured it out already let me see if it works in dms
sorry, if disturbed. but it was related to u. so...
how?
oh i see
in here?
thanks for pointing that out
hi
If the channel is a 'dm' type, it will immediately return from it.
okay
if (message.author.bot || (message.guild && !(message.guild && message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES"))))
that should work
oh i can simplify that
yes.
if (message.author.bot || (message.guild && !(message.channel.permissionsFor(client.user.id).has("SEND_MESSAGES"))))
better
theres no need to put parenthesis around && and even !, save 4 more characters π
i get insecure about that so i do it also so i can easilly add or remove things
i do my oneliner if's like this:
if (thing)
lol;
it might not be most efficient but its cleanest
also, having a restart command is so op like wow
hi plz help me out
try:
#....
except ValueError:
#.....
i have such a try except loop
but the error randomly showed up in console
instead of executing the except block
it generally works normally but i have had this prob once before
does anyone know why thsi is happening
I dont know much about python but, doesn't it have catch keyword?
in py its except
The error showed up in console isn't ValueError, is it
it is

File "main.py", line 639, in pokemon
if not no or int(no) == 1:
ValueError: invalid literal for int() with base 10: '--name cleffa'
lol
makes no sense
could you send your code
How to
why is your except indented
it isnt
In first channel
hm weird
Help
Read the error
@somber wigeon show your code first
@vale garden the if statement is not at the correct indentation ig
That's the code
does that really matter tbh
i thought indentation could be of any size
even that doesn't matter, it's always good idea to have consistent indentation
the convention according to pep8 is to have 4 spaces per indentation level
Hey uh im new to developing discord bots and was wondering how do i ping a role?
If you have the role object, you can use role.toString() or `${role}`. Otherwise, you can use the id using <@&id>
@& ?
Yes
Alright, will try thanks
For example <@&265125253443878912> for Bot Developer
:0
smart
Okay so
it does ping me and it shows that it pinged the role but my manager isnt getting pinged
And my bot has f!help too
oh and btw f! was the previous prefix of my bot
Incorrectly documented prefix?
and i changed it now
ok sorry Too
Who has a bot server on which my bot is, is called Abyssus my bot?
excuse me, wot
Is that you have my bot on your server where you test your bot
oh, nope
@strong tundra Hey, I was searching messages regarding microservice and you happen to be one of them.
Did you ever start on any?
Ah, I was just wondering how people decide upon how many instances to run for the microservices
I have almost all the parts, but I'm not sure about the devops or orchestrating the microservices
id probably scale up as needed with like kubernetes or something
maybe dokku would work?
I was going with a kubernetes approach about 2 years ago, it turns out running kubernetes alone is not fun
I'm currently wondering on how many of the http microservice I will run, the service that actually processes the event and send requests to Discord
Perhaps one is enough
for now
I'm going with Ansible and deploying an agent onto each machine, but that's so far only for the router layer.
Hey
100 votes = 1 USD ?
seems easy
if i have 100 accounts i can earn many hundreds usd
/month
K8s is too complex for my application, and the overhead is huge for instances.
Currently I'm deciding to deploy N instances across X machines, which leaves N/X instances per machine, and each machine will have an agent to deploy those instances.
Might re-use the same agent to deploy HTTP workers depending on how much load it actually gets, not sure if I'll ever scale HTTP workers across machines, since it's rather stateless, and the only thing it does is process event received by internal message bus and send http requests.
why this be eroring
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
(node:15148) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.
hey some one anwser my ques
hm interesting
I'm using Nats btw for my internal message queue
Coordinator, router, agent, and http worker all communicate via nats
idk why you'd need more than one http worker per machine though
That's the uncertain part, could I ever get so much requests that the network I/O will be bottlenecked for one machine
yeah I plan to have one http worker per machine if network I/O is the problem, which prob will be
ah yea
I'll prob allocate VPS for the http workers, since it's just all network I/O, cpu will prob be idle
that seems reasonable
welp that seems to solve most of my infrastructure problems
Now to see how many instances of nats & redis I need
lol
var secondMemberPP = await loadImage(opponent2.displayAvatarURL({format: "png"}))
error:
opponent2.displayAvatarURL is not a function
It's neat, I'm using compressed redis store
i should get started with darkredis i guess
#development message was my previous discussion of my infrastructure
Since I plan to back the bot with a web interface, which means a HTTP API, cache has to be centralized with something
hm yeah
im looking into compression with redis and found a cool doordash engineering post
I'm using bincode with twilight-models + flate2 for compression
#[derive(Deserialize, Serialize)]
pub struct Guild(pub GuildModel);
impl FromRedisValue for Guild {
fn from_redis_value(v: &Value) -> RedisResult<Self> {
if let Value::Data(data) = v {
let mut decoder = ZlibDecoder::new(&data[..]);
let mut decoded = Vec::new();
decoder.read_to_end(&mut decoded).map_err(|_| {
let err: RedisError = (ErrorKind::TypeError, "Unable to decompress data").into();
err
})?;
let guild: Guild = deserialize(&decoded).map_err(|_| {
let err: RedisError = (ErrorKind::TypeError, "Unable to decode to guild").into();
err
})?;
return Ok(guild);
}
Err((ErrorKind::TypeError, "None binary data").into())
}
}
neat stuff
I went with flate2 zlib because twilight gateway has an optional feature for utilizing that
and flate2 zlib-ng feature utilizes SIMD instructions for speed-ups
Yeah, however I don't really have much of a test bot with numerous traffic to benchmark the compression trade-off
Here's the current coordinator + router: https://i.imgur.com/lJtz2wi.gif
ah
Clusters consists of N shards, and each cluster will communicate to coordinator for shard id allocations.
From there, cluster will heartbeat on an interval, and coordinator will send shut down request to clusters if something goes wrong, allowing the agent to boot up another instance.
Yup, an uncharted territory for sure, I'm figuring out things as I go
heh
maybe I need an rubber ducky, talking to something about my problem and I somehow figure things out
i don't think too many people have done stuff like this
and i think the only docs i could find are on discord's own website
at least with big bot sharding
Yeah, and I'm glad I found twilight, I was originally using serenity
just split enough for building microservice with it
this errors ```const { ownerid } = require("../../loaders/reader");
const { MessageEmbed } = require('discord.js')
module.exports = {
config: {
name: "add"
},
run: async(bot, message, args) => {
if(!message.channel.name.includes('s-ticket'))return;
let notallowed = new MessageEmbed()
.setColor('#e64b0e')
.setDescription(`Need to be admin or created the channel!`)
if(!message.member.roles.cache.has("710751019495194645")) {
if(!message.channel.name === `${message.author.name}s-ticket`) {
message.channel.send(notallowed)
};
}
let user = message.mentions.members.first()
let channelsend = new MessageEmbed()
.setColor('#e64b0e')
.setTitle(`Added User`)
.setDescription(`${user} has been added to the channel!`)
message.channel.overwritePermissions(user.id, {'VIEW_CHANNEL': true, 'SEND_MESSAGES': true, 'MENTION_EVERYONE': false})
message.channel.send(channelsend)
}
}``` (node:15148) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role
didnt mean to flood
And somehow my clippy broke π
it is, especially reducing cognitive overhead on expr
ah cool
i think my bot has a gh actions linting process but it always fails cause i never bother
lol
this is funny, I guess this is a bug with clippy? Says it's been fixed, I forced a whole cargo check, and it's giving me lints again. Nvm, still an issue with cargo apparently.

it probably is lol
AbortError: The user aborted a request.
Yes ?
I just solve error, not giving code
tellling error
Yes tell me your error
let chx = db.get(`welchannel_${member.guild.id}`);
let msx = db.get(`welmessage_${member.guild.id}`)
const welcomeChannel =db.get(`welchannel_${member.guild.id}`);
// Send welcome message
let data = await canva.welcome(member, { link: "https://wallpapercave.com/wp/wp5128415.jpg" })
const attachment = new Discord.MessageAttachment(
data,
"welcome-image.png"
);
chx.send(msx,attachment);
}
);```
so if i try to replace text after 4th line it says cannot replace of null something like this
why not starting deploy ```css
Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.19.1...
Using default npm version: 6.14.8
-----> Restoring cache
Cached directories were not restored due to a change in version of node, npm, yarn or stack
Module installation may take longer for this build
-----> Installing dependencies
Installing node modules (package.json)
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/amishshah/ytdl-core-discord.git
npm ERR!
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.AYNu9/_logs/2020-11-20T10_06_37_627Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed```
are u having config.json file on github
yes
yes
node index.js
i need to check can u send screensho of resources tab
1min

oh wait i found why not starting
"ytdl-core-discord": "amishshah/ytdl-core-discord",
cant install this
after remove from package.json ytdl core
work

but how to install yrdl core "ytdl-core-discord": "amishshah/ytdl-core-discord",
When i create a support ticket myself, this line works just fine
await c.send(
${message.author} has created a new ticket Support will be with you soon <@&765885271861624843>);
But when anyone else than me opens a ticket, it dosent ping me, dosent even include the "Support will be" line
hi
hi
it's literally just
// check if the message sender is the bot owner
// if they are then run the eval
eval(/* message content */);
const format = /[ `!@#$%^&*()_+-=[]{};':"\|,.<>/?~]/;
member.setNickname.replace("format");```
not working
@earnest phoenix looks like you mentioned me
yes
i think its a discord bug
@earnest phoenix you ping me ?
no it's not
replies can turn on or off mentions
this reply has no mention
this reply has a mention which pings you
huh
i dont know about that lol
replies are a new thing
h
also #general
@earnest phoenix did i ping you ?
yes
oh
nice
anyways
@earnest phoenix if you were trying to tell me how to make eval command... i make eval command yesterday
ok
Is there a function in djs to reply to a message ?
you mean the new reply thingies or the <user ping>, <text> one
No the new one
Like this
i don't think so
Ok
Anyone a idea how to start a specific shard or from a specific shard point. Like i have one server and there is running shard 0 to 10 and i want a second server with shard 11 to 20 is that possible
is there any way i can make my bot send a reply into a channel the command was executed inside and allow the users to customize the prefix
well I mean thatβs a broad question
even harder for us to answer if u donβt know what ur doing
i need help with pymongo
use djslight :^)
we can do document.createElement to make new elements but how do i do the opposite to delete one
let element = document.querySelector("shivaco_is_not_a_qt");
delete element // because shivaco is a qt
element.remove()
discord.js-light
@earnest phoenix 
djs is an abbreviation
the actual name is discord.js
@crimson vapor their codes are same as discord.js ?
@earnest phoenix imagine saying i need hek
THAT WAS ACCIDETNT
discord.js-light uses less ram
almost same except discord.js-light allows you to control caching to save storage
"Storage"
*RAM
*space
@earnest phoenix so i dont need to change anything from my code ?

almost nope
nope, but you can implement your own easily, it's just the "message_reference" part when you POST a message into Discord.
it depends what your code does
you will likely need to change all your .cache.get() to .fetch()
i need help with pymongo, so i want to get all servers id and check all of them if they have some specific value nvm just i dont know how to get all servers ids so it would be helpful if someone knows
thats it ? @quartz kindle
it depends what your code does
@quartz kindle my bot is @earnest phoenix
discord.js comes with everything enabled, so everything always works
discord.js-light comes with a lot of things disabled by default, which you will need to manually enable depending on what your code does
for example if you need permissions, you need to enable cacheRoles:true and cacheOverwrites:true
ok so i am not gonna install discord.jslight lol
nikola tesla
as you wish :^)
nope tesla tower
how much ram is your bot using?
how many guilds?
suffer from djs' eating ram technique instead of djs-light's not eating ram technique then
my old which i probaly copy from github uses 400 mb ram at 1900 servers

normal djs prob would eat like 600mb to 800mb
how to get whole row in pymongo
huh it eats the ram really
@pale vessel lmao
btw those 134mb are because i cache user data and api responses for 24 hours
if i didnt cache those, it would be around 70mb
@earnest phoenix do you know who is nikola tesla
a genius
its tesla car owner maybe
getAllDocuments or something, look the docs
let preferredGames = response.preferredGames[0] || 'None'
```Cannot read property 0 of undefined
i got that name from tesla tower in clash of clans
...
thank you
and where do you think they got the name from
ofc the tesla coils
if i install these packages will it decrease my ram usage ?
what else
and where do you think tesla coils came from
Nikola Tesla was genious, Elon Musk is owner of Tesla Motors.
LOL I was joking
let preferredGames = response.preferredGames[0] || 'None'
```Cannot read property 0 of undefined
lmao
yes
@earnest phoenix those affect cpu, not ram
CEO
@restive furnace @quartz kindle @crimson vapor stop this is #development
that less RAM for making a bot on an app which runs on a chromium-based framework
are you battling google


