#development

1 messages Β· Page 1795 of 1

latent heron
#

probably something related with the stdin::read_line library

#

look you're famous now @crimson vapor

solar cave
#

Can we update bot which is on top.gg?

slender thistle
#

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

opaque seal
#

is that 4k?

earnest phoenix
#

is the thick side-bar a intention?

#

Maybe try flushing before reading the line to ensure it's printed out?

slender thistle
#

Not sure that's the cause, but I'll pong you with a result once I'm done consuming POTATOES

latent heron
#

no, its 1080p

crimson vapor
earnest phoenix
#

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 bloblul

eternal elbow
#

Normally these buttons should point to google but they do nothing, what could be the problem (Visual Studio Code - CodeTime Extension)

elfin fjord
#

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

slender thistle
#

Nah

elfin fjord
#

oh

slender thistle
#

You don't define discord.py objects per se. You're supposed to get them via various methods

elfin fjord
#

πŸ€”

autumn rampart
#
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

Gist

GitHub Gist: instantly share code, notes, and snippets.

Gist

GitHub Gist: instantly share code, notes, and snippets.

elfin fjord
#

I'm kinda trying discord.Guild.members() but it's not working :/

autumn rampart
#

i did

near stratus
slender thistle
#

discord.Guild can be received via Client.get_guild, Client.guilds, or whatever other methods return it

quartz kindle
autumn rampart
#

i am

quartz kindle
#

you dont use it anywhere in bot.js?

slender thistle
autumn rampart
#

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

elfin fjord
# slender thistle discord.Guild can be received via `Client.get_guild`, `Client.guilds`, or whatev...

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

slender thistle
#

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.

elfin fjord
slender thistle
#

message = discord.Message(...)

#

Does this tell you anything

elfin fjord
#

oh

slender thistle
#

You don't want the class (Message), but an instance of it, which is stored in a variable message

elfin fjord
#

but on_message(message) takes message as input. Is that the same message?

slender thistle
#

In your case, yes. It's a parameter that you use

elfin fjord
#

oh ok

#

so message.guild

autumn rampart
slender thistle
elfin fjord
#

ooh ok!

#

ty ^.^

slender thistle
#

πŸ‘

sly sierra
#

How could i change the color of these objects

rose warren
sly sierra
#

I know, How could i change the color of those what are they called etc KL1Sleep

#

I don't need code

rose warren
#

I don't understand what you mean then... πŸ€”

#

CSS is how to change the color. Take the class from the html element.

sly sierra
rose warren
#

Yes

sly sierra
#

Ah thank you

rose warren
#

No problem! 😊

sly sierra
rose warren
#

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.

rose warren
#

You can design for light / dark by getting the selected theme from the <html> wrapper

zenith fiber
#

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'

opal plank
# zenith fiber TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type functi...

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!

rose warren
#

Show your code

zenith fiber
#

Just for fun

zinc wharf
zenith fiber
#

I am learning

opal plank
#

its not about money

#

you dont start learning with a bot

zenith fiber
#

Yes I don't care

#

Mmh?

opal plank
#

and show your code

slender thistle
opal plank
#

we arent magicians

zenith fiber
#

This is develpment...

opal plank
#

oh, right

rose warren
opal plank
#

wait what

zinc wharf
opal plank
#

now this is weird

#

if i to go #general , go to another server, and come back, it defaults me to here

slender thistle
#

LMFAO

solemn latch
#

o weird

rose warren
#

They posted in #support too @opal plank you're not going crazy don't worry

slender thistle
#

You're Tim v2

lusty quest
opal plank
#

this is what i get for instinctively replying to stuff without checking

autumn rampart
#

/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

solemn latch
autumn rampart
#

ok

quartz kindle
#

you're still not using commando

#

client.registry is for commando, you're not using it

#

and Structures is inside Discord

autumn rampart
#

so do i delete commando

#

i am adding a discord command

quartz kindle
#

if you want to use commando, then use it properly

#

follow the docs

autumn rampart
#

i was using it

#

i am not using it know

quartz kindle
#

if you're not using it then remove it completely

opal plank
#

what the fok

#

discord js endorses commando?

solemn latch
#

i thought they made commando πŸ‘€

opal plank
#

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?

solemn latch
#

πŸ‘€ i still need to figure out buttons with detritus.

opal plank
#

need help?

solemn latch
#

i'm sure its in the support server somewhere i think i can figure it out

opal plank
#

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

latent heron
#

are you learning rust now? @slender thistle

slender thistle
#

Mhm

latent heron
#

pog

slender thistle
#

It's fun

latent heron
#

that makes two of us

#

wanna join my project?

slender thistle
#

What kind of project lmfao cuz I'm like

latent heron
#

fl0w.space

#

the chatroom backend is being written in Rust

slender thistle
#

Oh yeah no

#

hold on

opal plank
#

@solemn latch how is it treating u?

slender thistle
#

I don't think I'm ready to do backends lmfao

latent heron
#

sadge

#

lmk if you wanna help though

autumn rampart
#

so my bot works but the music commands does not work

slender thistle
#

πŸ‘

autumn rampart
slender thistle
#

Why are you sending these here

autumn rampart
#

they are code

#

i need help

slender thistle
#

What's the issue you're having, again?

autumn rampart
#

My music command does not work

latent heron
#

they already gave you an answer

#

remove them completely if you're not going to

autumn rampart
#

?

latent heron
#

re-asking the same question isn't going to suddenly give you a different answer

autumn rampart
#

one sec

#

const { CommandoClient } = require('discord.js-commando');

opal plank
#

thats not how it works

autumn rampart
#

I am using it

opal plank
#

tim sent u the code

#

its Client()

autumn rampart
#

ok

#

changed it

opal plank
#

pls tell me u didnt do what i think you did

#

show me ur code

boreal iron
#

_let’s hope Erwin isn’t getting a heart attack _

autumn rampart
#

ok

#

one sec

wheat mesa
#

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.

opal plank
#

i sure am

earnest phoenix
autumn rampart
#

I am fixing some stuff

slender thistle
#

I didn't get to that part yet

#

Thanks for noting it though πŸ‘€

earnest phoenix
# slender thistle ```rs // Print out text for user print!("{}", Color::Blue.paint("Enter a...

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!

modest maple
#

zoomeyes Do i see rust

#

what is happening herer

earnest phoenix
slender thistle
#

How well does termion play on Windows, though?

earnest phoenix
#

Oh termion is not supported at all on windows

slender thistle
#

πŸ˜‚ Yeah well

modest maple
#

why dont you just... use coloured, this is the entire point of why traits are great

earnest phoenix
#

So if your on windows, use what you did before

modest maple
#

legit

#

"foo".blue()

cinder patio
#

can confirm coloured is amazing

modest maple
#

Litterally, it makes excellent use of the fact that you can do blanket impl of traits

earnest phoenix
#

Yep that also works

autumn rampart
#

the commands still do not work

#

turns out i do not need it

modest maple
#

no need to shove an entire terminal UI system for the sake of coloured text lul

autumn rampart
#

but i tried to change it

slender thistle
#

Oh, huh

#

Neat

#

Thanks

modest maple
#

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

slender thistle
#

πŸ€” Any specific scenario you can provide as an example?

#

I doubt I'll ever use it ngl

modest maple
#

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

autumn rampart
#

the commands still do not work
turns out i do not need it

slender thistle
#

TUI?

modest maple
#

generally know as a Terminal UI

#

or Text UI

slender thistle
#

Ah

#

Thanks

#

This is gonna be a fun ride

modest maple
#

turns out portainer lists replicas as separate containers

autumn rampart
#

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)

opal plank
#

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!

earnest phoenix
#

Is it possible to use http 3.0 with express?

inner fulcrum
#

wat free thing u guys use to keep ur bot online ;-;

copper cradle
#

none

lusty quest
#

99% of the time "Free" hoster get you to pay in some indirect way

solemn latch
solemn latch
#

honestly, just a lot of poking around the docs/code. which i need to get better at anyway

opal plank
#

did i self advertisie to you already?

solemn latch
#

nope

opal plank
#

take a look at that

solemn latch
#

o pog

opal plank
#

its well commented

#

should give you a DECENT******************* template to work with

lusty quest
#

and still doesnt contain the collector

opal plank
#

πŸ‘€

#

i swear i have the code, its just not there, yet

lusty quest
#

its like buying a car and telling the guy you have the money, just not with you

opal plank
#

exactly

modest maple
#

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?

earnest phoenix
#

to speed up site

lament surge
#

How to make bot leave guilds

latent heron
#

You don't need HTTP 3 for a good while

modest maple
latent heron
#

^

#

Also that's not how HTTP protocol really functions

modest maple
#

If you stick anything behind nginx you're stuck with HTTP/1 handling anyway

latent heron
#

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

modest maple
#

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

earnest phoenix
modest maple
#

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

earnest phoenix
#

sed :C

modest maple
#

speaking of traefik it supports HTTP/3 zoomeyes Noice except no V1 support yet

long crow
opal plank
pure lily
#

how do I put Guild shard id on bot's status?

#

and yes I already sharded my bot

earnest phoenix
opal plank
#

and constructors make new objects

#

new class() // returns {}

earnest phoenix
opal plank
#

cannot compete with my big brain

#

give up, i have the high ground

earnest phoenix
#

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

opal plank
#

if everything is treated as an object, therefore its an object

earnest phoenix
#

If we're going with that logic and saying "screw you primitive types", then yes DogKek

opal plank
#

i didnt add /s to my sentences, but the mmulu should make it obvious enough lul

earnest phoenix
#

I know lul

light dew
#

Hellou

slender thistle
#

My PyCharm console doesn't support font colors apparently 😎

modest maple
#

pycharm terminal doesnt by default no

slender thistle
#

Ok so colored doesn't seem to work with it

#

and ansi_term does

modest maple
#

probably

slender thistle
#

What gives? πŸ€”

modest maple
#

Pycharm terminal is the same encoding as the windows CMD terminal

#

so it has a very minimal set of colour encodings

slender thistle
#

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

modest maple
#

pycharm moment

slender thistle
modest maple
#

if you want to fix it

#

go to

#

settings -> editor -> colour scheme -> console colours

slender thistle
#

Fucking around with the scheme there, yeah

#

colored

#

ansi_term

woeful pike
#

bro why are u using cmd

slender thistle
#

I only used it to actually see if it would work outside of PyCharm

modest maple
#

because CMD is the obvious superior shell

#

despite windows best efforts

slender thistle
#

cba to use PowerShell ty

modest maple
#

who does tbh

slender thistle
#

πŸ˜‚

modest maple
#

gitbash ftw

slender thistle
#

lmfao

vivid fulcrum
#

ps with ohmyposh is superiorrrrr

slender thistle
#

Output in txt

modest maple
slender thistle
#

Oh boy, got to ownership part in the Rust guide

modest maple
#

you're at le biggest hurdle now

slender thistle
#

I can tell

modest maple
#

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

slender thistle
#

References ftw

finite flume
#

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.

slender thistle
#

You could probably use some specific format for the fields. Say, JSON

lyric mountain
#

also validate all values before saving

finite flume
#

I had actually already been considering JSON, just wasn't sure if it was the safest way to go. Awesome. Thank you both!

slender thistle
#

πŸ‘

#

You could probably also have some sort of builder for it too for convenience

finite flume
#

How do you mean?

#

or, rather, "What's a builder?"

slender thistle
#

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)

finite flume
#

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

slender thistle
#

You got this topggThumbsUp

south mulch
#

did the new discord.py remove all .users() related features?

modest maple
#

you refering to 1.x or v2?

south mulch
#

1.7.3 to be exact

slender thistle
#

Doesn't seem so

onyx hare
#

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

slender thistle
#

I doubt the setTimeout is supposed to be there

lyric mountain
#

also setTimeout ain't an array to have [4000]

slender thistle
#

You're supposed to send the message before kicking the user. If it fails, the user doesn't have their DMs enabled

onyx hare
#

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

lyric mountain
#

setTimeout is not an array

#

and it doesn't work like that

rose warren
lyric mountain
#
setTimeout(() => console.log("1 minute has passed"), 60_000);

this will print "1 minute has passed" after 1 minute

quartz kindle
#

60_000? lul

lyric mountain
#

ye, thousand separator

quartz kindle
#

do languages actually accept that as a valid int?

lyric mountain
#

yep

quartz kindle
#

oh wow they do

rose warren
#

Never seen that before πŸ‘€

quartz kindle
#

me neither

lyric mountain
#

omg

sudden geyser
#

sadly underused

quartz kindle
#

its quite new actually

#

in js

lyric mountain
#

where's IE KEKW

quartz kindle
#

in hell where it belongs

rose warren
#

I've been using js for about 13 years and never seen it before

quartz kindle
#

understandable since its relatively new

slender thistle
#

Literally just read about them today

rose warren
#

Today I learned...

lyric mountain
#

I noticed that when intellij started auto-separating big values

rose warren
#

Its a thousand separator so you can do 1_000_000 right?

quartz kindle
#

ye

slender thistle
#

What happens if you do 1_0?

lyric mountain
#

also works

#

that's just a vanity thing

#

compiler probably ignores underscores inside numbers

slender thistle
#

Does it treat the integer as 1_000 or as 10?

quartz kindle
slender thistle
#

Ah

lyric mountain
#

_ is treated like comments

rose warren
#

Oh

lyric mountain
#

but you cant do _10

earnest phoenix
#

numeric separator operators are hardly used anywhere

quartz kindle
#

neither can you do ._

rose warren
#

Yeah I don't really see much point tbh. I've never messed up a value like that

quartz kindle
#

or _.

sudden geyser
#

missing half it's face

lyric mountain
#

they're fine when you're dealing with very big values

rose warren
#

I'll stick to old skool

quartz kindle
#

speed of light in meters per second as a bigint

earnest phoenix
#

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?

lyric mountain
#

probably

#

that looks like a log output

earnest phoenix
#

ok

#

@lyric mountainoh shoot, now I can't start mongodb.

lyric mountain
#

error?

earnest phoenix
lyric mountain
quartz kindle
#

you can probably find more details in the journal logs

#

try searching for mongo in journalctl

earnest phoenix
#

rip ip

lusty quest
#

hope you dont corrupted the Database file

modest maple
#

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

quartz kindle
#

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

lusty quest
#

i think Eri or so managed to get a MongoDB installation corrupted

quartz kindle
#

installation yes, not data file, unless you really screw up

modest maple
#

its pretty hard to corrupt db files yeah

lusty quest
#

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

earnest phoenix
#

hm

lusty quest
#

atleast with MongoDB

quartz kindle
#

yes

earnest phoenix
#

so

quartz kindle
#

the database itself will likely not touch the file unless it can be certain that everything is fine

earnest phoenix
# lyric mountain

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

quartz kindle
modest maple
#

painnnnnnn

sudden geyser
#

suffer IruSmile

modest maple
#

takes freaking ages to build these

earnest phoenix
#

Crunchy

#

Now I'm hungry, dang it!

sudden geyser
#

have a snickers

modest maple
#

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

timber fractal
#
msg.channel.send(`first text`).then(setTimeout(() => {
            (msg) => msg.edit(`second text`)
        }, 3000));``` why this sends the message but doesnt edit it?
modest maple
#

looking at that you're not actually giving .then() a callback

modest maple
#

you're immediately scheduling the timeout so .then just gets the handle

hidden nacelle
#
    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

modest maple
#

index.js apparently does no exist

timber fractal
#

.then(msg => { msg.edit("second text", { timeout: 5000 }) now i have this but it doesnt listen to the timeout how can i fix

sudden geyser
hidden nacelle
#

wdym

#

why

sudden geyser
#

You probably have the wrong directory specified.

timber fractal
hidden nacelle
#

the command i'm trying to do is node index.js

sudden geyser
sudden geyser
#

Navigate to your Node.js project directory.

#

And make sure the file exists

hidden nacelle
#

either xwass is trying to steal my computer

sudden geyser
#

Then run that

hidden nacelle
#

or its just a normal error

sudden geyser
#

No, you're just running the command wrong.

hidden nacelle
#

uh

#

you told me to check if index.js exists right?

sudden geyser
#

@timber fractal an example:

message.channel.send("Hello, ").then((msg) => {
  setTimeout(() => msg.edit("World!"), 5000);
});
hidden nacelle
#

it doesnt

sudden geyser
#

Show your project directory

hidden nacelle
sudden geyser
#

Do you know JavaScript well?

hidden nacelle
#

nope

sudden geyser
#

Then you may want to learn more JavaScript.

hidden nacelle
#

wait

#

i think its bc i deleted all my bot stuff

#

bc i got mad it wouldnt work

sudden geyser
#

that's fascinating

timber fractal
#
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

sudden geyser
sudden geyser
#

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

modest maple
#

you're currently scheduling the setTimeout at the same time of calling send not after the message as sent

timber fractal
#

worked tysm

hidden nacelle
#

shoutout to @earnest phoenix for being epic and helping me

quartz kindle
#
  1. scroll up and you'll see the actual error, which is probably discord.js not index.js
#
  1. you didnt install your dependencies
ornate otter
#

Is anyone able to help me cus Restcord is just giving a guzzel error and i don't know why

ornate otter
#

@quartz kindle are you able to help?

boreal iron
#

Why don’t you just send the error?

jovial nexus
#

how can i add a outline to a text using canvas?

rose warren
ornate otter
#

it's a LONG error

jovial nexus
rose warren
#

Google is your friend

ornate otter
#
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
rose warren
jovial nexus
#

neither stackoverflow

#

πŸ˜”

boreal iron
rose warren
#

Trust me it's quicker than asking here and waiting for a reply

#

And we're not here to spoonfeed

boreal iron
#

They do. I used Restcord in the past once, too

ornate otter
#

Where in the docs?

boreal iron
#

You can also disable SSL if you don’t wanna use it

#

$client->setDefaultOption('verify', false);

ornate otter
#

There's no mention of SSL in the docs tho-

#

that i can see at least

jovial nexus
boreal iron
#

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

ornate otter
#

Uncaught Error: Call to undefined method RestCord\DiscordClient::setDefaultOption()

boreal iron
#

Oh it’s outdated.

#

$client = new Client(['verify' => '/my/path/mycertfile.pem']);

This should be the latest method

rose warren
# jovial nexus whats suposed to do

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

ornate otter
#

Thank you

rose warren
# jovial nexus whats suposed to do

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...

jovial nexus
#

i need to outline an image, not a text

ornate otter
jovial nexus
#

and i cant find it, so i ask here

boreal iron
#

Oof also outdated, then take a look into the docs which arguments you can pass

rose warren
#

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

ornate otter
#

"apiUrl", "cacheDir", "guzzleOptions", "logger", "middleware", "rateLimitProvider", "throwOnRatelimit", "token", "tokenType", "version"

earnest phoenix
#

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?

rose warren
boreal iron
ornate otter
#

Oh

#

I think we were looking at two different docs

#

i was looking at restcord docs

boreal iron
#

Which is using that package

ornate otter
#

Yeah.

earnest phoenix
#

hm?

#

so

rose warren
#

Oh wait you mean the mongo error

earnest phoenix
#

ye

rose warren
#

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.

earnest phoenix
rose warren
#

Show your code

boreal iron
earnest phoenix
earnest phoenix
rose warren
#

It's connected then

earnest phoenix
#

this is what i got after running pm2 restart 0 --time and pm2 logs 0

rose warren
#

No timeout errors on launch

#

Those are old errors in the logs

#

Notice how there's no timestamp before them?

earnest phoenix
#

i see

rose warren
#

Those were logged before you restarted the bot using the pm2 command

#

Thus the reason why you should use timestamps in logging

earnest phoenix
#

ah.

#

ooof

#

still not working

rose warren
#

Take a look at pm2's docs. It has some other useful features

earnest phoenix
#

nani

#

I tried using a mongodb command

#

hm, maybe i should try updating node

rose warren
#

Just read the error logs and look at your code

earnest phoenix
quartz kindle
#

yes, array.flat() requires node 12+

earnest phoenix
#

how would you go about making a chat bot?

#

how do you learn it what to say?

drifting wedge
#

I made a cog for an aiohttp webserver, how can I pass the client arg into the function?

#

Py

sudden geyser
earnest phoenix
sudden geyser
#

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

earnest phoenix
sudden geyser
#

For starters, do you know what machine learning and artificial intelligence is?

earnest phoenix
#

I haven't really dived into it too much myself

sudden geyser
#

ML and AI are advantaged topics, so you should do a lot of research online. There's a lot to learn.

earnest phoenix
#

Ok, I will!

#

do you think i'll then have a better understanding on how to actually make one?

solemn latch
#

with a lot of research and time

sudden geyser
#

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.

earnest phoenix
#

aight cheers

#

do you have any sources by any chance how you would implement this in a discord bot

solemn latch
#

youll probably want to learn how machine learning works, and how to use it first.

placid iron
#

so..

#

is there any way to get a slash command "author" in discord.py

earnest phoenix
#
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

placid iron
#

pro tip put ``` infront and behind the code
for extra points do
```js
code
```

earnest phoenix
#

there

#

am i doing something wrong

placid iron
#

idk i dont do js OmegaKEKW

earnest phoenix
#

py?

placid iron
#

yes

earnest phoenix
#

o

sudden geyser
#

Are you not receiving events? (potentially missing intents)

earnest phoenix
earnest phoenix
sudden geyser
#

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

earnest phoenix
#

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

earnest phoenix
earnest phoenix
earnest phoenix
#

Dunno

#

I don't know

earnest phoenix
#
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()
    );
});
sudden geyser
#

Question mark

earnest phoenix
#

How do I run a js file from a different js file?

sudden geyser
#

by requiring/importing it

clever agate
#

someone help me? nodejs

#

I wanted to put an image in the background of another

#

Jimp in the case...

earnest phoenix
hidden nacelle
#

How do i make my bot run forever?

earnest phoenix
hidden nacelle
#

You mean a discord server?

earnest phoenix
hidden nacelle
#

?????

#

Is that free

earnest phoenix
#

some are

#

AWS EC2 instance (ubuntu free trial) is free for a year.

#

there's also heroku, although it doesn't support mongodb.

earnest phoenix
#

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

hidden nacelle
#

I dont wanna pay to have my bot running forever

proven lantern
#

is there a way to check if the user is in the guild before trying to fetch them?
guild.members.fetch({user: _id})

sudden geyser
#

.fetch should check the cache beforehand.

proven lantern
#

i want to prevent the fetch call if the member is not in the guild

hidden nacelle
#

Paying to keep a robot on forever is stupid

proven lantern
#

robots are not free

sudden geyser
#

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)

proven lantern
#

dangnabit

sudden geyser
proven lantern
#

nm

sudden geyser
#

all that does is look through the cache

hidden nacelle
#

What if

#

I buy a server

earnest phoenix
#

ash what

hidden nacelle
#

Not a discord server

#

Like an actual server

earnest phoenix
#

You mean a VPS?

hidden nacelle
#

A physical server

sudden geyser
#

So a raspberry pi

hidden nacelle
#

Then i make the server spam node .

earnest phoenix
earnest phoenix
#

just use pm2 lol

hidden nacelle
#

Node . Is the command that turns the bot on

#

So if i make the server spam it, it will be on forever

earnest phoenix
#

uh

#

no?

hidden nacelle
earnest phoenix
hidden nacelle
#

So yes

earnest phoenix
#

I don't think you have a good understanding of what you're talking about. Don't mean to sound rude.

hidden nacelle
#

This is the first time something i made worked

pure lily
sudden geyser
#

just grab the current shard in your source code

#

the library you're using may help

bright thorn
#

message is not editing why ?

hidden nacelle
earnest phoenix
#

Well

earnest phoenix
#

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?

pure lily
earnest phoenix
# bright thorn anyone please ?

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.

pure lily
#

so i can do it by my own

bright thorn
pure lily
pure lily
bright thorn
#

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);
    }
});
pure lily
#

but I want it on my bot's status

bright thorn
#

in your activity field

pure lily
bright thorn
pure lily
bright thorn
#

then i can know actual things

wheat mesa
#

Or you could send it here, either one!

gaunt ermine
#

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

earnest phoenix
#

Unepic API spam

#

oh am I not allowed to send code large blocks of code in here?

pale vessel
#

Unepic API spam

earnest phoenix
#

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

sudden geyser
pure lily
#

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

errant flax
pure lily
#

same error

errant flax
#

maybe go to the djs server

#

and ask there noobthonk

hallow mango
#

hey im using mysql and the id returned has its last two digits as 00 why ;-; (dunno how to ask)

pale vessel
#

What package are you using?

hallow mango
#

wdym

pale vessel
#

How are you using MySQL?

hallow mango
pale vessel
#

That's the package, yes

hallow mango
#

you mean the code?

pale vessel
hallow mango
#

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) ```
pale vessel
#

You want big numbers as string as they might go over the maximum safe integer

hallow mango
#

just not on this one

pale vessel
#

Log typeof rows[0].userId

hallow mango
pale vessel
#

That number/id is over the max safe integer (hence the 00 at the end)

hallow mango
pale vessel
#

That turns them into strings to retain the original value

#

Just like how IDs in discord.js are in strings instead of numbers

bright thorn
#

anyone can please tell me how can follow a announcement channel by my bot after joins a guild in discord.js

hallow mango
pale vessel
#

Yeah

#

You need to set those two options to true as manually casting it to a string won't work

hallow mango
#

thanks alot

pale vessel
earnest phoenix
#

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)

pale vessel
#

What would guild be?

#

Perhaps you meant to use id.name?

earnest phoenix
#

oh is that the correct way to reference the server's name?

pale vessel
#

id would be the guild here (that's what client.get_guild() returns)

earnest phoenix
#

oh right, I forgot I had made an id variable

#

let me try that

#

right thanks, it worked topggHappy

rose warren
#

Have you tried Google?

pale vessel
#

@earnest phoenix give stats command

earnest phoenix
pale vessel
#

@earnest phoenix

#

yes

#

That's python

#

Np!

#

What have I done

earnest phoenix
#

A sin

pale vessel
#

At least it's not a cos

earnest phoenix
slender thistle
#

you sin cos your mind is that of a fish tan k

copper cradle
#

I'm surprised they haven't complained about it not working yet

earnest phoenix
#

They probably don’t wanna look unsmart

pale vessel
#

My apologies

copper cradle
slender thistle
#

@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?

earnest phoenix
#

Micro-optimization bloblul

#

Should've sent this instead exdee

restive furnace
#

not nearly a micro optimization

#

its a optimization imo

earnest phoenix
#

Indeed, kind of a bad practice though accessing internals. But w/e mmLol

slender thistle
#

Lmfao what

#

That's fun

small tangle
#

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

modest maple
slender thistle
#

Didn't I give you the help you neeeded

earnest phoenix
modest maple
earnest phoenix
#

It's casting the values of the mapping to a list

#

They're not identical

modest maple
#

Not in the property handle though

#

The source for the property is

earnest phoenix
#

It is

modest maple
#
@property
def guilds(self) :
   return self._connection.guilds```
earnest phoenix
#

Β―_(ツ)_/Β―

#

I'd prefer it to be a method instead of property, tbh

modest maple
#

It makes no sense for it to be a method

small tangle
#

Does someone knows the answer to my question? imshy

modest maple
#

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

earnest phoenix
#

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.

modest maple
clear marlin
#

no idea mate..........................

#

?

wary swan
#

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

viral timber
#

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

pale vessel
#

You can use the REST API instead of relying on cache

deft lotus
#

how to invite team member in top.gg team

onyx hare
#

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`));

}
pale vessel
#

Method names are case-sensitive

#

They're usually in camel case, like setTitle()

onyx hare
#

ohhh i now see i have random capped s's

pale vessel
feral aspen
#

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?

tame sapphire
#

you need a }

#

at the end

#

wait

#

no

#

xd

feral aspen
#

No.

tame sapphire
#

ehm

pale vessel
#

Debug, log jobs and work

feral aspen
#

jobs is an object and work is the document for MongoDB.

pale vessel
#

Did you log and see the properties? You can never be too sure

feral aspen
#

I did.

pale vessel
#

So it may or may not contain the job?

deft lotus
#

how to invite team member in top.gg team

pale vessel
#

You could use jobs.find()?.name ?? "No Job" to avoid that error

#

Make sure the job exists before accessing the name property

feral aspen
#

.. 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. 😐

pale vessel
#

But you can't get property name from null

feral aspen
#

.. ofcourse, so if so, I don't want it to error, but instead return "No Job".

pale vessel
#

Hence why I said find()?.name ?? "No Job", that ?.

feral aspen
#

May I know what you call the ??.

pale vessel
#

Nullish coalescing operator

#

You can use that as a substitute for || only for values that are nullish (null and undefined)

feral aspen
#

Ohh..

#

.. when can I use || then, as an example?

pale vessel
#

You can use || in this context

#

Since null is falsey

feral aspen
#

The left side returned null, why couldn't I use ||?

pale vessel
#

?? is just more practical since find() returns either an object or undefined

feral aspen
#

Oh.

pale vessel
#

jobs.find() is undefined

feral aspen
#

Ah.. I got it now.

pale vessel
#

?. makes sure that if it's undefined, return undefined instead of trying to access name from it

feral aspen
#

If not, it would return its original value.

pale vessel
#

Yeah, if it's falsey

feral aspen
#

?. makes sure it returns undefined, and ?? performs the right-handed side/code when the left is nulled or undefined.

#

Correct?

pale vessel
#

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

feral aspen
#

Looked it up.. it makes it return undefined instead of an error.

#

.. but instead, we added the ?? making it put another value instead.

#

Right?

pale vessel
#

Yep

feral aspen
#

Sweet.

pale vessel
#

You were right, it doesn't return the original value, it returns undefined

feral aspen
#

πŸ‘

quiet pawn
#
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 ​

slender thistle
#

that's a semicolon, not a colon

quiet pawn
#

first time using py and cant even get bot online

feral aspen
#

Put : not ;

quiet pawn
#

ima kms

feral aspen
#

Don't.

slender thistle
#

Don't

quiet pawn
#

lol

feral aspen
#

Instead, be proud.

#

πŸ˜‚

#

You're learning daily.

slender thistle
#

It's a small mistake

quiet pawn
#

your kidding

#

that fixed it

pale vessel
#

Be proud you have the guts to try Python

feral aspen
#

No we aren't.

quiet pawn
#

lmaooo

#

god

#

im too used to js

#

you use ; not :

#

thats gonna take some getting used to

pale vessel
#

: ... instead of { ... }

feral aspen
#

We use it in switch statements, but alright. πŸ€·β€β™‚οΈ

#

.. for case "case": .

feral aspen
#

I don't put the : at all.

pale vessel
#
def some_func(): return True

function someFunc() { return true; }```
slender thistle
#

You deserve to be hazed if you do if x: pass

quiet pawn
#

wait am i installing discord py right

#

pip install discord.py

slender thistle
#

Yeah

#

Do pip -V

quiet pawn
#

im on 3.9

#

o wait

#

21.1.3

slender thistle
#

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

quiet pawn
#

o

#

1 sec

#

ill do same thing

#

and show

#

weird

onyx hare
#

How can I redirect an error message like β€œcommand: <name> failed to run Error: <msg>”

slender thistle
#

what

quiet pawn
#

?

slender thistle
#

Why-

#

Did you install Python in a separate directory?

quiet pawn
#

nah

#

its on main drive

slender thistle
#

Do you have C:\Python39?

quiet pawn
#

i install all programs on ssd

#

and games and other shit on a hdd

quiet pawn
slender thistle
#

Well, not drive, just a folder (directory)

quiet pawn
#

yes

#

i have it

#

ignor edrives name

#

its been that for years

slender thistle
#

Why do you have that folder in the first place?

quiet pawn
#

idk

#

it just

#

added it seld

#

i have 2

quiet pawn
slender thistle
#

Python39

quiet pawn
#

idk

#

i didnt add it my self

#

should i delete it?

slender thistle
#

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 🀣

quiet pawn
#

wait

#

is it why my bot isnt starting

#

im confused

slender thistle
#

Nah

quiet pawn
#

welp

#

i deleted it

#

and now my bots online

#

no errors

slender thistle
#

I'd suggest removing the folder from your PATH too

quiet pawn
#

and now its working fine

slender thistle
#

Not from your computer

#

You deleted it in your system variables?

quiet pawn
#

i just high lighted the folders

#

and pressed delete

slender thistle
#

Yeah, I suggest removing them from your PATH too

quiet pawn
#

how do i do that as well

slender thistle
#

Google ✨

quiet pawn
#

true

slender thistle
#

"how to remove a folder from path"

quiet pawn
#

pog ill do that

#

thankj you for the help as well

slender thistle
#

πŸ‘

hard vortex
#

Hello

#

Pls help

#

Me

#

How to use vote command on discord.js

#

Bot

slender thistle
#

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

sudden geyser
slender thistle
#

That's pretty much the behavior I wanted, sort of

#

It's close enough so it's fine, thanks πŸ‘

jovial nexus
#

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';