#development

1 messages ยท Page 758 of 1

modest maple
#

xD

#

and like

lusty dew
#

Why not just have 2

modest maple
#

%s is supposed to mean its being formatted as a string, but if its using datetime what comes after the % doesnt matter

lusty dew
#

Although isn't there many ways to format a string in js as well

modest maple
#

like some things are just odd in python

#

but its not as bad as clojure's VARIBLES actually being constants

lusty dew
#
async def find_one(client, table, cond, col):
    cursor = await client.db.cursor()
    if table in table_names:
        await cursor.execute(f'''SELECT * FROM {table} WHERE {col}}=?''', (cond))
    else:
        return

Hmm, I think this finishes the find_one function

modest maple
#

dont you need the cursor.findone() or is it diffrent to the SYNC version of sql

lusty dew
#

oh yea

#

You are right

modest maple
#

also btw you still shouldnt use f strings with sql

#

cuz it is liable to an attack and just not good practice

#

you could do it for table name maybe

lusty dew
#

๐Ÿค”

#

what should I use this

modest maple
#

actually scrap that

#

ignore me

lusty dew
#

then*

modest maple
#

cuz im not sure exactly how else you would do it tbh

lusty dew
#

oof

slender thistle
#

refer to sqlite docs

lusty dew
#

I don't see how it is liable to attacks

modest maple
#

altho you have a stray }

slender thistle
#

f-stringa, .format tend to fuck up

lusty dew
#

especially if I am checking the table name

modest maple
#

cuz sql works in weird ways

#

it should be okay possibly

lusty dew
#

I mean

modest maple
#

altho you have a stray }

lusty dew
#

does anyone wanna test an sql injection on my bot

#

Yea I fixed that stray }

modest maple
#

ah

#

cool

#

just one fyi

#

if it hasnt got anything

#

in that row under that condition

#

it will return NONE

lusty dew
#

I know

#

xd

modest maple
#

and None is the biggest pain in le ass ever

#

xD

lusty dew
#

I also forgot how to define primary key in sql

#

isn't it just

#

PRMARY_KEY

#

or whatever

modest maple
#

think so yh

lusty dew
#

I have used too many orms

#

I usually use an orm

#

Haven't used actual sql in ages

#

@modest maple do you know how to do an sql injection in a bot

mossy vine
#

can someone tell me why returnOriginal isnt working as expected in mongodb?

{
        "_id" : ObjectId("5e05daea850bf786aa7ddd32"),
        "user" : "321242389106786314",
        "month" : true,
        "score" : 30
}```
#

oh wait

#

shell and driver call this other things dont they

#

thats fucking weird

earnest phoenix
#
let finfo = await db.collection("factions").findOne({_id: "info"});
    let list = "";
    for(var i = 0; i < finfo.count; i++){
      db.collection("factions").findOne({_id: i}).then(async fsinfo => {
      let fserver = await client.guilds.get(fsinfo.serverID);
      let memberCount = await fserver.members.filter(m => !m.user.bot).size
      list += `**[${parseInt(i)+1}]:** \`${fsinfo.name}\` (${memberCount} members)\n`;
      });
    }
    let embed = new Discord.RichEmbed()
    .setTitle("List of factions.")
    .setDescription(list)
    .setColor("#ffa500");
    message.channel.send(embed);
``` Can someone tell me what I did wrong here? The console didn't output anything and "list" is empty when sent.
modest maple
#

can you do += in js?

twilit rapids
#

Yes

late hill
#

findOne

#

Unless I missunderstood and your factions model has a count property

#

I guess it does?

#

Either way, that database query in a loop

#

Could probably be optimized and converted to just 1 query

modest maple
#

couldnt you just do findmany

late hill
#

or just find

#

Depends on what he's using

#

But I don't understand the point of the info one

#

If you're keeping track of the total factions in the info thing

earnest phoenix
#

ok i will try findmany

late hill
#

You could simply not do that and use countDocuments instead

#

Assuming you're using mongodb

#

The main reason your list was empty is because you're adding to it in the .then(), your code continues without waiting for that to happen.

#

๐Ÿ‘€

surreal sage
#

howtodo a timeout and if someone says the thing i want to it blocks and automaticly turns off the timeout after some seconds

late hill
#

You can save the timeout in a variable and then use clearTimeout(variable) to stop it at any time

spiral condor
#

On the discord.js docs it says that collection.findAll() is deprecated, but is there any other way to find all things that pass a test?

#

Or in my case I want to find out how many pass a test

late hill
#

yes

#

the filter method

spiral condor
#

Ah, thank you

lucid silo
#

how i make an animated icon for my bot on dbl website ?

restive furnace
#

you cant

#

or actually u can, use css or scss for that

mossy vine
#

have fun using scss on your dbl page

earnest phoenix
#

scss is compiled down to css

twilit rapids
#

Evaling this code snipet below returns undefined, how would I actually get results from the forEach()?

this.client.shard.broadcastEval(`
const guild = this.guilds.get('614109432145641473');
if (guild) {
    const role = guild.roles.get("659351040893648916");
    role;
}
else {
    false;
}
`).then(results => {
    results.forEach(result => {
        if (result !== false) {
            result
        }
    });
});
valid frigate
#

lol wtf

twilit rapids
#

@valid frigate what?

valid frigate
#

afaik you're not getting results for maybe one of the reasons below

  1. the role/guild you're trying to get doesn't exist in any shard's cache
  2. console.log results shouldnt return undefined first
#

or maybe your comparison is wrong as well

#

!== is strict

twilit rapids
#

The role does it exists and I'm not logging it

valid frigate
#

why not just

#

if (result) {}

twilit rapids
#

Replacing result with msg.channel.send(result.id) does send the role ID

valid frigate
#

ok then id put your comparison at blame

#

lul

twilit rapids
#

What

valid frigate
#

i mean you said it keeps returning undefined

twilit rapids
#

As in that there is no eval output

valid frigate
#

???/

twilit rapids
#

Like

valid frigate
#

why are you checking if result is true, first question

#

if in broadcastEval script, it returns false, it shouldn't return anything

twilit rapids
#

I'm checking if it's not false

valid frigate
#

yeah but you're doing that with a strict comparison

#

!== checks if it's literally true

twilit rapids
valid frigate
#

rather than a role object

#

???

#

weird ok

twilit rapids
valid frigate
#

idk then lol

twilit rapids
#

I want my forEach to return the role object rather than nothing

valid frigate
#

have you considered find

#

as in find one item in the array that is not false

#

try that, and if it doesnt work there's also filter

twilit rapids
#

How would I use to find to find something that is not false

trim prawn
#

!play the lion sleep tonight

flat pelican
#

Ye sure

earnest phoenix
#

@twilit rapids you could use filter and check if the results aren't false

#
let arr = [ false, false, false, true ];
return arr.filter(c => c !== false);
#

idk if that helps

sinful lotus
#

@twilit rapids for each is async

#

for of would work better with return

#
this.client.shard.broadcastEval(`this.guilds.has('614109432145641473') ? this.guilds.get('614109432145641473').roles.get('659351040893648916') : false`)
    .then((data) => data.filter(Boolean))

@twilit rapids and as a tip, you can simply like this.

twilit rapids
#

But wouldn't guild be undefined in guild.roles

sinful lotus
#

a sec

#

editing

twilit rapids
#

Okies

sinful lotus
#

you can chain it like that

#

since you are sure it would not get undefined due to has check

#

and it will either return undefined or false

#

and since js has no strict type checking

twilit rapids
#

So that then returns the role object

sinful lotus
#

undefined or false = falsy

#

if it can find the role ofc

#

but yeah that 2 liner code does all that work

twilit rapids
amber fractal
sinful lotus
#

I mean he already have the code

#

I just simplified it

#

although if you dont need the whole object role

#

and you only need the id

#

sending the id only would work better, processing and ipc wise

twilit rapids
#

Basically, I want to check if the msg author has a specific role in my server

sinful lotus
#

basically id only?

#
this.client.shard.broadcastEval(`this.guilds.has('614109432145641473') && this.guilds.get('614109432145641473').roles.has('659351040893648916') ? this.guilds.get('614109432145641473').roles.get('659351040893648916').id : false`)
    .then((data) => data.filter(Boolean))

then it can kinda get longer like this but yeah it still will work

amber fractal
#

You may want to cache it too

#

I would anyways

twilit rapids
#

But then I would have to also add checking if the user has the role in my server

sinful lotus
#

I dont really cache guilds that arent in same shard

#

it will just cause confusion and dup cache

#

since you cant cache the role without guild object unless you cache it via your own

#

which I really dont see any benefits other than less ipc I guess, but ipc is designed for that thing eitherways

quartz kindle
#

(this.guilds.get(id) || {roles:{get:()=>{return {id:undefined}}}}).roles.get(roleid).id

#

lmao

sinful lotus
#

lmao thats another way of doing it but I love my ternaries heheheh

#

sometimes I chain ternaries which is a bad idea heheheh but I do it anyways

quartz kindle
#

chaining ternaries is so annoying

#

there should be a better way to use ternary chaning

sinful lotus
#

coding privately is where I unleash all the bad practices heheheh

quartz kindle
#

dont we all?

sinful lotus
#

being creative or whatever goes in your brain

quartz kindle
#

thats why we dont code FOSS

sinful lotus
#

its fun

quartz kindle
#

lmao

sinful lotus
#

chain an or statement works as well if you are in to that kind of thing

opaque eagle
#

Where do I set envs in github actions?

twilit rapids
#

So how would I then check if a specific user in my server has that role, because I also have to fetch the user first

#

This is going to be such a long broadcastEval lmao

sinful lotus
#

easiest way is custom functions then call it on broadcastEval

#
const weeb = new Client();
weeb.invokeWeebness = (id) => {
  const guild = weeb.guilds.get('some id');
  if (!guild) return false;
  const role = guild.roles.get('some id');
  if (!role) return false;
  return guild.members.has(id) && guild.members.get(id).roles.has(role.id);
}
//
client.shard.broadcastEval(`this.invokeWeebness('${lewd id}')`)
  .then(_ => _.filter(Boolean))
#

tip #1: you dont need the whole code to be on broadcastEval

#

Padoru padoru season makes me a good person

twilit rapids
#

What would lewd id then be? The user's ID?

sinful lotus
#

ofc

#

the id on the function will be the one you supplied on that broadcastEval

quartz kindle
#

weebs

zealous veldt
#

That is too much weebery

valid frigate
#

oh boy

#

have you considered eris

vital lark
#

@opaque eagle you set env variables in the secrets tab in settings

#

i.e ```yaml
env:
token: ${{ secrets.SSH_USER }}

opaque eagle
#

oh

minor kelp
#

Error: 'Command' object has no attribute 'time'
Code causing the error: ```py
@bot.command()
async def uptime(self, *ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
embed = discord.Embed(colour=ctx.message.author.top_role.colour)
embed.add_field(name="Uptime", value=text)
embed.set_footer(text="Uptime!")
try:
await ctx.send(embed=embed)
except discord.HTTPException:
await ctx.send("Current uptime: " + text)

Language: Python
Possible Fixes: Unsure
Help needed: A lot
When: ASAP
earnest phoenix
#

tfw you fill out a form

minor kelp
#

yeah i made it myself

valid frigate
#

doesnt look like asap

modest maple
#

you do know

#

time is just time in python

#

you need datetime

#

not time

minor kelp
#

i have that

#

if i didnt

#

my time command wouldnt work

modest maple
#

current_time = time.time() that is not datetime

minor kelp
#

lol

modest maple
minor kelp
#

i have it

modest maple
#

datetime != time

#

youre doing time

#

thats a diffrent module

minor kelp
#

and this would go where

#

I have time imported too

modest maple
#

EXACTLY

minor kelp
#

WHAT

quartz kindle
#

you have to use datetime, but you are using time

modest maple
#

read

#

the

#

docs

minor kelp
#

that

#

is

#

python

#

2

#

im

#

using

#

3.8

modest maple
#

The lib is the same thing smh

minor kelp
#

just help me lol

modest maple
#

I AM

quartz kindle
#

we already told you what you have to do

modest maple
#

search up how to use datetime and python modules

quartz kindle
#

you have to use datetime, not time

modest maple
#

like

#

this is basic basic stuff

minor kelp
#

yeah i get that. just tell me what to do

quartz kindle
#

use datetime instead of time

#

thats what you have to do

minor kelp
#

not like that :/

quartz kindle
#

thats literally it

minor kelp
#

like the code to put in ohmylord

quartz kindle
#

jesus christ

minor kelp
#

ye?

#

so

quartz kindle
#

so

#

you are usng time

minor kelp
#

time.time goes to

quartz kindle
#

use datetime instead

minor kelp
#

datetime.time?

quartz kindle
#

yes

#

finally

minor kelp
#

really?

quartz kindle
#

or whatever

#

i dont use pythong

minor kelp
#

that looks like it wouldnt work to me but

#

alright

#

epic, a syntax error!

surreal sage
#

How to add a number like this:
1 + 6 = 7
When i try it in my script: js String + String
Then is the output: //String1 = 1 String2 = 2 12 i dont want that

minor kelp
#

Hm

#

try making the output into its own message/output

surreal sage
#

wdym

#

i want it to math

#

wait

modest maple
#

you do know

surreal sage
#

Math.floor(String + String)
Maybe?

modest maple
#

youre adding two string

surreal sage
#

y i saw that

modest maple
#

so of cource "1" + "2" = 12

#

turn it into an int

surreal sage
#

math.floor ?

minor kelp
#

Yeah

#

int not str

surreal sage
#
Math.floor(String + String)``` this?
#

is the output 3 then?

modest maple
#

couldnt you just use the Number function

surreal sage
#

i dont know that function

sudden geyser
#

you need to change it to an int, search up parseInt

minor kelp
#

^^

modest maple
#

its legit what turns a string into an int if it can

minor kelp
#

Error: TypeError: descriptor 'time' of 'datetime.datetime' object needs an argument
Code causing the error: ```py
start_time = datetime.time()

Language: Python
Possible Fixes: Unsure
Help needed: A lot
When: ASAP
modest maple
#

REad

#

the

#

docs

minor kelp
#

ew w3schools

modest maple
#

well youre the one who cant be asked to look at proper docs so im linking you to the basic learners edition :P

minor kelp
#

bOI

#

id rather try to learn python from a f*cking brick than use w3

sudden geyser
#

SBot check out the link and see how you can incorporate it

minor kelp
#

i have a diff error now lul

modest maple
minor kelp
#

blurryeyes
Error: TypeError: descriptor 'time' of 'datetime.datetime' object needs an argument
Code causing the error: ```py
start_time = datetime.time()

Language: Python
Possible Fixes: Unsure
Help needed: A lot
When: ASAP
modest maple
surreal sage
#

spam

modest maple
#

ikr

minor kelp
#

ur kinda unhelpful

modest maple
#

READ THE DOCS

#

youre asking why its not working

minor kelp
#

READ MY CODE

modest maple
#

im saying

#

read

#

the

#

docs

#

.time() requires shit

minor kelp
modest maple
#

if you read the docs

#

you would know this

#

and know the much much much easier solution

#

but as youre refusing to read them

minor kelp
#

F*CK IT ILL JUST STACKOVERFLOW LMAO

modest maple
#

no help for you

#

#copypasta 101

minor kelp
#

leave me alone

modest maple
#

๐Ÿ‘‹

minor kelp
#

:(

sudden geyser
#

it's like 3 seconds but okay

minor kelp
#

can you stahp

mossy vine
#

dude i just read the docs and i have no idea how to fix it lmao

minor kelp
#

for?

mossy vine
#

the datetime documentation that was sent above

minor kelp
#

ya?

#

What error you having?

mossy vine
#

oh i think i got it

#

wait why are you even using datetime for that

minor kelp
#

class datetime.date.

#

that might be why

#

Please post the full Traceback

vital lark
#

console log the data when sent

#

also it's undefined when a member isn't found

minor kelp
#

TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'
Never had this error before.

vital lark
#

are you sure your getting the address correctly

#

it seems your trying to get a member

#

by the argument

minor kelp
#

You use address before the "const address"

#

I don't use JS so, im just guessing here

#

Let me see.

restive furnace
#

if "address" is used before its const/let/var address = smh, it wont simply work. Does that even make sense???

#

and if its inside if(cond) var smh = 0; console.log(smh) wont work

#

instead you can do let smh; if (cond) smh = 0; console.log(smh) will work

#
  • thats basic js, so please, try find google for simple questions and even harder, before ask here.
#

But thats still basic js

#
  • you cant ping 127.0.0.1 cause its localhost
#

or smh

#

(node:13072) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:443 what the error says???

#

or wait

#

its because you did ping 127.0.0.1/localhost/0.0.0.0/198.168.xxx.xx OR your ip is blacklisted on the api.

#

What you input?

#

i found the error

#

you typed http:/ instead of http://

#

now working?

#

404 = The server/page doesnt exist.

#

the site exist but the page in the site doesnt exist.

#

http(s):// is real. http(s):/ wont work

#

basic internet stuff

#

what youre req'ing

#

๐Ÿคฆโ€โ™‚๏ธ

#

requesting thats what i meant..

#

the url you requesting

vital lark
#

try this

restive furnace
vital lark
#

๐Ÿ‘ use your browser before asking us help for requests ๐Ÿ‘

restive furnace
#

then it should work.

#

Try axios or node-fetch then (cause snekfetch is anyway depreacatedadatata)

vital lark
#

I checked the url in the browser

#

it works for me

restive furnace
#

probs copy pasta, cause this line wont make even sense: let entry = bodt.find(post => post.id === id)

#

thats not even needed

late hill
#

So many possible issues there

#

why do you slice args.join(" ") with 22

#

That means the first 22 characters of that string are gone

#

So unless your prefix and command itself add up to something above that limit

#

address would always contain nothing

restive furnace
#

basic js / d.js

#

you shouldnt copy from even ur another commands

late hill
#

copy pasting in code is generally a red flag

#

It means you could have probably coded a function or something

#

and re-used that

#

Doing so will prevent a lot of issues such as you wanting to update something that's used in multiple places and forgetting to update it in some places

#

If it's one method, you only have to change that one method

#

etc

restive furnace
#

Dont say that 24/7 its just basic js not api...

late hill
#

Go through your code line by line and try to understand what's happening

modern sable
#

this guy deleted all of his messages

twilit rapids
#

Deleted messages are also logged here... lol

lusty dew
#
    t = await find_one(client, table, col, cond)
    await cursor.execute(f'''UPDATE }''')

How would I get the table from t and use it in the next sql query

split hazel
#

Is there a way to disable CORS in ExpressJS

quartz kindle
#

you can use the middleware

wraith hornet
#

I want to send Admin cmds used on my Roblox game here to discord, how can I do it?

opaque eagle
#

Like log them?

#

log when they're used

wraith hornet
#

Yeah

opaque eagle
#

if so, webhooks

lusty dew
opaque eagle
#

look into webhooks

lusty dew
#

This might help

#

How can I make a composite key in sql

wraith hornet
#

It's hard for the scripts (For me) but it can be done, right?

lusty dew
#

Yes

summer torrent
#

Anyone know an API for PUBG Mobile?

opaque eagle
#

wow i thought roblox dev used some gui like scratch lmao

wraith hornet
#

Nope

#

I'm trying to make a big SW game but the scripts are difficult for me..

lusty dew
#

Roblox is pure lua for the most part

opaque eagle
#

oh

#

and is there version control? like git

#

and ci/cd

lusty dew
#

They remove some things that are unneeded but for the most part everything is there

opaque eagle
#

oh ok

lusty dew
#

Ye

vital lark
#

I'm wondering why this is happening?
I'm making a starboard bot for a friend's server (library: Eris) and when I destruct the emoji, it destructs and then returns undefined/null?

        const key = emoji.id ? `${emoji.name}:${emoji.id}` : emoji.name;
        const emote = msg.reactions[key];
        console.log(key, emoji);
โญ { name: 'โญ', id: null }
[14:50:37 PM] [ERROR/14367]  ->  Cannot destructure property `emoji` of 'undefined' or 'null'
lusty dew
#

They basically made their own lua lib called Roblox Lua

#

Youโ€™re not destructing anything btw

#

Youโ€™re just using a template literal xd

opaque eagle
#

^

vital lark
opaque eagle
#

that's a unicode emoji

#

not a custom emoji

vital lark
#

no duh

#

it returns undefined when I console.log the emoji

#

when it's a unicode

opaque eagle
#

That error originates further up ur code

lusty dew
#

Yea

vital lark
#

hmm

lusty dew
#

I wish python had a version of sequelize xd

opaque eagle
#

like an ORM?

lusty dew
#

I hate doing sql queries

#

I know python has orms

#

But I wish there was a sequelize one for py

opaque eagle
#

sequelize is an orm

#

python has orms

lusty dew
#

Yes but isnโ€™t sequelize made for js

opaque eagle
#

yeah

#

you're not gonna find the exact thing lol

#

but similar solutions exist

lusty dew
#

What Iโ€™m saying is I wish there was an orm like sequelize xd

opaque eagle
#

oh

lusty dew
#

I love sequelize

opaque eagle
#

meh

lusty dew
#

Itโ€™s easy to use

opaque eagle
#

yeah

lusty dew
#

But a pain in the ass at times

opaque eagle
#

i don't like its TypeScript support

#

or lack thereof

lusty dew
#

I donโ€™t know ts though Iโ€™d like to learn it

#

Lol

opaque eagle
#

Does anyone know of a good platform to write docs for a REST API

modest maple
lusty dew
#

How would I make a composite key in sql

#

so that way it takes two fields to look something up

split hazel
#

How do you make a website display an embed when posted in html?

earnest phoenix
#

an embed in discord?

lusty dew
#

Heโ€™s asking how you display an embed on his website

#

Iโ€™m assuming he means a discord embed

split hazel
#

already found out

grizzled raven
#

ok

split hazel
#

stole html code from my xenforo forum DabbingWumpus

earnest phoenix
#

let fcount = db.collection("factions").countDocuments();
    let factions = db.collection("factions").find();
    let list = "";
    for(var i = 0; i < fcount; i++){
      let fserver = client.guilds.get(factions[i].serverID);
      let memberCount = fserver.members.filter(m => !m.user.bot).size
      list += `**[${parseInt(i)+1}]:** \`${factions[i].name}\` (${memberCount} members)\n`;
    }
    let embed = new Discord.RichEmbed()
    .setTitle("List of factions.")
    .setDescription(list)
    .setColor("#ffa500");
    message.channel.send(embed);
``` Can someone tell me why list is empty? The console didnโ€™t upload anything.
#

did you check if the for loop actually enters

#

learn to debug your code

#

go through it step by step until you find the line that's causing the issue

earnest phoenix
#

Lol

lusty dew
#

In sequelize how could I define an array of jsons with values

#
        items: Sequelize.ARRAY(Sequelize.JSON({
            id: Sequelize.SMALLINT,
            name: Sequelize.STRING,
            level: {
                type: Sequelize.SMALLINT,
                defaultValue: 0,
                allowNull: false
            }
        })),
#

My idea was something like this

#

but idk

earnest phoenix
#
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
``` Help me
glad charm
#

Have you read the error.

#

Do you understand what it means

earnest phoenix
#

Yeah, but I can't figure it out.

glad charm
#

So what are you trying to get?

earnest phoenix
#

Animated emoji

glad charm
#

Show the line of code lol

earnest phoenix
#
  .addField(`${client.emojis.get("660134474247307284")}`)
glad charm
#

Welp.

#

I assume client is defined.

earnest phoenix
#
const client = new Discord.Client();
exports.run = async (bot, message, client, args) => {
}
``` there is
glad charm
#

Hmm

#

Why is there a bot and client?

lusty dew
#

Are you creating a new client every time you use a command

earnest phoenix
#

Bot info command

glad charm
#

It looks like they might be.

earnest phoenix
glad charm
#

The bot is your client

#

Why are you making a new one

lusty dew
#

Uh

#

Just use client or bot

#

Not both

earnest phoenix
#

I did not understand

lusty dew
earnest phoenix
#

Ha ok

#

thx

lusty dew
#

How are you defining bot

earnest phoenix
#

What did you mean

#

I did not understand

lusty dew
#

...

vital lark
#

well

#

if you don't know what were talking about, you probs stole the code on GitHub

lusty dew
#

Yea

earnest phoenix
#

No

#

I am from Azerbaijan

#

I am not good Engilish Language

slender mountain
#

Hey, for a music bot, it looks like the song is playing, but I hear no audio. I can see the green circle, but still no audio, could this be an issue with one of the modules like node-opus?
I'm not really looking for help with code, just wondering if anyone has had this issue and knows what causes it.

slender mountain
#

nvm I figured it out

rich sable
#

How do I setup the list bot?

lusty dew
#

What

vital lark
#

what

rich sable
#

Do I like set it up or is it automatically set when I invite it?

lusty dew
#

What do you mean

rich sable
#

Nvm I got it xD

#

I feel stupid lol

earnest phoenix
#

Help me!

#
 TypeError: Target is not an array.

db.push I get this error while using
Help me!

#
let invite = await client.guilds.get(teaminfo.serverID).channels.first().createInvite({maxAge: 0});
``` The error is "Unknown Channel". Can someone tell me what did I do wrong here?
#

@earnest phoenix what is db?

#

quick.db 7.0.0-b22

#

sorry I dont have experience with quick.db

#

thnaks

modest maple
#

right............

@earnest phoenix Firstly that error is saying what ever youre pushing isnt an array OR youre trying to treat it like its an array when it isnt

lusty dew
#

Read the error

#

Error says it all

modest maple
#

@earnest phoenix i dont think you need to specify a channel to create an invite?

lusty dew
#

Yes ya do

#

If youโ€™re making a channel inv yes

earnest phoenix
#

the createInvite function is from a textchannel

lusty dew
#

Also

earnest phoenix
#

how can I get a random channel? I tried getting the first channel but it says unknown channel

lusty dew
#

Is this for a server you can publicly access

earnest phoenix
#

no

#

but the bot is in it

lusty dew
#

Then you might as well stop

#

Youโ€™re breaking the tos

#

You canโ€™t make an invite for a server you havenโ€™t been invited to or isnโ€™t publicly available to join

#

Itโ€™s breaking the users privacy

modest maple
earnest phoenix
#

i mean it isn't public yet but it can be used by me

lusty dew
#

๐Ÿค”

#

Is it a server you own

earnest phoenix
#

yes

lusty dew
#

Mk

#

My guess is

#

your client.guilds.get isnโ€™t returning anything

#

So it doesnโ€™t have any channels

#

Make sure youโ€™re getting a guild object

earnest phoenix
#

does console.log ing it solves it?

lusty dew
#

Console logging helps debug it

earnest phoenix
#

ok lemme try

#

yes it returns something

lusty dew
#

What does it return

earnest phoenix
#

guild {...}

lusty dew
#

Is it empty

earnest phoenix
#

no

lusty dew
#

Okay thatโ€™s a start

#

Show me your code again

earnest phoenix
#
let invite = await client.guilds.get(teaminfo.serverID).channels.first().createInvite({maxAge: 0});
lusty dew
#

Okay

quartz hill
#
var user=client.users.get(userid);

some ids says undefined.
Is this an error or have users been deleted?

summer torrent
#

use client.fetchUser()

lusty dew
#

Also donโ€™t use var

#

Ever

#

Use let or const

quartz hill
#

ok thx

earnest phoenix
#

i dont see a problem with var

lusty dew
#

Var has many issues

#

Itโ€™s outdated for one

earnest phoenix
#

at least it works

lusty dew
#

Thatโ€™s...no

earnest phoenix
#

i just know let is updated var

opaque eagle
#

Lmao

lusty dew
#

This dude

opaque eagle
#

Just because it works doesnโ€™t mean you should use it

lusty dew
#

Just because it works doesnโ€™t mean you should use it

earnest phoenix
#

ik

summer torrent
lusty dew
#

Var has scoping issues

opaque eagle
lusty dew
#

On top of many other issues

earnest phoenix
#

i only use var after if statements because let doesn't work

opaque eagle
#

Lmao

lusty dew
#

๐Ÿค”

opaque eagle
#

I can always come to discord bot help channels for a little humor

lusty dew
#

Why not just assign the variable as nothing then give it a value inside the if statement

earnest phoenix
#

i do both

#

it just depends on what comes to my mind first

lusty dew
#
let something;

if(!something){
something = new value
}

something;
#

Bad example

#

But ya get what I mean hopefully

earnest phoenix
#

ok any idea on my invite provlem?

lusty dew
#

My only thought is

#

That itโ€™s not getting the channels properly

earnest phoenix
#

ok

quartz hill
#

I used now client.fetchUser() but again undefined says code

lusty dew
#

What

#

Youโ€™re saying client.fetchUser returns undefined

earnest phoenix
#

check if the user exists and the id is correct

quartz hill
#

yes

#

yes correct

lusty dew
#

Then the user doesnโ€™t exist

#

Or more likely

#

Your ID is wrong

earnest phoenix
#

thats literally what i said

#

nvm

quartz hill
#

User has used my bot 3 months ago.

lusty dew
#

Also make sure youโ€™re using a UserID and not a MessageID, or GuildID

quartz hill
#

I'm sure of that.
I do not understand whether the user deleted it.
A few ids give this problem. (5 of them in 1000 ids.)total 1000 ids

earnest phoenix
#

wait you are fetching 1000 users?

quartz hill
#

One by one.

#

yes

modest maple
#

WHY!?

quartz hill
#

My bot is a collection bot.
That's why I'm trying to find the inactive.

modest maple
#

what

lusty dew
#

Oof didnโ€™t mean to send that message

#

Xd

modest maple
#

i noticed

#

xD

lusty dew
#

Iโ€™m debating whether I wanna save the last bit of sanity I have tonight and not open up Pycharm or say fuck it

modest maple
#

pycharm is <3

lusty dew
#

Itโ€™s 5am I havenโ€™t slept since 6am yesterday which is when I woke up

modest maple
lusty dew
#

I just

#

Donโ€™t wanna make a bot alone

#

I hate coding alone

#

I like collaborating

#

It makes it more fun

heavy marsh
#

I am coding a bot in discord.js
& im trying to find a way to do a word filter for example ...

MY MESSAGE: Hey can you join my server <Server Link>
BOT: Hey can you join my server

So the bot replaces the links https || http with a space

lusty dew
#

Well

#

You could use regex and use replace method

heavy marsh
#

replace method?

lusty dew
#

Yes

summer torrent
#

.replace("https", "") like this

lusty dew
#

"Hello World".replace('Hello', 'IAmTooTiredFuckMyLife')

heavy marsh
#

ooh ...

lusty dew
#

Yea

heavy marsh
#

Thanks alot

lusty dew
#

Np

heavy marsh
#

It worked but not completely

#

Dosnt it like remove the whole link

#

And also it didnt remove both ..

#
var desc = args.slice(1).join(" ");
if (message.content.includes('https'||'http')) desc = desc.replace("https", "")```
#

this is how i did it

low wasp
#

Doinng replace like that will only remove the first instance

#

I recommend googling: js remove links from string

#

You should find a regex code that will help you with that

flat pelican
#

Use regex

low wasp
#

angeryBOYE I was typing that Eri

flat pelican
#

runs away

modest maple
#

xD

heavy marsh
#
if (message.content.includes('https'||'http')) desc = desc.replace(/(https?|ftp):\/\//, "")
#

Would this do the trick

low wasp
#

That would only replace https:// and ftp:// and http://

heavy marsh
#

nvm I will test it

#

oor oks

#

will it replace all links

#

or just the first link found

low wasp
#

I won't remove links

#

It just removes the https://

heavy marsh
#

will it do that in all the links found or just one

low wasp
#

Just one

heavy marsh
#

ooh

#

how to make it do for all links

low wasp
heavy marsh
#

ooh thanks

wheat jolt
#

how I can revoke all invites of a server using d.js?

lapis merlin
#

ops

#

hmmmm

wheat jolt
#

instead of message.author.roles you should use message.member.roles

#

what do you want to do

sudden geyser
#

and .roles does not exist on a user

#

You're looking for a member

wheat jolt
#

^

sudden geyser
#

even though you need to get the role then the name

lapis merlin
#

:0

wheat jolt
#

if you would like to make a list of the roles, you should use this:

message.member.roles.map(r => `${r.name}`).join('\n')
lapis merlin
#

Now I'm ashamed of what I did ,-,

#

thanks c:

wheat jolt
#

np

hollow saddle
#

Well you shouldn't use template literals like that

#

Just using (r => r.name) would be fine

wheat jolt
#

ah, true

barren heath
minor kelp
#

I'm sure Google can help. Or you can look at the PRAW Docs.

barren heath
#
@client.command()
async def shibapic(ctx):
    shiba_submissions = reddit.subreddit('shiba')
    post_to_pick = random.randint(1, 10)
    for i in range(0, post_to_pick):
        submission = next(x for x in shiba_submissions if not x.stickied)

    await ctx.say(submission.url)

barren heath
#

For some reason it says:
Instance of 'Reddit' has no 'subreddit' member

modest maple
#

well ig it has no .subreddit

barren heath
#

wdym

patent prism
#

I wouldnt use PRAW for a bot, due to it blocking quite a bit

barren heath
#

what do I use for reddit then?

modest maple
#

i mean you could always run in executor

#

or use a thread to get ti

#

it*

patent prism
#

You can just do a GET request to reddit.com/r/shiba/hot.json

modest maple
#

to keep it async

patent prism
#

with aiohttp

barren heath
#

oh ok ima try it

patent prism
#

Dont need to do any fancy executor stuff when you have aiohttp

barren heath
#

ok

grand flame
#

Hello

modest maple
#

hello

snow urchin
#
let discord = require("discord.js");
let client = new discord.Client();
const broadcast = client.createVoiceBroadcast();
client.on("ready", () => {
  console.log(95742980);
  var voiceChannel = client.channels.get("551078363478097931");

  voiceChannel.join()
  .then(connection => {
    const stream = "https://radio.wearebounce.net/radio/8000/radio.mp3"
    broadcast.playStream(stream);
    const dispatcher = connection.playBroadcast(broadcast);
  })
  .catch(console.error);

});

why wont this play the stream?

obtuse thistle
#

do you get an error? ๐Ÿ‘€
ps: i've never done a music bot

snow urchin
#

no i dont

obtuse thistle
#

does it join the channel ๐Ÿ‘€

#

try debugging ๐Ÿคทโ€โ™‚๏ธ

earnest phoenix
#

you're creating a new client

#

and never logging in

#

ready will never fire

topaz fjord
earnest phoenix
#

imagine Creating a new Client for Each command

copper cradle
#

^

snow urchin
#

@earnest phoenix i do have it login, just did not show that part

#

@obtuse thistle It does join the voice channel, but does nothing afterwards

obtuse thistle
#

have you tried putting breakpoints around the dispatcher and/or stream to see what happens in them?

quartz kindle
#

@snow urchin an url is not a readableStream

#

you need to connect to the url with an http library and open a readableStream from it

modest maple
#
import asyncio

async def handle_echo(reader, writer):
    data = await reader.read(100)
    message = data.decode()
    addr = writer.get_extra_info('peername')

    print(f"Received {message!r} from {addr!r}")

    print(f"Send: {message!r}")
    writer.write(data)
    await writer.drain()

    print("Close the connection")
    writer.close()

async def main():
    server = await asyncio.start_server(
        handle_echo, '127.0.0.1', 8888)

    addr = server.sockets[0].getsockname()
    print(f'Serving on {addr}')

    async with server:
        await server.serve_forever()

asyncio.run(main())```
#

am i right in thinking i should be able to run these scripts on separate programs and have them still communicate via tcp

earnest phoenix
#

What is the point of this server?

#

I actually donโ€™t know

snow urchin
#

@quartz kindle It worked before the way I am doing it now with the url

earnest phoenix
#

Do I ask people for help on my server?

mossy vine
earnest phoenix
#

Ok thx

modest maple
#

so um

#

anyone know batch a bit better than me

#

wait nvm

mossy vine
#

just post your question

modest maple
#

didnt save changed

#
The system cannot find the file Logger.py.
Press any key to continue . . .

#
@echo off

cd "D:\Innkeeper\Status%Ping\" 
start Logger.py 

pause```
#

now

#

why df is it working when i run the bat normally

#

but not when i call it via python

west raptor
#

"run the bat normally"?

#

wdym

modest maple
#

double click

#

rather than using os.startfile in py

copper cradle
#

inside the bat

modest maple
#

what

copper cradle
modest maple
#

yh

copper cradle
#
cd "D:\Innkeeper\Status%Ping\"
python Logger.py

pause
#

that

modest maple
#

it still cant find the file

#

its not running it thats the issue

copper cradle
#

ยฏ_(ใƒ„)_/ยฏ

modest maple
#

its getting the batch file to actually see logger.py first

copper cradle
#

o h

modest maple
#

for some reason running it manually it works

#

but when os does it

#

nop

copper cradle
#

then idk

heavy marsh
zealous veldt
#

Do you mean whether or not the link embeds?

heavy marsh
#

basically yes

#

like to check if that link is an image or not

zealous veldt
#

message.embeds I think is a property that exists

heavy marsh
#

so simple message.embeds

modest maple
#

we did it boois

#

we got it working

#

it just ugly af

earnest phoenix
#

that code won't work if the user doesn't have embed permissions

#

or if they put the url in <>

#

or if they suppress the embed

ionic compass
#

silly question but it is not possible for two guilds to have channels with the same id right?

earnest phoenix
#

nope

#

well

#

theoretically it is

#

realistically it isn't

lofty hamlet
#

Hi,

#

I have shard my bot last day

#

And several systemรน does'nt work

ionic compass
#

thank you

icy osprey
#

Hey guys can someone help me please, I'm using
message.reactions.get(reaction).users
but the bot is only getting his own reactions

lofty hamlet
#

Vote system, adding and leave message from server bot etc

valid frigate
#

when your bot is sharded, its instances can't see each other

modest maple
#

Sharding basically works by having a second instance of your bot running, altho it shouldnt be needed for your bot untill you get neer 2,000 guilds

valid frigate
#

for example guilds on one shard are not visible on another unless you eval them

modest maple
#

so you have to treat it as seperate programs almost

lofty hamlet
#

Yeah i know...

#

But hopw i can make vote system with sharding

earnest phoenix
#

@icy osprey use fetchUsers on the reaction

#

iirc users is just cached users

#

fetchUsers is guaranteed to return all of the users who reacted

icy osprey
#

Soo

#

message.reactions.fetchUsers(); ?

earnest phoenix
#

on the reaction
singular reaction

#

reactions is a collection of all of the reactions

icy osprey
#

my bad

#

message.reactions.get(reaction).fetchUsers(); then

earnest phoenix
#

yup

icy osprey
#

It's afunction right ?

earnest phoenix
#

keep in mind fetchUsers is a promise

#

yup

icy osprey
#

So I need to await ?

earnest phoenix
#

yeah

icy osprey
#

thank you

#

I'm trying rn

earnest phoenix
#

or if your method isn't async use .then

lofty hamlet
#

Who can help me plz ?

icy osprey
#

to ?

late hill
#

How are we supposed to help you with that

#

No idea how you try/want to handle the votes

lofty hamlet
#

I have a vote system with webhooks

#

But with shardin, he does not work

#

So i want vote system with sharding work

late hill
#

Ok

#

That's still not very helpful

#

But if it was working before

#

And doesn't work now

#

It's probably because when someone votes you do something

lofty hamlet
#

It's because i have sharding my bot

#

It's because i have sharding my bot

late hill
#

that doesn't work properly when sharded

lofty hamlet
#

Of course if it works only on one shard and not all

#

You don't know sharding

late hill
#

We can't help you with that if you don't show us code or at least tell us what you're doing

#

I know sharding

earnest phoenix
#

probably because the lib you're using works only with a non sharded client

#

it's not that hard to setup webhook handling without a lib doing it for you

#

make a webserver, listen on port for whatever path, do whatever with the data DBL sends you

lofty hamlet
#

Ok i have another example

#

I have a another system

#

Who work when my bot is not sharding

#

And not work when he is shard

#
    let adding = bot.channels.get("493061310968496128")
    try {
        let embed = new Discord.RichEmbed()
            .setThumbnail(bot.user.displayAvatarURL)
            .setColor("2ca823")
            .addField(`Discord supplรฉmentaire`, `Nom : **${guild.name}** \nID : **${guild.id}** \nCrรฉateur : **${guild.owner.user.tag}** \nMembres : **${guild.users.size}**`)
        adding.send(embed)

    } catch (e) {
        console.log(e)
    }
})```
#

When my bot is added to guild

#

He send message to channel in my discord

#

But this code work just in one shard

late hill
#

Yes

#

Because the channel you're attempting to get

lofty hamlet
#

If aiT4S RANDOM IF THE CODE IS NOT LAUNCH IN THE GOOD SHARD THE CHANNEL IS NOT FIND

late hill
#

Is located on 1 shard

lofty hamlet
#

Ups capslock

#

Yeah

#

So how i can make this when my bot is shard ?

icy osprey
#

@earnest phoenix Thank you so f*** much you fixed few bugs in my bot thanks to your tip

late hill
#

You'd have to get it to run from the other shard

#

Whatever library you use for sharding might have certain tools to help with that

lofty hamlet
#

JS

late hill
#

You could also, use discord webhooks

lofty hamlet
#

??

late hill
#

Which seem like they would fit the use case above a lot better

#

And would also ignore the issue of sharding completely

lofty hamlet
#

So my system has to be redone to work with sharding

late hill
#

You can add a webhook to a discord channel > you send a request to the webhook > the webhook posts a message in that channel

lofty hamlet
#

I have several system who don't work with sharding, fuck sharding ๐Ÿ˜‚

#

Mmmmh

#

Interessing

late hill
#

but yeah

lofty hamlet
#

How i can make that ?

late hill
#

You can just google discord webhooks

#

It's pretty simple

#

And if you're using discord.js I believe they even have tools to send to webhooks easier

#

Anyway, for certain other features you may still need your shards to be able to communicate with eachother in some way

#

There's many ways to do so

#

I use node-ipc for mine

lofty hamlet
#

I have several system down you can explain with what i cna patch this : system of log when user write command, system vote, dm log when user send private message to my bot

late hill
#

All your logs to discord channels will probably be the same issue

#

Being that the channel doesn't exist over there

earnest phoenix
#

you generally shouldn't log to discord anyways

#

log to a .log file and make a command which uploads the .log file whenever you need it

lofty hamlet
#

But i want log when user make command

late hill
#

^^

lofty hamlet
#

But i want in channel it's easier for my staff ^^

late hill
#

I just log certain key stuff so staff members can see if something's going on

#

As they don't have access to my server

earnest phoenix
#

then allow staff to execute the command aswell

#

logging to discord is bad and unreliable

#

and soon enough it'll get so spammy that you'll start to get ratelimited

lofty hamlet
#

I'll think about it in the meantime I'll do that

#

So, @late hill for example i want make my system of when user add my bot the bot send message to a channel of my discord

#

I do what

#

Excuse me for question ^^'

late hill
#

I log shards disconnecting and stuff

lofty hamlet
#

But I want to understand so I can start

late hill
#

using a webhook

lofty hamlet
#

^^

late hill
#

Not that spammy

lofty hamlet
#

?

#

I do what for the first time ?

late hill
#

If you want to use the webhook method

#

You add a webhook the channel first

#

Then you can send stuff to it

#

With simple requests

lofty hamlet
#

Mmmmh ok i do create webhooks in the channel of my server and i do put my code where ?

#

In one shard ?

#

It's boring that we can't connect all the shards

snow urchin
#

its in guildMemberAdd event
nvm solved just seen as i posted rip

late hill
#

You'd just put the code in the guildCreate event?

lofty hamlet
#

AHHH

#

No i have understand

#

My bad ^^ Ok yeah

#

I go learn discord webhooks, if i have any problem i can send private message to you ?

late hill
#

It's nothing more than a post request to the webhook url

lofty hamlet
#

I have never use this

#

Ok i have created my webhooks

earnest phoenix
#

guys
does anyone use postman
for JSON?

earnest phoenix
#

for json what

modest maple
#

hes muted

#

cuz he asked it everywhere instead of waiting

rugged minnow
#
    var webhook = message.channel.createWebhook(message.author.username, message.author.displayAvatarURL)
    var mentionHook = new Discord.WebhookClient( webhook.token , webhook.id );

hi, i'm trying to make a command that creates a webhook with username and pfp of the author -> send a message, for some reason the code above returns a 405: method not allowed, what should i do?

#

also i'm not sure that webhook.token and webhook.id even works

#

(the webhook gets created successfully)

amber fractal
#

createWebhook returns a promise

#

Await it before using it's properties perhaps?

#

Not sure if that will fix your problem, just a thought

rugged minnow
#

so i should do something like this?

 var mentionHook = async new Discord.WebhookClient( webhook.token , webhook.id );```
amber fractal
#

No

#

Await the creationg of the webhook

rugged minnow
#

oh ok

amber fractal
#

Like var x = await y()

rugged minnow
#

ok, i'll try that

amber fractal
#

The function itself must be async

rugged minnow
#

nope

vital lark
#

await

#

not async

rugged minnow
#

alright i'm retarded

stray wasp
rugged minnow
#

yep, i can't afford/host a vps

#
    message.delete();
    
    // Setting The Webhook
    async function webhsetup(){
    var webhook = await message.channel.createWebhook(message.author.username, message.author.displayAvatarURL)
    var mentionHook = new Discord.WebhookClient( webhook.token , webhook.id );  
 
    var args = args.join(" ")
    if(args.toLowerCase().includes("@everyone") || args.toLowerCase().includes("@here")){
      message.channel.send("Nope.")
      return;
    }
    var scream = randomCase(String(args));
    mentionHook.send(scream)
  }

webhsetup();```

i'm probably doing something wrong
late hill
#

Did you call the function

#

ok

rugged minnow
#

yep, didn't copy that

late hill
#

any errors?

rugged minnow
#

no errors, but nothing gets sent

#

the function doesn't seem to work

#

the message gets deleted, but nothing else

#

also this UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'join' of undefined

late hill
#

oh

#

i see

#

Is args actually defined

rugged minnow
#

yep

#
execute(message, args){
late hill
#

Technically overwriting it and setting it to args.join() should be fine

#

But it might be messing up because you're using var

#

Which makes it accesable in a lot more places

#

Mean that could get fucked with

rugged minnow
#

should i use const?

late hill
#

Well

#

Just stop using var without needing var

#

But also, just use a different variable name for the joined arguments

rugged minnow
late hill
#

You're basically redeclaring args

#

While using args for it

#

Which is probably an issue

rugged minnow
#

okie i'll change the name of the modified args

#

still method not allowed

late hill
#

You didn't mention method not allowed before

#

Your bot won't always be allowed to create webhooks

#

You'll have to handle that

rugged minnow
#

Your bot won't always be allowed to create webhooks
You'll have to handle that
how?

#

wait, nvm

late hill
#

Check if you have permissions or not

rugged minnow
#

i mean, the webhook gets created

late hill
#

๐Ÿ‘€

#

oh

rugged minnow
#

but it's probably the

 var mentionHook = new Discord.WebhookClient( webhook.token , webhook.id );
late hill
#

Why would that not be allowed

sudden geyser
#

did you await the webhook variable

rugged minnow
#

no

#

thanks

late hill
#

oh

#

the order

#

it's id, token

#

not token, id

rugged minnow
#

thanks again

#

๐Ÿ‘

icy osprey
#

Hey guys

#
var servers = client.guilds.size;```
#

Is this the right way to count users and servers ?

#

coz it doesn't gives me the right user amount

glad charm
#

That is all the users cached at the moment.

#

You'd have to iterate over all the guilds and get the user count from each one.

icy osprey
#

damn

#

using client.guilds ?

glad charm
#

Yes

icy osprey
#

thanks

peak bloom
#

note that that will count duplicates