#development

1 messages · Page 1331 of 1

gentle lynx
#

Not Erwin today told me to use them instead of normal queries

solemn latch
#

the benifits of prepared statements are listed on that url

gentle lynx
#

Aight

earnest phoenix
#

some one able to help me on discord.py im trying to only allow specific roles use a command but depending on the role they can have like a different amount of stuff cleared

example like

if role = admin then the can clear 100 msgs

if role = mod then the can clear 50 msgs

charred nimbus
#

pls help me

solemn latch
#

just a basic if statement @earnest phoenix

gentle lynx
#

Also why would you even do that

earnest phoenix
#

can u give an example by any chance ?

gentle lynx
#

Mods can just use the command twice

earnest phoenix
#

its an example

gentle lynx
#

Either check for role name or perms

solemn latch
#

i can link you a guide on how to use if statements in python

earnest phoenix
#

how would i check for roles

solemn latch
#

member.roles

static nexus
#

hey guys

earnest phoenix
#

so if member.roles == 'rolename'?

static nexus
#

how r u doing

#

i'm trying to open pycharm without the .bat file, cos as we know, bats are bad.

charred nimbus
static nexus
#

It just doesn't work

solemn latch
#

you dont have perms to edit those files @charred nimbus

charred nimbus
#

why

earnest phoenix
#

so if member.roles == 'rolename'?

solemn latch
#

roles is a list

earnest phoenix
#

if member.roles == ['roles']

#

?

gentle lynx
#

Im guessing .includes or something like that

solemn latch
#

dont think python has .includes

sonic lodge
#

@charred nimbus run it with sudo

earnest phoenix
#

so i would do

if member.roles == LIST

solemn latch
#

idk, probably should check that link i sent

earnest phoenix
#

i didi

#

did*

solemn latch
#

did it say if elm == list?

earnest phoenix
#

-_-

static nexus
#

I need some help with opening Pycharm.
I'm trying to open it, but it won't open without the pycharm.bat file.
If anyone can help, I'd be very greatful.

solemn latch
#

it gives you examples of how to do it 🤔

earnest phoenix
#

dont gotta be rude abt it -_-

solemn latch
#

whats rude? i gave you a link

#

which explains it

#

asking if something is right, when i just gave you a source that says its wrong is rude.

charred nimbus
#

sudo: npm: command not found

#

@sonic lodge

static nexus
#

I need some help with opening Pycharm.
I'm trying to open it, but it won't open without the pycharm.bat file.
If anyone can help, I'd be very greatful.

sonic lodge
#

yeah that's what i just thought

static nexus
#

I reinstalled pycharm, I used toolbox

#

I DID EVERYTHING

river thistle
#

anyone knows why whenever I want to edit an embed wich already has an image attached to it to put a new one, nothing changes ?

#

its kinda hard to explain but

solemn latch
#

like an embed thats already sent?

river thistle
#

yep

solemn latch
#

you cannot attach new images to existing embeds iirc

river thistle
#

oh thats why then

solemn latch
#

someone else might want to comment on that, because i dont have a source on that.

river thistle
#

well you can actually

#

just looked at the docs

#

you can but you have to attach the file first

solemn latch
#

thats what i said

river thistle
#

well I guess I'll use the api spammy way

#

delete + send again

#

lmao

static nexus
#

hey guys

#

can someone help me

#

i asked

#

but noone listened

#

I need some help with opening Pycharm.
I'm trying to open it, but it won't open without the pycharm.bat file.
If anyone can help, I'd be very greatful.

solemn latch
#

not a lot of py devs here

#

😦

balmy anchor
#

Hi guys a have a question,
For making a music discord bot that you can search videos with, I must having a google api?

river thistle
#

never used pycharm sorry

solemn latch
#

i do my best to help, but the question i cant answer, maybe shiv can but looks like he is busy modding some people

river thistle
#

Hi guys a have a question,
For making a music discord bot that you can search videos with, I must having a google api?
@balmy anchor some plugins don't need one but most of the time you'll need a Youtube Data v3 api key

balmy anchor
#

someone told me after like 300h u'll need to spend money no?

ember lodge
solemn latch
#

ah v11

#

scary

#

good job being in october spirit

ember lodge
#

i know :) ill update it later

proven lantern
#

if msg.member is defined is it safe to assume msg.guild will be defined?

solemn latch
#

guilds are pretty much always cached in every lib afaik

proven lantern
#

not for DMs

#

client.on('message', msg=>{});

#

the client will have the guilds cached

solemn latch
#

oh, why are you checking member then 🤔

#

just check guild

proven lantern
#

that's not what i'm trying to do

#

i want to see if it's a DM

solemn latch
#

then check the type

proven lantern
#

msg.type?

sonic lodge
#

the type of the channel it was sent in

solemn latch
#

^

#

very xy problem here

proven lantern
#

msg.channel.type

proven lantern
#

nice, that will make the code more clear

solemn latch
proven lantern
#

so if msg.channel.type === "text" then msg.guild and msg.member will be defined

#

right?

solemn latch
#

message.member may not be iirc

#

since messages can come from webhooks

proven lantern
#

can discord users post messages in guilds they dont belong to?

solemn latch
#

no

proven lantern
#

so msg.member should be define right?

solemn latch
#

not if its a webhook

#

since webhooks dont have members or users

proven lantern
#

gotcha

#

thanks

lean wing
#

the can when the have the contorl of a discord bot that is on the server you want

#

i tthink

solemn latch
#

bots have members associated

fading breach
#

node . does not work it takes longer then usual (over 10 minutes and nothing happens)

opal plank
#

use node filename

solemn latch
#

check for loops

opal plank
#

node index.js , or node bot.js or node main.js, whatever your main file is called

fading breach
#

alright

solemn latch
#

its been so long since i used that i forgot about it

fading breach
#

nothing is happening

nova fable
#

سلاو

proven lantern
#

make sure your command prompt is in the right directory

fading breach
#

yeah

#

it is

charred nimbus
#

how can i give my self perms on my vps in google cloud

earnest phoenix
#

So i want to make a auto response for my bot for example the user sends a messages which includes word invite basic stuff i can check if the array of responses includes that but how can i make it detect even if the user types invitei23u0912u312 or something like that?

solemn latch
#

js?

proven lantern
#

are there any node processes running in the task manager @fading breach

earnest phoenix
#

js?
yup

fading breach
#

dont think so let me check

solemn latch
#

string.includes("")

earnest phoenix
#

bruh

proven lantern
#

also does node --version print a version greater than 12?

fading breach
#

what are they called?

earnest phoenix
#

what if they write inviteblablabla

#

it won't detect Thonk

solemn latch
#

why not?

proven lantern
earnest phoenix
#

leme test it ig

fading breach
#

nope not a single one

#

do i need one thats open

earnest phoenix
#

why not?
okay yes it will

proven lantern
#

no, there shouldn't be one running until you run the node command

fading breach
#

okay

proven lantern
#

does the node --version command work?

fading breach
#

yes

#

it says v13.12.0

proven lantern
#

i've never used 13 with discordjs, but it should work

solemn latch
#

what did you change from your old code

fading breach
#

should i get a newer/older version?

solemn latch
#

to the current?

fading breach
#

me?

solemn latch
#

ye

fading breach
#

image search like !image just gives some random image

solemn latch
#

did you add anything to your ready event?

fading breach
#

no

solemn latch
#

did you delete your login?

fading breach
#

the one with the token?

solemn latch
#

yes

fading breach
#

no its still there

solemn latch
#

can you add a console.log("test 123")
near the beginning of your code?

#

and see if it logs

fading breach
#

it logs

solemn latch
#

double check your client.login isnt in an event

fading breach
#

it says client.login('thetokenthing');

#

not really sure lol

solemn latch
#

like, is it at the very very bottom of your code

fading breach
#

yes

solemn latch
#

with no
} or ) at the end

fading breach
#

wait no it has that at the end

solemn latch
#

or well ) to close the (token) obs

#

im not sure 😦

fading breach
#

tysm it works now :)

#

not sure if commands work though lol

#

ReferenceError: options is not defined

#

oof

pure lion
#

who is options

solemn latch
#

my name is options, because i have no options pandasad

fading breach
#

just wanted to say we are both mutuals with absolute lol

#

medic

#

haha but uhm i gotta fixx ReferenceError: options is not defined

pure lion
#

just wanted to say we are both mutuals with absolute lol
o shit thats actually really cool

#

where is options undefined?

#

its usually just an object you pass in and not options.foo or whatever

ember lodge
#

How can i get admin command logs from my ARK server that is hosted in nitrado?

earnest phoenix
#

Okay so i know how to get if a string includes something from array

const resArray = [
  { trigger: 'invite', response: 'test' }
];
resArray.some(x => message.content.includes(x.trigger));

which will return a boolean if it includes or not but how can i find the object that with the trigger that was found?

wispy hinge
#

if (value){ ?

pure lion
#

why are you storing that in an array tho

fading breach
#

do i just send the code for it

pure lion
#

ye

earnest phoenix
#

cuz its gonna be an array of different objects

pure lion
#

why

fading breach
earnest phoenix
#

the members gonna set up the auto response like they want

pure lion
#

oh dogpile do be epic

fading breach
#

yeah i just wanted to try it

wispy hinge
#

"User-Agent": "Chrome"

snow urchin
#

would both guildMemberRemove and guildBanAdd listeners be triggered at the same time?

pure lion
#

is that pptr or something

#

would both guildMemberRemove and guildBanAdd listeners be triggered at the same time?
yep

snow urchin
#

alr

fading breach
#

"User-Agent": "Chrome"
what

earnest phoenix
#

why
any better way?

wispy hinge
#

ur code

#

BRUH

fading breach
#

my code is bad

earnest phoenix
#

its an array of objects some can be added or removed Thonk

pure lion
#
const you = _stinky
solemn latch
#

might want to make it a map @earnest phoenix

sudden geyser
#

would both guildMemberRemove and guildBanAdd listeners be triggered at the same time?
@snow urchin sort of. Not literally at the same time your bot handles the case, but more like one may be triggered before the other. For the most part I think it's guildBanAdd triggered first, but don't rely on one of them being first.

fading breach
#

yes

#

ok i gtg bye :)

#

ill fix it some other time i guess

wispy hinge
#

its an array of objects some can be added or removed Thonk
@earnest phoenix Yeah, i think so

fading breach
#

dm me a way to fix it if u want

earnest phoenix
#

might want to make it a map @earnest phoenix
Hmm i can but not sure since i wanna add more options dm the user instead of sending it to the channel

snow urchin
#

@snow urchin sort of. Not literally at the same time your bot handles the case, but more like one may be triggered before the other. For the most part I think it's guildBanAdd triggered first, but don't rely on one of them being first.
@sudden geyser I am not really concerned as to which is triggered first, I am currently doing stuff for the PreMiD discord bot and they have the ban and member remove event do the same thing, meaning only one of them was needed if they both were triggered

celest axle
#

No

snow urchin
solemn latch
#

maybe

sudden geyser
#

Is there a setting to set the max line width for a line in visual studio code

sonic lodge
#

you can change the max word wrap column

sudden geyser
knotty sigil
#

Does someone knows how can i log that when a file or embed got deleted it will show it like this?

quartz kindle
#

check for message.embeds and message.attachments

#

isnt it obvious?

#

24hours = 24 * HOUR

#

1week = 7 * 24hours

#

etc...

solemn latch
#

10/10 burber experince

cosmic robin
#

@cosmic robin how do you rate your burber experience
@royal portal whats burber

knotty sigil
#

hair cutter

drifting wadi
#

Hi!! I need help, Im trying to detect the reactions of a message, but the bot doesn't detect it

    return ['💰', '💵', '🤑', '💸'].includes(reaction.emoji.name) && user.id === message.author.id;
  };

  message.awaitReactions(filter, { max: 4, time: 60000, errors: ['time'] })
    .then(collected => {
    const reaction = collected.first();
    if (Discord.MessageReaction.emoji == '💰') {
    message.channel.send("1");
  
    //act = false;
  } else if (Discord.MessageReaction.emoji == '💵') {
    message.channel.send("2");
   
    //act = false;
  } else if (Discord.MessageReaction.emoji == '🤑') {
    message.channel.send("3");
  
    //act = false;
  } else if (Discord.MessageReaction.emoji == '💸') {
    message.channel.send("4");
 
    //act = false;
  }
})`

#

Here is the code

#

Does anyone can help me please?

sonic lodge
#

what is Discord.MessageReaction.emoji

snow urchin
cerulean laurel
sonic lodge
#

@snow urchin array.random() doesn't exist

snow urchin
#

oh right yes, my dumb brain 😄

drifting wadi
#

you should be using reaction.emoji instead
@sonic lodge ok, im trying it

snow urchin
sonic lodge
#

no

earnest phoenix
#

yes callum

snow urchin
#

getting mixed signals

earnest phoenix
#

*actually no

snow urchin
#

ah sure its -1 not +1, since 0 is start

drifting wadi
#

@sonic lodge , doesn't work, look

sonic lodge
#

it's 0

#

@drifting wadi what's supposed to happen

#

and mb, it should be reaction.emoji.name, not reaction.emoji, if you want to compare the actual unicode representation

drifting wadi
#

when I react with 💰, the bot has to say 1

#

but It says 1 without reacting

sonic lodge
#

look at your filter

#
return ['💰', '💵', '🤑', '💸'].includes(reaction.emoji.name) && user.id === message.author.id;```
#

it checks that the id of the user who reacted is the same id as the user who sent the message, which is your bot

#

your collector will then only collect those four reactions by your bot

drifting wadi
#

Oh

#

How can I fix it?

sonic lodge
#

you need the id of the user who triggered your bot's message

drifting wadi
sonic lodge
#

show the whole command code

drifting wadi
#

uhm ok

#
const moment = require("moment")

module.exports.run = (client, message, args) => {
  const embed = new Discord.RichEmbed();
  embed.setAuthor("Creador de presupuestos", "https://i.imgur.com/GungfUE.png", "https://i.imgur.com/GungfUE.png")
  embed.addField("a")
  embed.setColor("#fffff1")
  embed.setFooter(`Comando pedido por ${message.author.tag}`)
  embed.setTimestamp()


  message.channel.send(embed).then(function(message) {
    message.react('💰')
    message.react('💵')
    message.react('🤑')
    message.react('💸')

const filter = (reaction, user) => {
    return ['💰', '💵', '🤑', '💸'].includes(reaction.emoji.name) && user.id === message.author.id;
  };

  message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
    .then(collected => {
    const reaction = collected.first();
    if (reaction.emoji == '💰') {
    message.channel.send("1");
  
    //act = false;
  } else if (reaction.emoji == '💵') {
    message.channel.send("2");
   
    //act = false;
  } else if (reaction.emoji == '🤑') {
    message.channel.send("3");
  
    //act = false;
  } else if (reaction.emoji == '💸') {
    message.channel.send("4");
 
    //act = false;
  }
})})


}
sonic lodge
#

oh noes i hate explaining scoping problems

#
//                       this message at the top here is the user's message. it contains the information you want.
module.exports.run = (client, message, args) => {
  const embed = new Discord.RichEmbed();
  embed.setAuthor("Creador de presupuestos", "https://i.imgur.com/GungfUE.png", "https://i.imgur.com/GungfUE.png")
  // ...

  // here, you send a message to the same channel the user sent their original message. so far so good.
  message.channel.send(embed).then(function(message) {
    // oh noes! the message that "message" refers to now is the message the bot just sent!
    message.react('💰') // that works for these reactions, because the bot needs to react to the new message it just sent.
    message.react('💵')
    message.react('🤑')
    message.react('💸')

const filter = (reaction, user) => {
    return ['💰', '💵', '🤑', '💸'].includes(reaction.emoji.name) && user.id === message.author.id; // but once we get here, "message" is still referring to the message sent by your bot, not the one the user sent.
  };```
#

all you need to do is distinguish between the user's message, and your bot's message, which just takes some renaming

drifting wadi
#

and how to do this?

#

srry but im a begginer

solemn latch
#

for example function(m){}
rather than function(message){}

blissful coral
#

Suggest you look up how to do it and learn further

drifting wadi
#

it still doesnt working

#

Suggest you look up how to do it and learn further
@blissful coral I have searched but I didnt find anything

#

@sonic lodge srry for being anoying

blissful coral
#

Well what did you search

drifting wadi
#

How to detect reactions discord.js

sonic lodge
#

you should be looking up how scope works

blissful coral
#

^

#

And it is messageReactionAdd @drifting wadi

drifting wadi
#

ok

restive notch
#

is there any packages that improve the compilation and just the bot in general (JS)

coral stirrup
#

??

restive notch
#

like packages that speed up my discord.js bot

coral stirrup
#

npm packages wont speed up your bot. they will slow it down..

#

atleast, if youre talking about performance & response times..

restive notch
#

more efficient compilation?

coral stirrup
#

.js files do not get compiled..

restive notch
#

you know what i mean i hope

coral stirrup
#

my friend, i think you have to start over learning the difference between different types of programming languages

restive notch
#

wdym

coral stirrup
#

there are different types of programming languages, js for example is an interpreted language and can not be compiled. c++ for example is a compiled language

#

but i wont explain to you how this works in detail, some googling should do it

restive notch
#

oh understand i thought nodejs was compiling the files on glitch because ive never used js on my own machine like i have python and c++

#

although for websocket speed on the page it says "utf-8-validate in combination with bufferutil for much faster WebSocket processing (npm install utf-8-validate)"

#

thanks

coral stirrup
#

... i wont answer any questions from you, i feel trolled.

restive notch
#

sorry idk why you feel trolled

solemn latch
#

npm install zlib-sync
npm install bufferutil
npm install discordapp/erlpack
npm install utf-8-validate

#

^ should speed things up

restive notch
#

yes i see

solemn latch
#

jemalloc can reduce memory usage, but slightly higher cpu usage if that trade is fine for you aswell

coral stirrup
#

because you were telling me about how the „compilation“ process should be speeded up, and then you send me a quote to speed up your websockets, which is kinda obvious if you have the right tools.

restive notch
#

ooh ill keep an eye on jemallc

restive notch
#

for webhook using

const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});``` do i need express?
pale vessel
#

for webhooks? nah

restive notch
#

no?

solemn latch
#

i belive glitch provides a dynamic internal port

restive notch
#

what does that mean?

solemn latch
#

process.env.PORT rather than 5000

restive notch
#

i dont have a .env on my project

pale vessel
#

it's there by default

#

heroku does that too

restive notch
#

i got rid of it

#

i deleted the .env

pale vessel
#

process.env is not only from .env files

restive notch
#

oh

#

i understand now

#

so 3000?

#

when i put the env thing it says in the terminal its running on port 3000

pale vessel
#

yeah

restive notch
#

so using

const DBL = require("dblapi.js");
const dbl = new DBL(dbltoken, { webhookPort: process.env.PORT, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
``` and the putting my address and my password in topgg for it still doesnt spit anything out in the console
solemn latch
#

ive not used glitch ever, but somewhere in the glitch fourm/docs they cover ports

#

worthwhile to look at probs

restive notch
#

k

silver lintel
#
let prefix = '-';
  if (!message.content.startsWith(prefix) || message.author.bot) return;
``` how do i make it respond to two different prefixes?
boreal iron
#

&&

solemn latch
#

what even is

#

nvm

boreal iron
#

if(!prefix1 && !prefix2 ... )

pale vessel
#

if ((!startsWith("p1") && !startsWith("p2")) || bot)

#

ye

solemn latch
#

its often easier to include rather than && every time

pale vessel
#

like ![].includes(content[0]) || bot?

solemn latch
#

yeah

faint prism
#

You mean or, not and

boreal iron
#

Don’t get why searching the array should be easier than using an operator in the statement but okay.

solemn latch
#

if you have 6 diffrent prefixes

#

&& && && && && &&

#

:p

pale vessel
#

it's cleaner, at the very least

faint prism
#

It'd be ||

solemn latch
#

yeah pandasad

boreal iron
#

But way slowlier

solemn latch
#

i tried

sudden geyser
#

If you have a fixed amount using &&/|| is okay.

faint prism
#

If you have &&, both prefixes would have to be true

solemn latch
#

why is includes slower 🤔

boreal iron
#

Wrong @faint prism

pale vessel
#

i mean are you running your bot on a potato

boreal iron
#

He checks if none of it is used

pale vessel
#

notice the !

boreal iron
#

!

#

if( not prefix1 && not prefix2 ) return

#

In words

pale vessel
#

in python

solemn latch
#

lmao

boreal iron
#

Shhh go away with your snakes

faint prism
#
if (msg.startsWith(prefix1) || msg.startsWith(prefix1))
{
  // Prefix exists in msg
}
pale vessel
#

it's for a return code so it should be the opposite

solemn latch
#

sometimes i feel like we ! ! ! things in coding

#

for no reason

faint prism
#

Oh, yeah, you're right

boreal iron
#

You guys are weird

solemn latch
#

lmao

pale vessel
#

always has been weird

boreal iron
#

Aye

solemn latch
#

wheres always has been bot

remote wharf
#

hello
can someone help me with the dblpy module
I am not sure how to make something get called when someone votes for my bot
btw I do not use cogs for my bot```python
class TopGG(commands.Cog):

def __init__(self, bot):
    self.bot = bot
    self.token = 'dbl_token' # set this to your DBL token
    self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

@tasks.loop(minutes=30.0)
async def update_stats(self):
    logger.info('Attempting to post server count')
    try:
        await self.dblpy.post_guild_count()
        logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
    except Exception as e:
        logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))


    await asyncio.sleep(1800)

@commands.Cog.listener()
async def on_dbl_vote(self, data):
    logger.info('Received an upvote')
    print(data)

def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
I am not sure exactly what to put instead of DBL token
and if I have to call these functions somewhere
like setup

pale vessel
remote wharf
#

ok

remote wharf
#

does anyone know here how to use on_dbl_vote without a cog

opal plank
#

erm, thats new to me

solemn latch
#

too many slaves?

opal plank
#

what did i dorked this time?

#

probably self invoking or recursive functions

#

i think

#

maybe

#

never had that error before

solemn latch
#

are you going to have to like, increase stack size or something pogey

opal plank
#

im fairly certain i already fucked enough with the code

#

prob best to leave node as is

solemn latch
#

"It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit."

opal plank
#

probably self invoking or recursive functions
spot on

solemn latch
#

lmao

remote wharf
#

hello

#

how do I make something it print something when someone votes for my bot on discord

#

WITHOUT cogs

opal plank
#

webhooks

#

oh

#

hmm

#

cof cof shiv

solemn latch
#

are cogs not just listeners 🤔

remote wharf
#

idk'

#

do I need to call the functions somewhere

opal plank
#

BRUH WTF

#

WHY

#

WOT

remote wharf
#

and is there any way to test if it works

#

I am stupid so I would not know

solemn latch
#

did you fix it @opal plank

#

saddly not a py dev 😦

remote wharf
#

oh ok

opal plank
solemn latch
#

pretty sure cogs are pretty important to use in python. is there a reason your specifing without cogs @remote wharf ?

opal plank
#

this is fine, its just one function trying to FETCH 5 slaves/shards, clearly its working fine with the FUCKING 4000 REQUEST PER MINUTE

remote wharf
#

because I do not use cogs for my bot because htey are impossible to use

#

and I do not understand one bit

#

and I how no clue if you are supposed to call them

#

or do something like that

solemn latch
#

do you understand webhooks?

remote wharf
#

not one bit

solemn latch
#

because youll have to learn either cogs, or learn how to make webhooks

remote wharf
#

would prefer the webhooks then

#
import dbl
import discord
from discord.ext import commands, tasks

import asyncio
import logging


class TopGG(commands.Cog):
    """Handles interactions with the top.gg API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)

    # The decorator below will work only on discord.py 1.1.0+
    # In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())

    @tasks.loop(minutes=30.0)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

        # if you are not using the tasks extension, put the line below

        await asyncio.sleep(1800)

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
#

do I need to call this setup thing somewhe

#

how do I test if the API is working without voting for the bot 100 times

solemn latch
#

the test button on your bots edit page

opal plank
#

how are 5 slaves doing that many calls?

#

its a for loop on those entries

#

how is it doing that many calls?

remote wharf
#

and also what exactly is DBL token?

#

is it hte one on the API page

#

and how do I know if the test works

solemn latch
#

the token provided

remote wharf
#

for example if wanted to test voting

#

do I just click test

solemn latch
#

youd print the results from your listener

remote wharf
#

do I call the setup function somewhere

solemn latch
#

i would guess so

remote wharf
#

how would I call it

#

if it takes in the agrument of bot

#

do I put the client there?

opal plank
#

cool, now all my shards broke

solemn latch
#

f

opal plank
#

cuz of a function

#

thats not even related

#

i love sharding

#

so much

remote wharf
#

and what do I put for the webhook url

solemn latch
#

http://ip:port/path

#

port and path you define

#

ip is the public ip

remote wharf
#

ok thanks

#

how do I call the setup command

#

what would I put inside for the arguments

#

setup(?)

solemn latch
#

i feel like its self explanitory

#

setup(bot):

#

your bot

remote wharf
#

what is in bot

#

bot is not defined

#

is that the client?

solemn latch
#

presumably yes

remote wharf
#

oh ok

opal plank
#

NOW IT WORKS?

#

WOT?

#

MATE

solemn latch
#

is there the same number of slaves?

opal plank
#

somehow a self calling function is breaking the whole cluster

#

like wtf

#

exbrein plez

#

imma just turn that into a normal function

#

-.-

#

fuck that shit

remote wharf
#

when is use the test

#

does it call everything?

drifting wedge
#

can flask get stuff from discord py?

earnest phoenix
#

any lib can interact with any lib if you make it do so

#

remember that you're programming

#

not writing an essay

solemn latch
#

can discord js interact with discordpy? jk ofc it can

blissful coral
#

Yes

#

Lol

#

If you do it correctly

opal plank
#

cough cough api cough cough

solemn latch
#

^

#

that was the joke

blissful coral
#

Cough cough hell cough cough

remote wharf
#

so is this correct?

#
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
bot = commands.Bot(command_prefix = "&")
import os
TOKEN=os.getenv("TOKEN")
class TopGG(commands.Cog):
    def __init__(self, bot):
      self.bot = bot
      self.token = ""
      self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='', webhook_auth='', webhook_port=0)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(data)

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))
setup(bot)
bot.run(TOKEN)
opal plank
#

How can Discord which is written in c,m ruby and a ton of other languages connect to my js/py/go bots?

blissful coral
#

Hmmmmm

remote wharf
#

it does not seem to be workign

blissful coral
#

Good question

#

Error?

remote wharf
#

none at all

#

is there some different thing for tests

opal plank
#

i only call it once

#

ONCE

#

How is it duplicating itself?!??!?

solemn latch
opal plank
#

its only called once on the index

remote wharf
#

I don't think that the client is supposed to go inside the bot parameter

#

because it is not working

#

and there are no errors 😭

opal plank
#

@ TIm hilp

#

nvm figured out

#

im a fucking idiot, ignore me

remote wharf
#

does anyone know how to make the bot do something when someone votes for it in discord.py

#

or even get the webhook working

#

because I have absolutely no clue

opal plank
carmine summit
#

Uh

opal plank
#

the more i touch the more i break

remote wharf
#

do you need to call the setup function

opal plank
#

yeah

remote wharf
#

how

opal plank
#

wdym how?

remote wharf
#

what does the bot argument mean

#

is it the client

#

because that does not seem to be working

opal plank
#

you talking about me?

remote wharf
#

not exactly

opal plank
remote wharf
#

abotu the webhook for the APOI

opal plank
#

oh

#

yeah im not familiar with py

remote wharf
#

it is impossible to work

opal plank
#

otherwise i'd help

solemn latch
#

i mean, people use the default code all the time

remote wharf
#

the default code does not work for me

#

because I have no clue what the bot argument means

#

and if I am supposed call setup

#

or just leave it there

#

and how to test it properly

solemn latch
#

your the python dev, you should probably know 🤔

restive notch
#

how do i obfuscate nodejs code?

remote wharf
#

I am stupid 😭

#

I have no clue

solemn latch
#

i can google how to use functions for you

remote wharf
#

I just don't know what the bot argument entails

carmine summit
#

How do u test code with vs code?

remote wharf
#

and what exactly you are supposed to but there

carmine summit
#

Like self host it?

remote wharf
#

not that

compact echo
#

Try that

restive notch
#

thanks

remote wharf
#

it is not javascript though

#

oh that is him

compact echo
#

I don't know if it works because I just googled it

solemn latch
#

have you checked the port you are acessing is open?

#

have you checked if the firewall is allowing incoming connections?

#

did you port forward

remote wharf
#

so if I just put this

#
from discord.ext import commands

import dbl


class TopGG(commands.Cog):
    """
    This example uses dblpy's webhook system.
    In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
    """

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token'  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        """An event that is called whenever someone votes for the bot on top.gg."""
        print("Received an upvote:", "\n", data, sep="")

    @commands.Cog.listener()
    async def on_dbl_test(self, data):
        """An event that is called whenever someone tests the webhook system for your bot on top.gg."""
        print("Received a test upvote:", "\n", data, sep="")


def setup(bot):
    bot.add_cog(TopGG(bot))
#

and filled in the right stuff

#

would it work

solemn latch
#

no

pale vessel
remote wharf
#

or would I need to call the setup thing

solemn latch
#

you have others you need to do

remote wharf
#

like what

solemn latch
#

can you answer the three questions i asked

#

:p

remote wharf
#

I am not sure if it is open

#

I just used 5000 as the port

#

how do I check

#

I am not sure about firewall

#

I am not sure what port forward is

solemn latch
#

firewalls are completely managed by you, theres a handful of them so i cant say what yours is so i cant really tell you about it

#

port forwarding depends on your router and only is needed if you are running off a home network

remote wharf
#

what does that mean

solemn latch
#

wheres your server located that your running this code?

opal plank
#

google port fowarding

remote wharf
solemn latch
#

vps? home? server?

#

whats your url look like that your using(change it so its obvs not yours)

remote wharf
solemn latch
#

no path?

#

or port

remote wharf
#

no

solemn latch
#

you need to include the path and port

remote wharf
#

I don't think you can do that

solemn latch
#

why not?

remote wharf
#

that is just the url that is there

carmine summit
#

What's the difference of .some and .find

remote wharf
#

is depends on the name of the probject

opal plank
#

url is not path

#

url:port/path

solemn latch
#

^

opal plank
carmine summit
#

https://

opal plank
#

wait

remote wharf
#

for the link to the project it is

opal plank
#

they using 3000?

solemn latch
#

idk what repl allows

#

or doesnt allow

remote wharf
opal plank
#

i forgot the normal https port

solemn latch
#

youd add your path after their path iirc

restive notch
opal plank
carmine summit
#

What's the difference of .some and .find

remote wharf
#

but I thought the path has so be an integer

solemn latch
#

path is any url

remote wharf
#

so how does this relate to the web hook

solemn latch
#

the path there is /subscriptions

carmine summit
#

but I thought the path has so be an integer
@remote wharf You mean port?

solemn latch
#

your webhook server has to be at a path

#

that the webhook client can reach

remote wharf
#

oh I keep getting confused

tame kestrel
#

What's the difference of .some and .find
@carmine summit mdn says some returns true if found, while find returns the actual entry that passes the filter

compact echo
#

@restive notch Sorry but like I said. I legit just search up how to obfuscate nodejs code and I didn't test it. Just google it

remote wharf
#

how does it know it is one repl.it though

restive notch
#

yeah thats waht i did and i couldnt find anything suitable for discord bots

remote wharf
#

so I need to change the path the to the path to get to my project?

restive notch
#

thanks though

solemn latch
#

and the path to your webhook

#

it needs to be pointing exactly at the webhook

#

no matter what

remote wharf
#

what is the link though

#

the link to the project

solemn latch
#

yes, then the port and path of the webhook

#

whatever that may be

remote wharf
#

how do I know if it is for the webhook

compact echo
#

@restive notch I searched up how to obfuscate nodejs code discord bots and got this https://obfuscator.io/. This worked for me but I don't know for super big files so maybe try this and let me know?

solemn latch
#

you get a response from the code when you test it

opal plank
#

the link(url) IS the url you have already, the paht (/somePathHere) you need to specify within the code once it listens to the root

remote wharf
#

but I have no clue what this webhook link is

drifting wedge
#

how do i use varables for html?

opal plank
#

wlel its your fault

remote wharf
#

idk

solemn latch
#

its what your setting it to

#

lmao

opal plank
#

well it your fault*

remote wharf
#

yeah I am pretty stupid

opal plank
#

you chose to go the webhook route rather than cogs

compact echo
#

how do i use varables for html?
@drifting wedge google it?

remote wharf
#

I have no clue how to use cogs either

solemn latch
#

your setting it
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

compact echo
#

<var> tag I think

remote wharf
#

yeah

opal plank
#

either pick one or move to something else

#

cogs are pretty important in py iirc

#

you'll likely have to learn them either way downt he line

#

why not get it over with already?

remote wharf
#

but do I call the setup funcotin

#

and wehat do I put inside them

opal plank
#

i personally dunno, Py isnt my area

remote wharf
#
def setup(bot):
    bot.add_cog(TopGG(bot))
#

there is this thing

#

do I need to call this

#

and what do I put inside it

solemn latch
#

look at the docs, most people have no issue setting this up

remote wharf
#

I have been trying to set this up for the past 3 hours

opal plank
#

i've been trying to debug my sharding for the past 5

solemn latch
#

i need another 5 week project

#

i wanna learn opengl

remote wharf
#

oh well I guess I should just not add this then

solemn latch
#

which means learning c++

opal plank
#

try sharding, you'll love it

remote wharf
#

it is so hard to add lol

solemn latch
#

shiv will be on soon prob

remote wharf
#

(at leasta for me)

drifting wedge
#

how do i call a function from flask in html?

opal plank
#

Woo, try sharding if you wanna a 5+ week project

drifting wedge
#

flaskapp?

opal plank
solemn latch
#

im too dumb for actually making a sharding manager

opal plank
#

this shit is beyond complicated tbh

solemn latch
#

i can enable sharding in djs

#

ezpz

opal plank
#

lmao

carmine summit
#

Bruh

#

Spawning a shard takes forever

opal plank
#

its fun to play with, but holy fucking shit is it hard and moody

#

it takes me roughly 5-10 seconds to spawn a shard

solemn latch
#

my bot will take 10 years to spawn more than 5 shards 🤷‍♂️

#

so much loading done with my stuff

carmine summit
#

Mee6

#

Oh no

solemn latch
#

oh gosh

carmine summit
#

Has 3m servers

#

3k shards

solemn latch
#

will see it startup tomorrow

carmine summit
#

Takes a day to boot up

solemn latch
#

after a reboot

#

gosh mee6 just get better servers 5head

opal plank
solemn latch
#

7 minutes~

opal plank
#

11 seconds i think

#

shard slow to spawn, huh durh

solemn latch
#

if you needed 500 shards how long would it take

#

🤔

opal plank
#

lets see with 100

#

500 seems a bit much

solemn latch
#

oh just test it, rather than doing math

#

seems logical

#

91 minutes

#

wait

#

did i math right

#

am i drunk

#

yeah 91 minutes???

#

500

opal plank
#

i got an idea

#

hold up

solemn latch
#

18 minutes if my math is right for 100

opal plank
#

thats too long for mister ddossing twitch

#

hehehehhee

#

giemm5

#

well it died mid way but that proves the point lmao

#

@solemn latch

#

50 in 30seconds, take it or leave it

solemn latch
#

not good enought. 700 ever 10 seconds

opal plank
#

time to revert this change before i get bent off twitch

solemn latch
#

says the boss who never programmed a day in his life

opal plank
#

my pc cant even keep up with that many spawns

#

if i were to push that onto the host it'd probably do RAELLY decent

#

time to play with this more until i get dehydrated from crying

solemn latch
zenith knoll
#

is there a way to sync a channels permissions to a category?

#

like idk <channelobj>.setPermissions(channel.categoryperms)

solemn latch
zenith knoll
#

?

#

im in development

#

i need help

solemn latch
#

the other person

#

who deleted his messages

pearl trail
#

wut

zenith knoll
#

woo any fixes?

solemn latch
#

get the permissions from the category

#

set them as the channels perms

opal plank
#

im fairly certain the docs showed that

#

holdup

solemn latch
#

it should

zenith knoll
#

ok

opal plank
zenith knoll
#

i assume permissions lock

#

o nbvm

#

channel.lockPermissions()

#

thought that was v11 but ok

earnest phoenix
#

so like what does utf 0 do?

zenith knoll
#

um

earnest phoenix
#

there's nothing there but it looks like a space

zenith knoll
#

0 width chars?

#

idk

earnest phoenix
#

no utf-8 with 00000000 or utf16 with 00000000 00000000

#

How can I see httpStatus with node-fetch.

#

do you have a specific use case?

#
function checkStatus(res) {
if (res.ok) {
return res;
} else {
throw message.channel.send(`**${message.author.tag}**: Kullanıcının profili gizli.`)
}
}

const oyunistatistik = `http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=${steamToken}&steamid=${ozet.response.players[0].steamid}`;
let istatistik = await fetch(oyunistatistik).then(checkStatus).then(url => url.json());

I tried it gives an error message. but it gives a try catch message.

zenith knoll
#

(node:30376) UnhandledPromiseRejectionWarning: Error [GUILD_CHANNEL_ORPHAN]: Could not find a parent to this guild channel.
at TextChannel.lockPermissions (D:\dbots\Modmailtemplate - Copy\node_modules\discord.js\src\structures\GuildChannel.js:272:45)
at D:\dbots\Modmailtemplate - Copy\index.js:47:22
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:30376) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:30376) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

opal plank
#

pong

#

erm, 1 sec

#

debugging here

zenith knoll
#

ok

earnest phoenix
#

@earnest phoenix idk if this helps but you could always just use the native http.request?

#

It's faster and simpler to use

zenith knoll
#

chan.setParent(config.maincategory).then(() => {
chan.lockPermissions()

        })
earnest phoenix
#

in your example, instead of using res.okay, use res.status, because node-fetch is just a wrapper for http.request @earnest phoenix

opal plank
#

what is that function?

zenith knoll
#

uh

opal plank
zenith knoll
#

tryna set permissions to parent

opal plank
#

use that

zenith knoll
#

wat

#

but im tryna sync category to channel

opal plank
#

category IS a channel

zenith knoll
#

er

#

so

tame kestrel
#

It's all channels pepeCRY

zenith knoll
#

channel.overwritePermissions(id of category.permissionOverwrites);

solemn latch
#

even im a channel

zenith knoll
#

channel.overwritePermissions(id of category.permissionOverwrites);
@zenith knoll ?

solemn latch
#

you need the channel class for both @zenith knoll

zenith knoll
#

'?

#

im confused lol

solemn latch
#

"id of category"

#

needs to be the actual category object

opal plank
zenith knoll
#

needs to be the actual category object
@solemn latch so
<server>.channels.cache.get(id)

solemn latch
#

should be

opal plank
#

if you know that id is a category, yeah

zenith knoll
#

yea

opal plank
#

check type

#

<channel>.type === 'category'

solemn latch
#

<channel>.type === 'dog'

opal plank
#

Twitch Abusive Slave goes brrrrr

earnest phoenix
#

@opal plank thats awesome

cerulean laurel
#

good morning at all
i have just like yesterday the same problem with my code
my code doing 3 channal if i tipe (prefix)statson
if the code it is ´the main.js file is still worke but if i make a new file for the com extra the bot is nothing doing

solemn latch
#

@earnest phoenix

#

oop

#

thanks mod

cerulean laurel
#

god morning at all
i have just like yesterday the same problem with my code
my code doing 3 channal if i tipe (prefix)statson
if the code it is ´the main.js file is still worke but if i make a new file for the com extra the bot is nothing doing
@cerulean laurel

solemn latch
#

Statson
vs
statson

cerulean laurel
#

Statson
vs
statson
@solemn latch u meen by the discripton the statson ?

solemn latch
#

the name

cerulean laurel
#

owwww

#

nice know is working 😉 thanks u

opal plank
#

also catID

#

where the heck is that defined?:

unreal token
#

Im getting this error : UnhandledPromiseRejectionWarning: Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.

#

any fix to this issue?

solemn latch
cerulean laurel
#

how i can let command work only if somone have the role or higher

unreal token
#

@solemn latch I tried that but then I got the same error and this error Cannot read property 'triggerReady' of undefined

solemn latch
#

might be triggerClientReady now

unreal token
#

o

#

oof still same response

solemn latch
#

🤷‍♂️

#

its too late for me to dig around the github to find it tbh

unreal token
#

ripo

#

@solemn latch i put it in the same code in the error path (node_modules d.js) and it seems to be working fine

#

like im not getting the error anymore ;-;

#

welp tysm lol

solemn latch
#

We did it pogey aka I did nothing

#

I'm just taking credit

#

Just like in school

unreal token
#

nah I was guided lol

sudden geyser
#

Ladies and gentlemen, we got 'em

blissful coral
#

How do I get all user flags?

#

Someone said it is oauth but bots have it without

#

and I can't figure out how

sudden geyser
#

I don't think you can get all user flags/badges without oauth.

blissful coral
#

Thought so 2

#

but right here

sand condor
#

check for nitro perks, gif avatar, discrim

sudden geyser
#

some of them are just improvises I believe. For example, do you have the nitro booster role

#

I don't think it's reliable as you can't be 100% sure, so I wouldn't bother putting the field myself.

sand condor
#

the creator of the bot already shared his method in this channel

#

it's not 100% reliable but it works sometimes

blissful coral
#

can you link it plz

sand condor
#

i would if i could find it 😅 it would be better off asking him but he does also do the things i said in the message above

blissful coral
#

Well

#
console.log(message.author.fetchFlags().then(flags => flags.toArray().map((flag, counter) => `${counter + 1}- ${(new(require("string-toolkit"))).toProperCase(flag.split("\_").join(" "), true)}`).join("\n")))
#

Found this

#

Promise { <pending> }

#

Get this tho

#

When he evals he doesn't get this tho

#

hmm

opal plank
#

probably awaits it

#

or Promise.resolveAll

sand condor
#

i don't think that's it, nitro information is not shown in userflags (if that's still what your looking for)

opal plank
#

checking gif is a good call tbh

#

though yeah, its not always reliable

blissful coral
#

Hmmm

#

I give up lul

#

He is just the better coder

opal plank
#

apart from userbotting an account to get access to that info, i cant see a reliable way to provide that info thats fail-safe

sand condor
#

yea it's never going to be 100% accurate because there are people with nitro without gif avatars, have normal discriminators, and other things that comes with nitro that they don't use

opal plank
#

could check for emojis in chat too

#

regex match every emoji, check if its a global/server emoji, if not its also a good indicator they have nitro

sand condor
#

yeah but is fetching a users messages that efficient

opal plank
#

though gifs are always nitro iirc

sand condor
#

plus you would also have to choose channels to fetch them from

opal plank
#

i mean, most likely the best and most affordable way would be to require CREATE_INVITE perm and add a userbot there whose sole purpose is to provide extra cache info for the main client, though thats likely against TOS

sand condor
#

lmao

opal plank
#

is it userbotting if the 'bot' doesnt do anything but retrieve info that users have access?

#

one could argue bots should stay on the bots endpoint, period

#

though the same goes for 'its not userbotting if its not automating stuff'

#

request cache => retrieve it => emit to bot

#

idk, im not a staff, ask em'

sand condor
#

good question

opal plank
#

personally, i doubt they'd allow it

sudden geyser
#

over engineering™️

opal plank
#

thats my middle name

sudden geyser
#

Not Over Engineering Erwin

#

Hello Noee

#

That is your new name from now on

opal plank
#

NOEE and the ARC of Ddoss

blissful coral
#

Yeah @opal plank @sand condor I just not gonna do it after lookin at it further

cursive verge
#

is your bot is verified on top.gg , does it get the verified tag?

#

*if

solemn latch
#

You mean the check mark?

drifting wedge
#

R there subusers in galaxy gate?

solemn latch
#

Like account wise? Or making second user accounts on the vps?

viral veldt
#

uhh can i ask about smething?, if we got verified at top.gg but after that the bot is offline

#

can we report it ?

drifting wedge
#

So I can give my devs access

#

Without full perms

solemn latch
#

Yeah any Linux os can do that

drifting wedge
#

Wdym?

#

Like ssh wise?

solemn latch
#

Vps's use Linux mostly

#

As the operating system

fluid basin
#

linux is similar to windows for accounts

#

you can make multiple ones

#

with sudo/admin perms

#

linux permissions is actually quite configurable

#

what will be the purpose of giving other people access though?

drifting wedge
#

Like for example I don’t wanna give access to the code

fluid basin
#

wouldn't having like FTP to transfer files and a restart command be good enough?

solemn latch
#

You can give them anything you want any way you want

fluid basin
#

wait... if you don't want to give them access to the code, then why do they need an account

drifting wedge
#

You can give them anything you want any way you want
@solemn latch so I can only give certain files?

#

wait... if you don't want to give them access to the code, then why do they need an account
@fluid basin well some part of the code

#

My dev team works In a pretty wierd way

fluid basin
#

I wouldn't suggest giving vps access in that case them (imo, personal opinion though)

solemn latch
#

^

agile lance
#

How can I find a channel by name in a variable, I tried the code below and it didnt work.

let welcome = message.guilds.channels.find(chan => chan.name == “new-joins”)

fluid basin
#

there are much more and better collaboration platforms out there

#

such as Github

drifting wedge
#

Ik

fluid basin
#

where you can share and collaborate on code

solemn latch
#

If you can't trust them with all the code you can't trust them with your vps

drifting wedge
#

It’s for installing shit

#

Not coding

#

Alr

#

Ok

fluid basin
#

installing?

drifting wedge
#

Ty

#

Like getting everything setup

#

My bot is really wonky

#

Like REALLLY WONKY

solemn latch
#

Sounds like a docker kinda solution

drifting wedge
#

we need like an api client thingy that we made to make the dashboard work and all sorts of shits

#

It’s super complicated

agile lance
#

How can I find a channel by name in a variable, I tried the code below and it didnt work.

let welcome = message.guilds.channels.find(chan => chan.name == “new-joins”)

fluid basin
#

How can I find a channel by name in a variable, I tried the code below and it didnt work.

let welcome = message.guilds.channels.find(chan => chan.name == “new-joins”)
@agile lance .find returns a Collection, you need to access the collection either though checking the size to see if the channel is found, and them maybe using .first() to get the channel

#

yes we saw your message

#

you didn't need to send it again

agile lance
#

.first() would only check the first channel listed, However in the private bot im making, My channel is listed 6th on the list.

fluid basin
#

then you need to find the channel you want

#

the best would be to use by id

#

name might have more than 1

agile lance
#

How can I use ID?

#

I only ever learned how to use chan => chan.name

wet storm
#

Hello

fluid basin
#

channels.get(channel_id_here)

#

e.g. channels.get("272764566411149314") to get this channel

agile lance
#

so

<guild>.channels.get(“ID”)

#

<guild> is a placeholder for how I define my guild class

#
const guild = message.guild;
const joinChannel = guild.channels.get(“ ID HERE “)

client.on(“guildMemberAdd”, async member => {
await joinChannel.send(“Welcome to the server, “ + member + “!”)
return;
})
#

Will that work?

drifting wedge
#

How can I make Flask redirects with code? Like make redirect automatically?

solemn latch
#

return redirect(url)
On whatever route you want

drifting wedge
#

Like calling from mongo?

solemn latch
#

Like we talked about earlier?

#

Youd have to make an request and build your url from that request

faint prism
#
string input = "This casing should be varied";
string output = input[0];
for(int i = 1; i < input.Length; i++)
{
  if (char.IsUpper(input[i-1]) output += char.ToLower(input[I]);
  else output += char.ToUpper(input[i]);
}
return output;
#

Yeah that'll probably work

vale garden
#
//.. file 1
bot.channels.cache.get(channel).send({embed}).then(() => {

        let a = args[0]

        let b = args[1];

        if (message.content.includes("!")) {

      if (args[0] == "catch" && args[1] == pkmn) {
        //console.log(args[0])
        //console.log(args[1])
        //console.log("test: "+pkmn)
      }
        else {
          message.channel.send("That is the wrong pokemon")
         //console.log(args[1] === pkmn)
        //console.log(args[0] === "catch")

        }

        }

      


      })
#
//.. file 2
bot.channels.cache.get(channel).send({embed}).then(() => {

        if (counter === -1) {

        let a = args[0]

        let b = args[1];

        if (message.content.includes("!")) {

      if (args[0] == "catch" && args[1] == `${pkmn}`) {
       message.channel.send("You have caught a "+pkmn)
       counter = 0;
      // console.log(counter+" test")
      }
        else {
          message.channel.send("That is the wrong pokemon")
        // console.log(args[1] === pkmn)
        //console.log(args[0] === "catch")

        }

        }

      
      console.log(counter)

        }


      })
#

hi plz help

#

for some reason when i run the program using file 1, the commented statements get logged

#

while if i use file 2, the commented statements there dont get logged

#

btw ive commented the statements here just for clarity, the statements arent actually commented

viral veldt
#

while if i use file 2, the commented statements there dont get logged
@vale garden is that bot.channels.cache.get(channel) channel is snowflake?

vale garden
#

yea

#

its the channel id on both

viral veldt
#

Try to catch the errors

vale garden
#

and quick update btw, the statements on the else block of file 2 do get logged

agile lance
#
const guild = message.guild;
const joinChannel = guild.channels.get(“ ID HERE “)

client.on(“guildMemberAdd”, async member => {
await joinChannel.send(“Welcome to the server, “ + member + “!”)
return;
})

Will this work for a private bot to send welcome messages?

vale garden
#
if (args[0] == "catch" && args[1] == `${pkmn}`) {
        try {
       message.channel.send("You have caught a "+pkmn)
       console.log(counter+" yeet")
       counter = 0;
        }
        catch (err) {

  console.log("error")

}
      }
#

@viral veldt i did this and still nothing has been logged

viral veldt
#

hmm

agile lance
#

I know why

viral veldt
#
const guild = message.guild;
const joinChannel = guild.channels.get(“ ID HERE “)

client.on(“guildMemberAdd”, async member => {
await joinChannel.send(“Welcome to the server, “ + member + “!”)
return;
})

Will this work for a private bot to send welcome messages?
@agile lance yes