#development
1 messages Β· Page 1795 of 1
probably something related with the stdin::read_line library
look you're famous now @crimson vapor
I thought it would be synchronous, but I'll have to take a look
Since the println macro works just how I want it to
is that 4k?
is the thick side-bar a intention?
Maybe try flushing before reading the line to ensure it's printed out?
Not sure that's the cause, but I'll pong you with a result once I'm done consuming POTATOES
no, its 1080p
oh shit pog
Yep, you have to flush it if you want it to print out right away
Or, since the stdout is line-buffered, you can add the \n manually instead of flushing it. But that kinda breaks the purpose of not using println 
Normally these buttons should point to google but they do nothing, what could be the problem (Visual Studio Code - CodeTime Extension)
guys, how do I define discord.Guild()?
It says it needs state and data but idk what to fill in there.
I'm working with discord.py btw
wait this prolly goes in #support
Nah
oh
You don't define discord.py objects per se. You're supposed to get them via various methods
π€
Error: Cannot find module 'discord.js'
Require stack:
- /Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/node_modules/discord.js-commando/src/client.js
- /Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/node_modules/discord.js-commando/src/index.js
- /Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/bot.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/node_modules/discord.js-commando/src/client.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/node_modules/discord.js-commando/src/client.js',
'/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/node_modules/discord.js-commando/src/index.js',
'/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/bot.js'
]
}
https://gist.github.com/RealYusufIsmail/0f69332c9e707d2e659cfe0a92afae32
https://gist.github.com/RealYusufIsmail/ed25df6925c9a5711f42d41e6b79fbba
i get this error
so then what?
I'm kinda trying discord.Guild.members() but it's not working :/
npm i discord.js
i did
delete the node_modules folder and do npm install again
discord.Guild can be received via Client.get_guild, Client.guilds, or whatever other methods return it
why do you need commando if you're not using it?
i am
you dont use it anywhere in bot.js?
How do you want to get the guild? You can use Client.get_guild with the guild ID
Oh i am not using it
i thoght i was
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const Youtube = require('simple-youtube-api');
const ytdl = require('ytdl-core');
const { youtubeAPI } = require('./config.json');
const youtube = new Youtube(youtubeAPI);
elif message.content.startswith('!members'):
for member in discord.Guild.members:
await message.channel.send(member.mention)
here's my code, but I'm not sure if this is where the issue lies. Going through the documentation it said discord.Guild.members would return a list, but then I get the error:
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/pi/PycharmProjects/AWOOOOOOOOOO/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/pi/PycharmProjects/AWOOOOOOOOOO/REDACT-a-bot/bot.py", line 80, in on_message
for member in discord.Guild.members:
TypeError: 'property' object is not iterable
oh...
Yeah, discord.Guild is a class. You need an instance of it
Oh no that's a bad idea doodoo
First of all, why have a command that tries to mention all guild members?
Secondly, ignoring the first question, you don't want to send messages in loops. It's preferred that you create one big string and send it at once instead.
Thirdly, an instance of Message (named message in your case) contains a guild attribute, which returns an instance of Guild. You want that, and not the class itself.
- This is mostly a test function for what I'm gonna try to pull later
- Hmm... oki
- oh! So should I do
Message.guildor smth? This is in the on_message loop.
oh
You don't want the class (Message), but an instance of it, which is stored in a variable message
but on_message(message) takes message as input. Is that the same message?
In your case, yes. It's a parameter that you use
is this right https://gist.github.com/RealYusufIsmail/0f69332c9e707d2e659cfe0a92afae32#file-bot-js-L23
Mhm
π
How could i change the color of these objects
Using CSS
I know, How could i change the color of those what are they called etc 
I don't need code
I don't understand what you mean then... π€
CSS is how to change the color. Take the class from the html element.
Ah so i inspect element right?
Yes
Ah thank you
No problem! π

Just make sure you're forcing dark theme in the bot's settings page if you're making a custom design that doesn't take light/dark theme into account.
yea i know
You can design for light / dark by getting the selected theme from the <html> wrapper
Hello
How can I fix this?
I write node . In the terminal
The bot comes online
I invoke a command
And then it says
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
at checkListener (events.js:130:11)
at _addListener (events.js:408:3)
at Client.addListener (events.js:466:10)
at Client.<anonymous> (C:\Users\sitir\Desktop\test\index.js:489:9)
at Client.emit (events.js:387:35)
at MessageCreateAction.handle (C:\Users\sitir\Desktop\test\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\sitir\Desktop\test\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\sitir\Desktop\test\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\sitir\Desktop\test\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\sitir\Desktop\test\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10) {
code: 'ERR_INVALID_ARG_TYPE'
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
Show your code
I am not doing it for money man
Just for fun
How did you type all of that in that short amount of time lmao
I am learning
// Print out text for user
print!("{}", Color::Blue.paint("Enter array index: "));
// Read user input
match io::stdout().flush() {
Ok(flush) => flush,
Err(e) => panic!("Problem flushing stdout: {:?}", e),
};
io::stdin()
.read_line(&mut index)
.expect("Reading line failed.");
seems to do the job, thanks
we arent magicians
This is develpment...
oh, right
Show your code
wait what
Debatable to some people 
now this is weird
if i to go #general , go to another server, and come back, it defaults me to here
LMFAO
o weird
You're Tim v2
happens to me atleast 12 times a day
/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/bot.js:24
Structures.extend('Guild', Guild => {
^
ReferenceError: Structures is not defined
at Object.<anonymous> (/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/bot.js:24:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
i get this error
i dont see you defining anywhere.
ok
what are you trying to do?
you're still not using commando
client.registry is for commando, you're not using it
and Structures is inside Discord
if you want to use commando, then use it properly
follow the docs
if you're not using it then remove it completely
i thought they made commando π
idk who made it, i just recall its quality being some of the worst things ever created in js, ranking just below is-undefined
@solemn latch is it my time to shine now with detritus?

π i still need to figure out buttons with detritus.
need help?
i'm sure its in the support server somewhere i think i can figure it out
use this
import { ComponentButton } from 'detritus-client/lib/utils';```
or ActionRows
i do it manually cuz im stoopid
though i DO like the button helper since it parses emojis for you
are you learning rust now? @slender thistle
Mhm
pog
It's fun
What kind of project lmfao cuz I'm like
@solemn latch how is it treating u?
@latent heron https://puu.sh/HSmtC/83c7d43c89.mp4 this is a thing I'm experimenting with to practice it
I don't think I'm ready to do backends lmfao
so my bot works but the music commands does not work
π
Why are you sending these here
What's the issue you're having, again?
My music command does not work
?
re-asking the same question isn't going to suddenly give you a different answer
what?
thats not how it works
I am using it
_letβs hope Erwin isnβt getting a heart attack _
I would greatly appreciate it if you didnβt ping me 7 times and send a friend request. I am not available to answer your questions all the time, I went to bed at the time because it was 1am.
You could unwrap it instead doe
, but np!
I am fixing some stuff
If you are going to use it multiple times, I would recommend making it into a function, also that match and panic is kinda waste of code cause you can do the exact same thing with .expect
use std::io::Write;
fn cprint(string: &str) {
// Custom print function to print inline and flush
// You can do this manually but its easier to do it this way
print!("{}",string);
io::stdout().flush().expect("Problem flushing stdout");
}
fn main() {
// Then you can use it like this for formatted strings
cprint(&format!("{}", Color::Blue.paint("Enter array index: "));
// And like this for normal strings
cprint("Enter array index: ");
}
Tho I would recommend termion for terminal colors if you are on linux
cargo install termion
Add termion = "1.5.6" under your dependicies in cargo.toml
use termion::color;
use std::io::Write;
fn cprint(string: &str) {
print!("{}{}",string,color::Fg(color::Reset)); // you dont have to have the reset here, but it makes it easier so you don't have to do color::Reset after everything
std::io::stdout().flush().expect("Problem flushing stdout");
}
fn main() {
cprint(&format!("{}Enter array index: ", color::Fg(color::LightRed)));
// And like this for normal strings
println!("{}Enter array index: ", color::Fg(color::LightRed));
}
Termion makes it easier for multiple colors in the same string
Good luck!

How well does termion play on Windows, though?
Oh termion is not supported at all on windows
π Yeah well
why dont you just... use coloured, this is the entire point of why traits are great
So if your on windows, use what you did before
legit
"foo".blue()
can confirm coloured is amazing
Litterally, it makes excellent use of the fact that you can do blanket impl of traits
Yep that also works
no need to shove an entire terminal UI system for the sake of coloured text lul
but i tried to change it
also for future reference
if you neeeeeeed to write to the stdout without print for what ever reason
use the write! macro
but there is very little reason to do so
π€ Any specific scenario you can provide as an example?
I doubt I'll ever use it ngl
Thanks btw, will note that
I cant really think of any scenario where you would need to, other than possibly writing a TUI framework where you explicitly need to flush stuff at intervals
the commands still do not work
turns out i do not need it
TUI?
turns out portainer lists replicas as separate containers
SyntaxError: 'super' keyword unexpected here
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/YusufIsmail/Documents/GitHub/YusufIsmail_Discord_Bot/bot.js:18:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
you should learn a bit more of js dude
its clear you've been copying stuff from somewhere else without knowing what it does
@autumn rampartBefore you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
Is it possible to use http 3.0 with express?
wat free thing u guys use to keep ur bot online ;-;
none
99% of the time "Free" hoster get you to pay in some indirect way
it may have taken me a bit longer than it should have, but https://i.woo.pics/078fbe334e.webp
@opal plank
you could have asked for help
honestly, just a lot of poking around the docs/code. which i need to get better at anyway
did i self advertisie to you already?
nope
take a look at that
o pog
and still doesnt contain the collector
its like buying a car and telling the guy you have the money, just not with you
No
pretty much no client / server HTTP lib will support HTTP/3 for a while
I mean hell even HTTP/2 support is limited
not entirely sure why you need it though?
to speed up site
How to make bot leave guilds
You don't need HTTP 3 for a good while
thats not how that works 
If you stick anything behind nginx you're stuck with HTTP/1 handling anyway
You could go with /2 but as CF8 said there's limited support
I don't see a reason to completely move away from HTTP/1 yet although we're slowly transitioning away from it
the majority of the http requests made internally are http/1
most http requests from browsers are HTTP/2
but what tends to happen is you get
HTTP/2 or HTTP/3 to Cloudflare, HTTP/1 to your server because people forget they need to enable HTTP/2 support on nginx and apache, then HTTP/1 to any internal app
If you're going with a heavily micro service approach something like Grpc will suite you better than REST setups because you have that underlying HTTP/2 Multiplexing and slightly more efficient data transfer compared to your typical HTTP/1 requests, or zeromq would be another setup but that depends
http 2 allows multiplexing, which could be useful with a site many assets
yes, im aware... And indeed it does offer additional performance boosts.
you're question was HTTP/3 though, and even in HTTP/2's case support for standard clients is limited and people just forget to enable h2 for their reverse proxies etc...
and also like i said, if you are behind a reverse proxy like nginx or apache, it wont proxy via HTTP/2 anyway it jumps down to pipeline http/1 or http/0.9
other than traefik, I think traefik might proxy via http/2 if it can
sed :C
speaking of traefik it supports HTTP/3
Noice except no V1 support yet
Teach me Class and Costructor senpai
classes is just an object
constructor is just a new object

Both wrong 
Classes are functions
Constructors are functions as well
wrong
import class from somewhere
class.thing
clearly an object
and constructors make new objects
new class() // returns {}

Mf, classes are wrapped functions; literally almost everything is treated as an object so you can access their properties, constructors are basically functions that return a new instance when invoked

If we're going with that logic and saying "screw you primitive types", then yes 
i didnt add /s to my sentences, but the
should make it obvious enough lul
I know lul
My PyCharm console doesn't support font colors apparently π
pycharm terminal doesnt by default no
probably
What gives? π€
Pycharm terminal is the same encoding as the windows CMD terminal
so it has a very minimal set of colour encodings
Well, that doesn't help the fact that I ran my project manually via command prompt (where the colors displayed correctly) and in PyCharm terminal it didn't at all
I can provide a video of me running my project with colored both ways
pycharm moment

if you want to fix it
go to
settings -> editor -> colour scheme -> console colours
bro why are u using cmd
I only used it to actually see if it would work outside of PyCharm
cba to use PowerShell ty
who does tbh
π
gitbash ftw
lmfao
ps with ohmyposh is superiorrrrr
Output in txt

Oh boy, got to ownership part in the Rust guide
you're at le biggest hurdle now
I can tell
generally the hurdle is less about learning how to use lifetimes and more about how you structure your code so you rarely need to explicitly deal with them
like well written rust code generally doesnt have many / any explicit lifetimes, they can all be elided / inferred by the compiler
References ftw
Hey guys.
My bot stores character sheets for a tabletop roleplaying game, using a mongodb, and then uses that information to make certain game actions like dice rolls easier for the players. Currently, actually inputting the stats for the character takes a good while, because it's all individual commands for each field.
I'm trying to brainstorm ways to make that process a little easier, and one I've considered is providing a format for a text file that a user could upload with a bot command.
What options are available to prevent metadata and file content attacks? I'm pretty new to this.
You could probably use some specific format for the fields. Say, JSON
use JSON as shiv said since it's probably the most human-readable format, and enforce filesize limit
also validate all values before saving
I had actually already been considering JSON, just wasn't sure if it was the safest way to go. Awesome. Thank you both!
π
You could probably also have some sort of builder for it too for convenience
A website or some kind of a helper that provides the available fields for users, output of which they can copy and paste (in a JSON format)
Ah, alright. That's actually a neat idea. I know even less about building websites, but I'll have to look into that. Thank you
You got this 
did the new discord.py remove all .users() related features?
you refering to 1.x or v2?
1.7.3 to be exact
Doesn't seem so
im raging at something that might be so simple, so my kick command kicks like it should but when i have it try to send the kick message to the user (user being my testing account rn with dms on) it says "cannot send message" ive tried adding this: kickMember.kick(setTimeout[4000]) to try and delay the kick but it wont work.. i seriously cant win
I doubt the setTimeout is supposed to be there
also setTimeout ain't an array to have [4000]
You're supposed to send the message before kicking the user. If it fails, the user doesn't have their DMs enabled
i do have it that way: but it manages to kick the user b4 sending the message
const Discord = require("discord.js")
exports.run = (client, message, args) => {
if (!message.member.hasPermission("ADMINISTRATOR")) {
return message.channel.send(
"Sorry but you do not have permission to `KICK` anyone"
);
}
if (message.mentions.members.size === 0)
return message.reply("Please mention a user to `Kick`");
let reason = args.slice(1).join(' ');
if (!reason) reason = '`None`';
if (reason.length > 1024) reason = reason.slice(0, 1021) + '...';
let guild = message.guild
const kickMember = message.mentions.members.first();
kickMember.send(`You have Been Kicked From ${guild} For ${reason}`)
kickMember.kick(setTimeout[4000]).then(member => {
const embed = new Discord.MessageEmbed()
.setTitle('A Member Has Been Kicked')
.setDescription(`**${member.user.tag}** was successfully Kicked.`)
.addField('Moderator', message.member, true)
.addField('Member', member.user.username, true)
.addField('ID', member.user.id, true)
.addField('Reason', reason)
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor(message.guild.me.displayHexColor);
message.channel.send(embed);
});
};
exports.conf = {
enabled: true,
guildOnly: true
};
so i tired to delay it but it didnt work
kickMember.send(DM).then(kickMember.kick())```
setTimeout(() => console.log("1 minute has passed"), 60_000);
this will print "1 minute has passed" after 1 minute
60_000? lul
ye, thousand separator
do languages actually accept that as a valid int?
yep
oh wow they do
Never seen that before π
me neither
omg
where's IE 
in hell where it belongs
I've been using js for about 13 years and never seen it before
understandable since its relatively new
Literally just read about them today
Today I learned...
I noticed that when intellij started auto-separating big values
Its a thousand separator so you can do 1_000_000 right?
ye
What happens if you do 1_0?
also works
that's just a vanity thing
compiler probably ignores underscores inside numbers
Does it treat the integer as 1_000 or as 10?
Ah
_ is treated like comments
Oh
but you cant do _10
numeric separator operators are hardly used anywhere
neither can you do ._
Yeah I don't really see much point tbh. I've never messed up a value like that
or _.
missing half it's face
they're fine when you're dealing with very big values
I'll stick to old skool
speed of light in meters per second as a bigint
I tried running
sudo mongod --auth --bind_ip ::,0.0.0.0 --logpath /var/log/mongodb.log
and got the output:
{"t":{"$date":"2021-06-28T18:04:43.667Z"},"s":"I", "c":"CONTROL", "id":20697, "ctx":"main","msg":"Renamed existing log file","attr":{"oldLogPath":"/var/log/mongodb.log","newLogPath":"/var/log/mongodb.log.2021-06-28T18-04-43"}}
Is that supposed to happen?
error?
you can probably find more details in the journal logs
try searching for mongo in journalctl
rip ip
hope you dont corrupted the Database file
mmm yeah
mongo lumps a single collection into a single file
so if the file goes everything goes unlike things like mysql and postgres that partition data in 1GB chunks
database files should not be corrupted from service errors
there are several protections in place, the only thing that could cause corruption would be system/disk/power failures
i think Eri or so managed to get a MongoDB installation corrupted
installation yes, not data file, unless you really screw up
its pretty hard to corrupt db files yeah
i know it can happen relatively fast with a bad write bcs of a Power outage, happens frequently on RPIs that are not properly shut down
hm
atleast with MongoDB
yes
so
the database itself will likely not touch the file unless it can be certain that everything is fine
If I understand correctly, I need to properly shut down mongod before trying again?
Ight lend me the lighters gonna light up the computers on fire
did you try the solutions from here? https://stackoverflow.com/questions/53469608/mongo-db-mongodb-service-failed-status-14
painnnnnnn
suffer 
takes freaking ages to build these
have a snickers
im sorry but
@app.post("/render/{template_id:str}", responses={404: {"model": TemplateResponse}})
async def render_template(template_id: str, context: dict = Body(...)):
logger.info(f"rendering template: {template_id} with context: {context!r}")
try:
template = templates.get_template(template_id)
except TemplateNotFound:
return JSONResponse({"template": template_id, "message": "not found"}, status_code=404)
rendered_html = await template.render_async(**context)
render_id = uuid.uuid4()
app.rendered[render_id] = rendered_html
loop = asyncio.get_running_loop()
fut = loop.create_future()
worker = app.workers[0]
app.workers.rotate(1)
worker.events.put_nowait((render_id, fut))
response = await fut
del app.rendered[render_id]
payload = {
"format": "png",
"data": response,
"category": template_id
}
r = await app.session.post(f"{LUST_ADMIN_URL}/admin/create/image", json=payload)
r.raise_for_status()
r_data = json.loads(await r.aread())
file_id = r_data['data']['file_id']
return RenderResponse(
template=template_id,
render=f"{LUST_URL}/{template_id}/{file_id}",
)
how the fuck
does this
just get completely ignored
and shoves some base64 in me
urgggggg
fuck docker compose
msg.channel.send(`first text`).then(setTimeout(() => {
(msg) => msg.edit(`second text`)
}, 3000));``` why this sends the message but doesnt edit it?
looking at that you're not actually giving .then() a callback
nvm its solved
you're immediately scheduling the timeout so .then just gets the handle
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []```
how fix
index.js apparently does no exist
.then(msg => { msg.edit("second text", { timeout: 5000 }) now i have this but it doesnt listen to the timeout how can i fix
Reading from the root of your user directory is concerning
You probably have the wrong directory specified.
does someone know whats wrong
the command i'm trying to do is node index.js
timeout is not a valid option. You should wrap it in a setTimeout.
Then you're probably not in the right directory.
Navigate to your Node.js project directory.
And make sure the file exists
either xwass is trying to steal my computer
Then run that
or its just a normal error
No, you're just running the command wrong.
@timber fractal an example:
message.channel.send("Hello, ").then((msg) => {
setTimeout(() => msg.edit("World!"), 5000);
});
it doesnt
Show your project directory
ah thank u
confused confusion
Do you know JavaScript well?
nope
Then you may want to learn more JavaScript.
that's fascinating
msg.channel.send(`hi`).then(setTimeout((msg) => {msg.edit(`bye`)}, 3500));``` now i have this but it still edits immidately can you help
i did something wrong again right
yes i did
If you want to learn JavaScript, some places are https://learnjavascript.online/ and https://developer.mozilla.org/en-US/docs/Web/JavaScript. If you learn it well, you may not need to throw away your project.
Yes, you did.
If you compare the differences between the example and the code you currently have, you'll notice the anonymous function difference.
So you may want to start there
you're currently scheduling the setTimeout at the same time of calling send not after the message as sent
shoutout to @earnest phoenix for being epic and helping me
- scroll up and you'll see the actual error, which is probably discord.js not index.js
- you didnt install your dependencies
Is anyone able to help me cus Restcord is just giving a guzzel error and i don't know why
@quartz kindle are you able to help?
Why donβt you just send the error?
how can i add a outline to a text using canvas?
ctx.strokeText()```
it's a LONG error
and an image?
Google is your friend
Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\Users\Outdated Cosplay\Documents\Lulu\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:201 Stack trace: #0 C:\Users\Outdated Cosplay\Documents\Lulu\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(155): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\Users\Outdated Cosplay\Documents\Lulu\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(105):``` this is just a tiny bit of tthe error
Stackoverflow is a good place to look for simple questions like that
google doesnt want to give me the anwer
neither stackoverflow
π
Read the docsβ¦
Generate a certificate using openssl and move it into the required folder
Literally both... https://lmgtfy.app/?q=js+canvas+outline+text
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
Trust me it's quicker than asking here and waiting for a reply
And we're not here to spoonfeed
Docs say nothing about this
They do. I used Restcord in the past once, too
Where in the docs?
You can also disable SSL if you donβt wanna use it
$client->setDefaultOption('verify', false);
whats suposed to do
Or generate an unsigned certificate as I said above and specified the path
$client->setDefaultOption('verify', '/path/cacert.pem');
But you will need a certificate anyway since the endpoint is requiring to use SSL
Uncaught Error: Call to undefined method RestCord\DiscordClient::setDefaultOption()
Oh itβs outdated.
$client = new Client(['verify' => '/my/path/mycertfile.pem']);
This should be the latest method
Take a look at the canvas docs on how to use it. Literally just Google "js canvas outline text" and the docs is like one of the first things you'll find
Thank you
The CanvasRenderingContext2D method
strokeText(), part of the Canvas 2D API, strokes β that
is, draws the outlines of β the characters of a text string at the specified
coordinates. An optional parameter allows specifying a maximum width for the rendered
text, which the user agent will achieve by condensing the text or by
using a lower...
i need to outline an image, not a text
apparently the option verify doesn't exist
and i cant find it, so i ask here
Oof also outdated, then take a look into the docs which arguments you can pass
For the border around the image just make a transparent rectangle the same dimensions and position as the image and draw that on top @jovial nexus
"apiUrl", "cacheDir", "guzzleOptions", "logger", "middleware", "rateLimitProvider", "throwOnRatelimit", "token", "tokenType", "version"
I'm getting mongodb connection timeout errors and idk why π¦
it works fine when I try to do it running node on my computer. anyone have any suggestions on how to fix this?
The problem comes from line 37 of your "current.js" file
According to the docs it should exist https://docs.guzzlephp.org/en/stable/request-options.html#verify-option
Which is using that package
Yeah.
Oh wait you mean the mongo error
ye
Looks like you're not connecting to the database?
Do pm2 restart 0 --time to get timestamps on your error logs. It'll help see what happened when.
That's not it. It logs that it's connected.
Well it looks like you're making a request before it connects
Show your code
Well looks like Iβm not to date anymore.
no no the code is correct, I've tested it and the bot works fine running off of node on my laptop.
Ok then
It's connected then
this is what i got after running pm2 restart 0 --time and pm2 logs 0
No timeout errors on launch
Those are old errors in the logs
Notice how there's no timestamp before them?
i see
Those were logged before you restarted the bot using the pm2 command
Thus the reason why you should use timestamps in logging
Take a look at pm2's docs. It has some other useful features
That has nothing to do with mongo or node. It's line 37 in your "current.js" file
Just read the error logs and look at your code
I looked up the error and I'm correct. I have v10 of node, whereas I should have v12+
yes, array.flat() requires node 12+
I made a cog for an aiohttp webserver, how can I pass the client arg into the function?
Py
some good ol' artificial intelligence
yes but where do you start
There are a lot of tools for building artificial intelligence, so I recommend you search them up. I haven't dived into the subject myself.
e.g. TensorFlow
how does that work
For starters, do you know what machine learning and artificial intelligence is?
yes, a bit
I haven't really dived into it too much myself
ML and AI are advantaged topics, so you should do a lot of research online. There's a lot to learn.
Ok, I will!
do you think i'll then have a better understanding on how to actually make one?
with a lot of research and time
I think you'll have a better understanding of the concepts, requirements, and current implementations. ML and AI have been getting more accessible by providers in recent years, but it's all a learning process.
aight cheers
do you have any sources by any chance how you would implement this in a discord bot
youll probably want to learn how machine learning works, and how to use it first.
sure
client.on('guildCreate', guild => {
client.channels.cache.get(logschannel).send(
new MessageEmbed()
.setTitle(New Server!)
.setThumbnail(guild.iconURL())
.setDescription(
`**Server Name**: ${guild.name}\n**Server ID**: ${
guild.id
}\n\n**Server Owner**: ${guild.owner}\n**Server Owner ID**: ${
guild.owner.id
}\n**Server User(s) Count:** ${
guild.memberCount
}\n\nI Am Currently in *${client.guilds.cache.size}* Servers`
)
.setColor('GREEN')
.setTimestamp()
);
});
client.on('guildDelete', guild => {
client.channels.cache.get(logschannel).send(
new MessageEmbed()
.setTitle(Left the Server!)
.setThumbnail(guild.iconURL())
.setDescription(
`**Server Name**: ${guild.name}\n**Server ID**: ${
guild.id}\n\n**Server Owner**: ${guild.owner}\n**Server Owner ID**: ${guild.owner.id}\n**Server User(s) Count:** ${guild.memberCount}\n\nI Am Currently in *${client.guilds.cache.size}* Servers`
)
.setColor('RED')
.setTimestamp()
);
});
is there something wrong what am i doing
pro tip put ``` infront and behind the code
for extra points do
```js
code
```
idk i dont do js 
py?
yes
o
What's your expected and actual output?
Are you not receiving events? (potentially missing intents)
Wait lemme send screenshot
Here, when i invite my bot it does this error
You're trying to access .id on a null value.
Just by scanning your code, I'd have to assume guild.owner is returning null.
Also, when sharing just text, you can just copy and paste it here (at least, the parts that matterβthe unhandled promise rejection warning).
from discord.ext import commands
import discord
class TestCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def guilds(self, ctx):
await ctx.send(f"I am in {len(self.client.guilds)} guilds")
bot.add_cog(TestCog(client))
So here we have the add_cog to the testcog class
We pass the client as a parameter for the class which gets handled in the initialization (init) and creates a class variable with it (self.client)
Then you can use it inside that class with self.client
O
Can u help me
Yeah?
Can u show me how to take a code outta a cmd handler just once
Dunno
I don't know
from discord.ext import commands
import discord
class TestCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def guilds(self, ctx):
await ctx.send(f"I am in {len(self.client.guilds)} guilds")
bot.add_cog(TestCog(client))β
from discord.ext import commands
import discord
class TestCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def guilds(self, ctx):
await ctx.send(f"I am in {len(self.client.guilds)} guilds")
bot.add_cog(TestCog(client))β
client.on('guildCreate', guild => {
client.channels.cache.get(logschannel).send(
new MessageEmbed()
.setTitle(New Server!)
.setThumbnail(guild.iconURL())
.setDescription(
`**Server Name**: ${guild.name}\n**Server ID**: ${
guild.id
}\n\n**Server Owner**: ${guild.owner}\n**Server Owner ID**: ${
guild.owner.id
}\n**Server User(s) Count:** ${
guild.memberCount
}\n\nI Am Currently in *${client.guilds.cache.size}* Servers`
)
.setColor('GREEN')
.setTimestamp()
);
});
client.on('guildDelete', guild => {
client.channels.cache.get(logschannel).send(
new MessageEmbed()
.setTitle(Left the Server!)
.setThumbnail(guild.iconURL())
.setDescription(
`**Server Name**: ${guild.name}\n**Server ID**: ${
guild.id}\n\n**Server Owner**: ${guild.owner}\n**Server Owner ID**: ${guild.owner.id}\n**Server User(s) Count:** ${guild.memberCount}\n\nI Am Currently in *${client.guilds.cache.size}* Servers`
)
.setColor('RED')
.setTimestamp()
);
});
Question mark
How do I run a js file from a different js file?
by requiring/importing it
someone help me? nodejs
I wanted to put an image in the background of another
Jimp in the case...
How would I run a file (spawnsystem.js) if 0 = 0? I did as you said and required spawnsystem.js.js if(0 == 0) runFile();
How do i make my bot run forever?
You need to set it up to a server, I recommend AWS EC2 instance. Once you set it up, install pm2 onto the server and start it.
You mean a discord server?
No, a VPS (virtual private server)
some are
AWS EC2 instance (ubuntu free trial) is free for a year.
there's also heroku, although it doesn't support mongodb.
I need help here 
why do i need the "||1 ==1 || 2==2"?
well actually it's if a variable equals 0
but it's unimportant for the question im asking
Aaaaaaa
I dont wanna pay to have my bot running forever
is there a way to check if the user is in the guild before trying to fetch them?
guild.members.fetch({user: _id})
.fetch should check the cache beforehand.
i want to prevent the fetch call if the member is not in the guild
Paying to keep a robot on forever is stupid
robots are not free
You'd likely need the guild members intent to check the list for the user, or make the .fetch request to see if the user isn't in the guild (by throwing)
dangnabit
just use your computer and convince yourself that you aren't paying for your robot's hosting (hint; you are)
wait, this might be what i'm looking for
https://discord.js.org/#/docs/main/stable/class/GuildMemberManager?scrollTo=resolve
nm
all that does is look through the cache
ash what
You mean a VPS?
A physical server
So a raspberry pi
Then i make the server spam node .
then i guess everyone who owns a successful bot is stupid lol
Node . Is the command that turns the bot on
So if i make the server spam it, it will be on forever
I dont wanna pay
pm2 is free? lol?
Every time the bot goes off-line, the command will make it go on-line again
So yes
I don't think you have a good understanding of what you're talking about. Don't mean to sound rude.
Bro you think i ever made A bot in my life?
This is the first time something i made worked
how do I put Guild shard id on bot's status? (js)
https://cdn.discordapp.com/attachments/272764566411149314/859110515719405568/unknown.png
message is not editing why ?
Not including my health bar script for unity
okay
Well
anyone please ?
I can't figure out how to run a file from another file still. I required it but not sure what to do next. How do I trigger the run?
but in my bot stats command which displays the current shardID is ${message.guild.shardID}
I'm not ignoring it, I simply don't know since I am using eris instead of discord.js. However maybe if you look around through their docs you might understand the problem.
use cache
ok
i cant find it can you send direct link
fetchClientValues
client.on('message', message => {
// ...
if (command === 'stats') {
return client.shard.fetchClientValues('guilds.cache.size')
.then(results => {
return message.channel.send(`Server count: ${results.reduce((acc, guildCount) => acc + guildCount, 0)}`);
})
.catch(console.error);
}
});
thats the command
but I want it on my bot's status
same you need to do same
in your activity field
so what will it look like
can you send in dm your ready.js
ok
then i can know actual things
Or you could send it here, either one!
Hey can someone tell me is there a way to get if the user has voted for you server in last 24 hours with js
Unepic API spam
And this
In fact, you don't even need 2 while loop, you don't even need the client parameter. Context object has bot attribute. But yeah, can't help you more as you're gonna spam the API
oh ok, I'll delete the msg then, but thanks anyways
Sending the code block was fine. It's what the code did that was questionable.
[ERROR][Discord Token]: Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted.
at WebSocketManager.createShards (/home/runner/music/node_modules/discord.js/src/client/websocket/WebSocketManager.js:258:15)
u didnt enable the intent in the discord dev portal
okay
I already enabled it still catches the error
same error
hey im using mysql and the id returned has its last two digits as 00 why ;-; (dunno how to ask)
What package are you using?
wdym
How are you using MySQL?
?
That's the package, yes
you mean the code?
Check this out https://www.npmjs.com/package/mysql#connection-optionsv
it works
on others
const q = "SELECT userId FROM ranking WHERE globalId=595101715485949952 ORDER BY level DESC , currentXP DESC LIMIT 10";
db.query(
q,
(err, rows) => {
if (err) throw err;
message.channel.send(rows[0].userId)
console.log(rows[0].userId)
}
); db.query(console.log) ```
You want big numbers as string as they might go over the maximum safe integer
just not on this one
its set as BIGINT
Log typeof rows[0].userId
?
That number/id is over the max safe integer (hence the 00 at the end)
this?
Yeah but you can fix it by enabling this in MySQL connection options
That turns them into strings to retain the original value
Just like how IDs in discord.js are in strings instead of numbers
anyone can please tell me how can follow a announcement channel by my bot after joins a guild in discord.js
so it should be a string?
Yeah
You need to set those two options to true as manually casting it to a string won't work
thanks alot
Anyone.
You can use use a webhook (https://docs.top.gg/resources/webhooks/#server-webhooks) and store the votes inside a database
I imported guild from Discord and then wrote this code:
async def usercount(ctx, client):
id = client.get_guild(#theIDofServer)
await ctx.channel.send(f"""The server {guild.name} has {id.member_count} members""")
But for some reason when I type >usercount in a Discord chat with my bot, the console says module discord.guild has no attribute name which confuses me because on the api reference documentation, it includes .name as an attribute
(I'm fairly new to python so I'm probably missing something)
oh is that the correct way to reference the server's name?
id would be the guild here (that's what client.get_guild() returns)
oh right, I forgot I had made an id variable
let me try that
right thanks, it worked 
Have you tried Google?
@earnest phoenix give stats command
@bot.command()
async def stats(ctx):
await ctx.send_stats()
``` Thank me later
A sin
At least it's not a cos

you sin cos your mind is that of a fish tan k
I'm surprised they haven't complained about it not working yet
They probably donβt wanna look unsmart
My apologies

@earnest phoenix there's no ready-to-use code for stats in Python
We don't know what you want to display as stats and we're not going to write your code for you
We're here to help, not do your job for you
Oh dear
Your client had a guilds property
Which returns a list of Guild objects
How do you get a length of a list?
Indeed, kind of a bad practice though accessing internals. But w/e 
When executing a slash command e.g. responding with an embed, doesnt the bot need the embed links permission anymore, i just denied him the permission and he's still able to respond
It would be an optimisation... If you wernt messuring the time to do a hundred million iterations where the speed increase is because you're cutting out a couple of getattrs
Didn't I give you the help you neeeded
It's not because of that though. The public property returns a new instance of a list everytime it's called. So, accessing the internals gets the length directly from the mapping which I don't know how better it would be since I'm not at a point to care with all of this, yet.
Looking at the source code it just gives you the same list, its not copying anything.
It is
@property
def guilds(self) :
return self._connection.guilds```
Β―_(γ)_/Β―
I'd prefer it to be a method instead of property, tbh
It makes no sense for it to be a method
Does someone knows the answer to my question? 
The property is their to protect you from invalidating your state
Its just re exporting the private attrs property
It could be a tuple tbh
That's probably the one thing I'd say
Man you be writing a short story
Screw it lmao. I was gonna give a case, but it doesn't seem to be practical. I agree that it's there to protect you from invalidating the state. But, probably it's just personal preference that I'd think it'd make more sense if it's a method instead.

hello i am struggling to chose a algorith to my project
i have a list of items with all of their properties in a array i want to show that items properties if you ask like this What and how much does it cost to craft a Large Wood Box? it doesnt have to be perfect i just want to match items in the text and if they match just send the items's all properties
i thinked about using keywords but i didnt find a way to do that efficently
So Iβm using discord.js in a sharded bot, how do I check if a user has a certain role in a certain guild?
Pls ping me
You can use the REST API instead of relying on cache
have i done something wrong with my embed? i got an error saying its not a function (node:13196) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).setTitle(...).setColor(...).SetDescription is not a function
const Discord = require("discord.js");
exports.run = async (client, message, args) => {
const help = new Discord.MessageEmbed()
.setTitle(`Help`)
.setColor("GREEN")
.SetDescription("Basic Help \nggcommands = Commands \nPrivate Bot For Now Cannot Be Invited")
.setFooter(message.author.displayAvatarURL({dynamic: true}), message.author.username)
.SetTimestamp()
message.author.send(help)
.catch(() => message.channel.send('**Error:** Cannot Message ' + message.author + " Error Message:"`Make Sure Your Dms Are Open`));
}
ohhh i now see i have random capped s's

Heyo.
I added this field line.
.addField("Current Work", `${jobs.find((val) => val.id.toLowerCase() === work.job).name`, true)
.. sometimes, it can be null.. and it won't be able to read the property for .name, I said alright, let's do this.
.addField("Current Work", `${jobs.find((val) => val.id.toLowerCase() === work.job).name || "No Job"}`, true)
.. but YET returning the same error.
(node:19912) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of undefined
.. did I do something wrong?
No.
ehm
Debug, log jobs and work
jobs is an object and work is the document for MongoDB.
Did you log and see the properties? You can never be too sure
I did.
So it may or may not contain the job?
You could use jobs.find()?.name ?? "No Job" to avoid that error
Make sure the job exists before accessing the name property
That's the point.. job is sometimes a string which can return an object to access the property, and sometimes it is null whereas it would return the error.
.. I'm trying to do that if it was null, it would return a string instead.
${jobs.find((val) => val.id.toLowerCase() === work.job).name || "No Job"} doesn't seem to work, though. π
But you can't get property name from null
.. ofcourse, so if so, I don't want it to error, but instead return "No Job".
Hence why I said find()?.name ?? "No Job", that ?.
May I know what you call the ??.
Nullish coalescing operator
You can use that as a substitute for || only for values that are nullish (null and undefined)
The left side returned null, why couldn't I use ||?
?? is just more practical since find() returns either an object or undefined
Oh.
You can, it's just that it couldn't find the job
jobs.find() is undefined
Ah.. I got it now.
?. makes sure that if it's undefined, return undefined instead of trying to access name from it
If not, it would return its original value.
Yeah, if it's falsey
?. makes sure it returns undefined, and ?? performs the right-handed side/code when the left is nulled or undefined.
Correct?
Yes, ?. makes sure it returns the previous value if it's falsey
In this case, undefined
If it's an object (truthy), it'll access the name property
Look up optional chaining
As for the ??, you're correct
Looked it up.. it makes it return undefined instead of an error.
.. but instead, we added the ?? making it put another value instead.
Right?
Yep
Sweet.
You were right, it doesn't return the original value, it returns undefined
π
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = 'p.');
@client.event
async def on_ready();
print("Bot Online")
client.run('token')
error
http://www.nuggy.space/JMnrLH7y β
that's a semicolon, not a colon
first time using py and cant even get bot online
Put : not ;
ima kms
Don't.
Don't
lol
It's a small mistake
Be proud you have the guts to try Python
No we aren't.
lmaooo
god
im too used to js
you use ; not :
thats gonna take some getting used to
: ... instead of { ... }
def some_func(): return True
function someFunc() { return true; }```
You deserve to be hazed if you do if x: pass
Does it point to a different interpreter?
This is my output, meaning that if I run my Python scripts with python, I'll have access to what I installed via pip
How can I redirect an error message like βcommand: <name> failed to run Error: <msg>β
what
?
Do you have C:\Python39?
ill look
Well, not drive, just a folder (directory)
Why do you have that folder in the first place?
wait what folder
Python39
You could technically just remove it from your PATH
As to whether delete it or not is up to you but you don't even seem to use it since it doesn't even have pip installed π€£
Nah
I'd suggest removing the folder from your PATH too
i deleted both those
and now its working fine
Yeah, I suggest removing them from your PATH too
how do i do that as well
Google β¨
true
"how to remove a folder from path"
π
Does anyone know any alternative of Python's turtle module for Rust?
Specifically something that lets me output the canvas without having to save it locally
π
That looks like what I could use
There's https://github.com/sunjay/turtle, but it just opens a window for the drawing.
That's pretty much the behavior I wanted, sort of
It's close enough so it's fine, thanks π
I have some problems with canvas, does someone know whats wrong?
Canvas.registerFont("./fonts/TTNorms-BlackItalic.otf", { family: "TT Norms" });
ctx.font = '115px TT Norms';








