#development

1 messages · Page 1251 of 1

vernal rivet
#

np

#

@earnest phoenix idk how safe using a while loop for what you want to do is. I honestly would think using a foreach loop would be better, and safer. while loops are conditional, meaning it is checking if something is true or false. foreach loops, doesn't, it goes through each item in a object/array, making the item into an object to be use.

earnest phoenix
#

yh i need it to check if its true or false

vernal rivet
#

you can do that inside a foreach loop. you can use if-else if-else statements

earnest phoenix
#

but i need it to keep looping till its true

#

continue

vernal rivet
#

you can use break, and continue in a while loop

earnest phoenix
#

yeah i was gonna use that, but it will still emit the variable = true which will put a user together even if their id is in the db tho right?

#

why do you need that bool in the first place

#

bool ?

vernal rivet
#

bool = boolean

earnest phoenix
#

because people cant be in the same game

eternal osprey
#

hey how do i make my command automated, so it will send this info every 1 minute? ```@client.event
async def on_message(message):
'''Bot replies back with sneaker info when it sees a command.'''

if message.author == client.user:
    return


if message.content.startswith('!nike'): 
    
    if r.ok:
        shoes = get_nike_shoes()  
        links = get_links()  
        bot_message = ''  

        for shoe, link in zip(shoes, links): 
            bot_message += shoe + '\n' + link + '\n\n'

        bot_message += 'For more Nike Sneakers releases and info: ' + NIKE_SNKRS_URL
        await message.channel.send(bot_message) 
    else: 
        await message.channel.send('We could not make contact with the Nike site. Our conclusion is that the Nike site is down. Please try again later!')```
earnest phoenix
vernal rivet
#

shrug i don't work with py

earnest phoenix
#

How do I keep it on the existing page if there are no more pages?

vernal rivet
#

use if statments

earnest phoenix
#

even if it's not worth it
what
How do I keep it on the existing page if there are no more pages?
don't allow it if the current page is equal to max pages

#

what
don't allow it if the current page is equal to max pages
@earnest phoenix how

#

magic

#

where did you copy the paginator from

vernal rivet
#

are you storing the pages into a array?

earnest phoenix
#

are you storing the pages into a array?
@vernal rivet yeah

vernal rivet
#

do you have a variable that has the current page number?

earnest phoenix
#
 if (reaction._emoji.name === "◀️") {

          i0 = i0 - 10;
          i1 = i1 - 10;
          page = page - 1;

 .setTitle(`Sayfa: ${page}/${Math.ceil(bot.guilds.cache.size / 10)} (${bot.guilds.cache.size} sunucu)`)
vernal rivet
#

thats a werid way of doing it.

#

are you using a Reaction Collector?

earnest phoenix
#

yeah

#

Do not do anything if the current page is ${Math.ceil (bot.guilds.cache.size / 10)} (2). how do i do such an operation

#
if(i0 < 0){

}
vernal rivet
#
/***
 *  @typedef {String[]} pages 
 */
 if (reaction._emoji.name === "◀️") {
          if(page === pages.length) return;
          i0 += 10
          i1 += 10;
          page++;
 .setTitle(`Sayfa: ${page}/${Math.ceil(bot.guilds.cache.size / 10)} (${bot.guilds.cache.size} sunucu)`)
}
 if (reaction._emoji.name === "◀️") {
          if(page === 0) return;
          i0 -= 10
          i1 -= 10;
          page--;

 .setTitle(`Sayfa: ${page}/${Math.ceil(bot.guilds.cache.size / 10)} (${bot.guilds.cache.size} sunucu)`)

Should look something like this.

earnest phoenix
#

don't spoonfeed them code

vernal rivet
#

its fine, its not showing them that much

earnest phoenix
#

yeah i see, could've still explained it though

eternal osprey
#

i still have not find the answer in the doc @earnest phoenix

vernal rivet
#

i mean could have, but at the exact same time, we would be here for a while if i were to explain it

earnest phoenix
#

@eternal osprey i literally took a screenshot of the section

eternal osprey
#

no

earnest phoenix
#

oh that

eternal osprey
#

this is all you sent

earnest phoenix
#

what's confusing

#

if you would just read through the doc you would get what you need to do

#

i don't even work with python and i know what to do

ancient nova
#

how would you do a skipto command for a music bot? (so it would give an ID to each song (1,2,3,4 etc) and you can get the numbers by looking up on 1queue commamd, and what I need is an example that you could skip to any song currently playing in the queue by comand example 1skipto 2 the output would be "Skipped to the second song in the queue". the song that was playing and songs before the given number are deleted from the queue and the song with ID of 2 changes their ID to 1 and starts playing) ANY IDEAS?

#

forgot to mention

#

I am using djs

vernal rivet
#

shrug just have it remove x amount of items in a array/map/list/what every you stored the songs in.

ancient nova
#

well, I am using a map, but when I tried to get map by var and for example doing getMap[2] <- "2" would signify the pos of the song in the queue. which should return my song right? I have made a outputs which should infact work, but it says that it's not defined

earnest phoenix
#

Hi again, I could use some help, this has been a problem for a while and i have yet to find the solution or a work around, all help is appreciated. Thanks in advanced!

Here are some Images of my problem and other things related to it:

#

why are you making it a promise

#

I run the query in mysql too and it gets the data required by the way so I don't think its the query.

#

why are you making it a promise
@earnest phoenix It was the only way I got with some help for it to get the data from the table before, I may have assumed it would work the same way here. Could you explain why it shouldn't be a promise?

#

it's valid to wrap it around one, i was just wondering why you were making it one

#

then i read up on the mysql package and it only does callbacks

#

Ah

#

It's kind of weird, it doesnt seem to be getting the value like it should be for some strange reason and comes out with no data.

#

It's showing no data being retrieved, but there is no error, yet when i do the query inside mysql, sure enough it locates the data

#

tried logging your statement yet?

#

actually print out to console what the statement looks like

#

the actual string of the statement

opal plank
#

uppercase commands

#

you monster

earnest phoenix
#

the actual string of the statement
@earnest phoenix sorry, can you explain? My mind went blank lol

#

uppercase commands
@opal plank doesn't have to be

opal plank
#

ik

earnest phoenix
#

i put a screenshot

opal plank
#

its just more redable

earnest phoenix
#

fair

opal plank
#

same reason why you'd use pascal Case

#

standard

earnest phoenix
#

i put a screenshot
@earnest phoenix what about it again? I don't think I understood 😅

#

log that string to console

#

see if everything's correct

#

then run the string through mysql to see if it returns data properly

#

weird

#

the userid is different from mine?

#

but what is this userid?

#

huh? why is it getting the bots userid?

#

are you sure the msg is the message you get from the event

#

and not the bot's message

#

keep in mind that bots also get their own messages

#

hmm, now that i think about it it could potentially be that but I don't know why it would do that...

quartz kindle
#

what data type did you define userid as?

#

varchar?

earnest phoenix
#

possibly

#

the problem seems to be that the bot is getting its own id though

#

so how would i prevent that from happening and it finding the userid of the person who used the command?

#

it seems to fire when a command is used

#

which actually makes sense now that i think about it

#

keep in mind that bots also get their own messages

#

simply return out of the listener if the message author is a bot

#

Is there a way to get an users intigrations? (Discord.js)

#

only through oauth2

#

okay thank you

wicked pivot
#

hi, anyone have an example of chart.js

limber flume
#

hey discord.py problem when i do a on_message_event event and i send the before and after content it spams the channel with embeds saying the bot is editing the message when its not here is a photo https://im-a-dev.xyz/D6kN7Sbd.png

sudden geyser
limber flume
#

@sudden geyser The message has received an embed. what this mean

sudden geyser
#

I think it would mean like messages with links.

#

You know, that preview stuff.

fickle arch
#

@fickle arch what are you struggling on with it?
@vernal rivet learning to make music function xd

jovial nexus
#

is there a way to connect all the shards of my bot?

limber flume
#

thanks @sudden geyser i fixed it

sudden geyser
#

Where's the difference?

limber flume
#

well i was putting it in something like this hello

#

and that triggered a loop i think

opal plank
#

dude chill, your message is 3 messages above

#

spam wont get you anywhere

silver lintel
#

How to get the bots pfp? Js

opal plank
#

your own?

silver lintel
#

Yes

opal plank
sudden geyser
#

client.user

opal plank
#

or that

silver lintel
#

So something like client.user.avatarURL?

sudden geyser
#

yes

#

avatarURL is a method just so you know

opal plank
fickle arch
#

what the different of module.exports with exports.run ?

opal plank
#

now just gotta switch the console lot to an emitter

thick gull
#

pog

eager meteor
#

gers

indigo flax
opal plank
#

just ask your question

indigo flax
#

File "main.py", line 352, in <module>
main()
File "main.py", line 348, in main
DiscordBot().run(config.DISCORD_TOKEN)
File "main.py", line 18, in init
allData = data.loadJSON(data.DATABASE_FILENAME)
File "/home/container/data.py", line 91, in loadJSON
with open(getFileName(fileName), 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'database.json'

opal plank
#

well

#

FileNotFoundError: [Errno 2] No such file or directory: 'database.json'

indigo flax
umbral zealot
#

do you?

indigo flax
#

File "main.py", line 352, in <module>
main()
File "main.py", line 348, in main
DiscordBot().run(config.DISCORD_TOKEN)
File "main.py", line 18, in init
allData = data.loadJSON(data.DATABASE_FILENAME)
File "/home/container/data.py", line 92, in loadJSON
return json.load(f)
File "/usr/local/lib/python3.8/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/local/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

umbral zealot
#

your json seems to be malformed

#

you might want to consider not using json as your database. that's really, really dumb.

indigo flax
#

inside my .json its {}

#

i mean

#

in my .json

umbral zealot
#

yeah don't do that. there are much better ways.

indigo flax
#

its nothing

#

its blank

umbral zealot
#

I'm sure you can find an easy sqlite database wrapper or something.

indigo flax
#

File "main.py", line 352, in <module>
main()
File "main.py", line 348, in main
DiscordBot().run(config.DISCORD_TOKEN)
File "main.py", line 18, in init
allData = data.loadJSON(data.DATABASE_FILENAME)
File "/home/container/data.py", line 92, in loadJSON
return json.load(f)
File "/usr/local/lib/python3.8/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/local/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

#

what does that mean

umbral zealot
#

it means you should not use json as a database.

earnest phoenix
#

please don't use it as a database

indigo flax
#

Traceback (most recent call last):
File "main.py", line 352, in <module>
main()
File "main.py", line 348, in main
DiscordBot().run(config.DISCORD_TOKEN)
File "main.py", line 19, in init
self.masterIDs = allData['Masters']
KeyError: 'Masters'

umbral zealot
#

I don't even know python and I'm sure I know what that error is.

#

Have you considered perhaps learning python before making bots? you seem to have issues with the basics.

indigo flax
#

read my status

#

:/

umbral zealot
#

I say the same to beginner JS devs: Learn the language Before making bots. Bots are hard, they use complex concepts that are hard to grasp for beginners.

indigo flax
#

ik json but not a lot of py

opal plank
#

i wonder if w3schools has a py course

umbral zealot
#

if not codecademy probably does

#

The answer to "I don't know a lot" is the same as "I'm learning": go do some online courses or tutorials for basic python first, take a couple weeks, and once you feel comfortable, then do bots.

opal plank
#

i think w3 focuses most on web langs tbh

#

Im now happy with the result of my cache

#

Happy when i see it

#

sad when i realize its only step one out of 3

drifting wedge
#
    @commands.group
    @cooldown(1, 0.5, BucketType.user)
    async def dep(self, ctx):
        await ctx.send(':lock: Command locked')

    @dep.command
    @cooldown(1, 0.5, BucketType.user)
    async def all(self, ctx, arg, member: discord.Member = None):```
#

this wont work?

#

fuction not attribute of command

proven lantern
#

can my bot have a global command like this !set-bot-prefix?

silver lintel
#

Yes

opal plank
#

I dont trust my code

#

its working too well

#

cant do much without more info

#

¯_(ツ)_/¯

vernal rivet
#

shrug what does your code look like?

opal plank
#

event emitter working nicely

#

though its odd no one started streaming

vernal rivet
#

@Typical Finney#5282 idk if someone answered your question but the difference between module.exports, and export.run is actually more of a question of what the difference of module.exports and export. The main difference is that module.exports passes it's body as an object. Example

// Message.js
module.exports = "Hello World";

// Index.js
var msg = require("./Message.js");

console.log(msg); // prints out Hello World

Exports is very similar but it passes it's body into a property.
Example

// Message.js
exports.message = "Hello World";

// Index.js
var msg = require("./Message.js");

console.log(msg.message); // prints out Hello World

They are very similar.

quartz kindle
#

exports is basically a shortcut for module.exports

#

its a reference to the same initial value

glossy elk
#

"change RichEmbed to MessageEmbed" hope that helps

worthy glacier
#

right now this just returns the first image in each entry first, but i want it to be randomized so that it returns a different image each time

glossy elk
#

You know you can just do !args[0] without needing to do args.length == 0

quartz kindle
#

!args.length would be semantically more correct but yeah [0] is shorter lol

glossy elk
#

Yeah, I mean I am just saying it's kind of useless

worthy glacier
#

images.entries returns an iterable so i want i to be random so i can return a random value from the entries

glossy elk
#

Also, off topic question @worthy glacier

#

What theme is that

quartz kindle
#

assign image.values() to an array, then use the Math.random() on array.length thingy

worthy glacier
#

dracula @glossy elk

#

ok ill try that @quartz kindle

earnest phoenix
#

Discord bots are impossible to be hacked unless their server ip and password or token gets leaked right?

umbral zealot
#

yes.

quartz kindle
#

the bot token is pretty much the only attack vector

umbral zealot
#

I mean, unless you mess up your permissions and give open access to an eval function to execute arbitrary code on the server.

#

so... bad code, token leak, or your VPS being accessed.

quartz kindle
#

your server and infrastructure would be a different category of attack, because it doesnt really target your bot specifically, if your server ever gets hacked, 90% chance the hacker is not targeting your bot, they just want to install viruses and turn it into a zombie

earnest phoenix
#

What tim said

umbral zealot
#

ohai Zoro!

silver lintel
#

I've got a

module.exports = {

}```thing, and I wanna use client.user, but it says client is undefined because it's not there, but I already defined it as a new discord client in another file
umbral zealot
#

well, is what you're exporting a function?

silver lintel
#

Yes

#

execute: Async function(message, args) {}

umbral zealot
#

then you should provide your client to that function when calling it

#

then again in this case, message.client would work just as well

silver lintel
#

:O

south forge
#

ku

earnest phoenix
#

ohai Zoro!
blobwave

silver lintel
#

I've got .setThumbnail(message.client.user.avatarURL) but it's not working

sudden geyser
#

If you're using Discord.js v12, .avatarURL is a method.

quaint hornet
#

i am out of creativity to think in new commands for my bot

#

i wonder if anyone have any ideia

thin turret
#

Create a command that gives you command ideas

sudden geyser
#

@quaint hornet what is your bot about

quaint hornet
#

everything

faint prism
#

Plenty of those around

sudden geyser
#

is there one specific thing your bot excels at // one category your bot is very good at

quaint hornet
#

well most part of the commands are about music

faint prism
#

Excels at nothing, amateur at everything

worthy glacier
silver lintel
#

Check logs

austere fern
#

How to add my bot?

umbral zealot
quaint hornet
#

i has thinking about some command of AI

quartz kindle
#

array.push[] is not a thing

#

its array.push()

quaint hornet
#

but What is too important that need to be executed by a AI

#

i never see someone using const [i, value] of array before

umbral zealot
#

that's actually called destructuring.

quaint hornet
#

interessing

quartz kindle
quaint hornet
#

🤔

#

What the diference of typescript and javascript?

sudden geyser
#

TypeScript is if JavaScript forced you to be strict and gave you what other OOP languages give you.

#

A more proper definition would be to see it for yourself: https://www.typescriptlang.org

TypeScript is still compiled down to JavaScript in the end.

quaint hornet
#

a javascript turned into a csharp?

sudden geyser
#

into a higher oop

quaint hornet
#

javascript but everithing is a object?

tired nimbus
#

is there a way to see what is most closely related to a given string in an array?

quaint hornet
#

if you want to search for a similiar thing in a array

#

have a package

tired nimbus
#

hm

quaint hornet
#

you give a word and a array

tired nimbus
#

which one

quaint hornet
#

and he show the most similar

#

and a array of similar thing

#

and give to it scores

sudden geyser
#

What do you mean by "closely" related. Sounds like you want to iterate over an array doing something on each element until you find something that matches.

tired nimbus
#

I mean like even if you misspell Pikachi it auto corrects to Pikachu because its the most closely related

quaint hornet
#

well than you want that package

#

string-similarity

#

the name

sudden geyser
#

What you're probably looking for is called the Levenshtein distance.

tired nimbus
#

if it doesnt use a package and is more efficient than a package then I will accept that as the best answer

#

oh I found it on stack overflow

#

dont mind if I do...

sudden geyser
#

If you end up implementing it, I recommend you set it to a number based on the length of their input (in case what you're matching against is short) and a low number, like 2-3.

modest smelt
#

i have a question

#

how do i make a welcoming channel through discordpy

#

pls hel

#

help*

tired nimbus
silver lintel
#

message.channel.send(message.author.avatarURL({ dynamic: true, format: 'png', size: 1024 })); how do i make it so it sends the bots pfp, not the users?

modest smelt
#

thats pretty ez @silver lintel

#

ur using discordpy?

silver lintel
#

nop

#

discord.js

modest smelt
#

ok then idk

fickle sapphire
#

Client.user

#

I think

modest smelt
#

how do i make a welcoming channel through discordpy

silver lintel
#

im doing it inside a

module.exports = {
  execute: async function(message, args) {

  }
}
#

and client isnt defined

tired nimbus
#

then define client

#

pass client in the parameters yes

fickle sapphire
#

^

quaint hornet
#

everyday i ask my self WHY, WHY!!!

silver lintel
#

console says DiscordAPIError: Cannot send an empty message

earnest phoenix
#

Hi! , I have a question, how can I block the private messages that reach my bot?

summer torrent
#

check if message channel's type is dm then return it

quaint hornet
#

console says DiscordAPIError: Cannot send an empty message
your message probabily is just a space

#

like this

silver lintel
#

then hoe 2 ficks?

quaint hornet
#

i don't know

#

what code is sending the message

summer torrent
#

what are you trying to do

quaint hornet
#

ar i undestando

#

probabily there so lag

#

or you do something wrong getting the url

silver lintel
#

get the bots pfp, the code is
message.channel.send(client.user.avatarURL({ dynamic: true, format: 'png', size: 1024 }));

earnest phoenix
#

I'd prefer 2048 instead of 1024

quaint hornet
#

2048 is too big

#

it will consume more for nothing

worthy glacier
#

how do i use client.startTyping() discord js

quaint hornet
#

1024*1024 is almost fullHD

silver lintel
#

DiscordAPIError: Cannot send an empty message ^^^^ SyntaxError: Unexpected identifier

worthy glacier
#

how do i make it so my bot id "typing" in the chat

#

so it shows the status underneath the bar

sudden geyser
worthy glacier
#

so i need to resolve the promise by sending a message?

sudden geyser
#

It resolves when the bot stops typing, which I think is based on the count parameter.

#

I'm a bit confused on what it means, but I think it means the number of times the typing thing should be considered "active". I'd assume it resolves on its own, but you could test it to see.

worthy glacier
#

ok thx

#

it seems to work during the command but continues aftwerwards continuously until i use another command

#

i might have to use .stopTyping at the end of commands

sudden geyser
#

Oh yeah

#

You will need to use that if you want it to stop as soon as the command is over.

quartz kindle
#

djs's typing is a mess

sudden geyser
#

I wish typing could be disabled as a user setting

#

don't need to be up at 3 am then accidently hit my keyboard

#

"everyone now knows you are here"

quartz kindle
#

lmao

#

discord's typing system is also a mess

silver lintel
#

how do i crop an image in an embed if i have an image link?

quartz kindle
#

you need to download the image and process it with some editor, like canvas, sharp, jimp, etc

silver lintel
#

oh

worthy glacier
sudden geyser
#

Make sure you check for errors and whatnot that may be thrown from the .run() method // make sure the typing will actually stop

#

A try block could help

quartz kindle
#

i just do this lol await message.client.api.channels(message.channel.id).typing.post();

sudden geyser
#

that reminds me, why do they make .api return nothing if you try and display it

#

I can't test it but it would return nothingness and no form of property access would show anything when I tried it with an eval command in the past

quartz kindle
#

its a proxy

sudden geyser
#

ah, I've never tried out proxies in js

quartz kindle
#

its pretty smart what they did, but at the same time so unnecessary and overly complex lmao

#

basically its a route builder, where methods are converted to api paths, ie .channels() is converted to "/channels" and .channels(id) is converted to "/channels/id"

#

and so on until you call one of the actual methods (get,post,etc), then it intercepts those and makes the request with the stored path

#

try console.log(client.api.a(1).b(2).c(3)) lul (if it doesnt show anything, add .toString())

sudden geyser
#

oh, that actually looks very useful

silver lintel
#

ive got an image in the assets, what file directory like ../ would i need to get that image?

quartz kindle
#

most likely ../assets/image.png

silver lintel
#

oh thank you

ionic dawn
earnest phoenix
#

ok

#

anyone know how to

#

limit the command

#

to one channel

#

like a verify command

ionic dawn
#

Database

#

That checks if the user used the command already

earnest phoenix
#

no like

#

you can only use the command]

#

in one channel

#

rip

#

ima go ham mode

#

to try myself

opal plank
#

attach a listener to that channel

#

and then if !message.content.startsWith(command) message.delete()

#

@earnest phoenix

ionic dawn
#

If message.channel isnt the channel you want return

earnest phoenix
#

eh nah thats not gonna work as well as i want it to so ill do another way

ionic dawn
#

Else so stuff and msg.delete

silver lintel
#

rendered = rendered.trimRight(); is this outdated becayse the connsole says TypeError: Cannot read property 'trimRight' of undefined

#

or is rendered undefined?

topaz fjord
#

rendered is

restive notch
dire obsidian
#

Its typescript that good or is like php?

summer torrent
#

@restive notch it is a custom css i guess

quartz kindle
#

typescript is a javascript compiler, has nothing to do with php

dire obsidian
#

Nonono

#

I mean

#

Typescript is sh*t?

quartz kindle
#

no, its not shit

restive notch
#

@summer torrent but you can only change the css of the text box

dire obsidian
#

Ok thanks

summer torrent
#

check dev tools

restive notch
#

lol he called php s*it

summer torrent
#

there is something like .status purple

pale vessel
#

i use php trollsad

restive notch
#

@summer torrent ok

quartz kindle
#

i still use some php as well lol

restive notch
#

ehh php is ok but its helpful

sudden geyser
#

"Ugly problems often require ugly solutions. Solving an ugly problem in a pure manner is bloody hard"

dire obsidian
#

Im just here for the meme

quartz kindle
#

if you want memes, both js and php are memed hard

sudden geyser
#

still love that quote from the creator

quartz kindle
#

but i guess php is memed a bit more

sudden geyser
#

JS was probably memed a lot more in the past.

summer torrent
sudden geyser
#

I can't imagine using it without em6

pale vessel
summer torrent
#

🤔

#

I'm using same code in my exec command and it works fine

sudden geyser
#

What is exec declared as.

restive notch
summer torrent
#
const { exec } = require("child_process")
pale vessel
#

wouldn't you need to promisify that if you're going to use await?

stark abyss
#

someone take my hand and walk me though mongodb

summer torrent
#

oh wait

stark abyss
#
const MongoClient = require('mongodb').MongoClient;
const uri = `mongodb+srv://${dbuser}:${dbpass}@cluster0.dszlo.mongodb.net/<dbname>?retryWrites=true&w=majority`;
const dbclient = new MongoClient(uri, dbOptions);
dbclient.connect(err => {
  const collection = dbclient.db("test").collection("devices");

  dbclient.createCollection( "contacts",
   { validator: { $or:
      [
         { phone: { $type: "string" } },
         { email: { $regex: /@mongodb\.com$/ } },
         { status: { $in: [ "Unknown", "Incomplete" ] } }
      ]
   }
} )

  dbclient.close();
});```
summer torrent
#

@pale vessel ty

stark abyss
#

why am i getting an error

#

dbclient.createCollection is not a function

#

how do I even use mongodb their docs is so confusing

quartz kindle
#

afaik collections are created automatically if they dont exist

stark abyss
#

okay

#

but how do fix it

quartz kindle
#

dbclient by itself is only the client, you cant do anything to it directly

#

you have to work on your database, "test"

stark abyss
#

oh

opal plank
#

WHO DARETH SAY TS IS SHIT?

quartz kindle
#

so if createCollection exists and is valid in mongodb (idk since i dont use mongo), it will likely be on the db, not in dbclient

opal plank
stark abyss
#

erwin you okay Pat

quartz kindle
#

therefore db = dbclient.db("test"); db.createCollection()

stark abyss
#

i see

valid frigate
#

is that not just pollution though

#

could it not be chained

opal plank
#

no im not okay

#

someone said ts is shit

valid frigate
#

oh you want to make it first

quartz kindle
#

most likely it can, but one would assume the database variable will be reused many times throughout the code

valid frigate
#

nvm then oooooooooooh

#

hmm

#

im curious how most bot devs approach this--storing the database client globally or generating a new one for each command

#

from a client pool

#

id much rather prefer the latter tbf

quartz kindle
#

for a high-concurrency long-running process, the more stuff you can keep open/connected the better

wanton aurora
#

Day two and not a single line of code exists

quartz kindle
#

magic

valid frigate
#

smm

#

hmm

carmine summit
#

let object = await axios(url).catch(function (error) {message.channel.send(error.message)});
is there any way to make this shorter?

opal plank
#

let object = await axios(url).catch((e)=> {message.channel.send(e.message)});

thick gull
#

wait fuck this is development

carmine summit
#

let object = await axios(url).catch((e)=> {message.channel.send(e.message)});
@opal plank What happened to everything?

opal plank
#

@thick gull itss technically development

#

testing a new commit

thick gull
#

Testing on prod

carmine summit
#

let object = await axios(url).catch((e)=> {message.channel.send(e.message)});
@opal plank How do I use throw??

opal plank
#

by reading the docs

carmine summit
#

oh

#

ok

opal plank
#

nah thats locally

#

you dont think my production would have only 86 streams do ya?

carmine summit
#

@opal plank Where do I put throw "Not Found"

#

How do I put all the objects inside an array?

faint prism
#

How do I put all the objects inside an array?
@carmine summit the same way you put anything in an array

carmine summit
#

no i mean

#

i dont know the name of the objects

#

its randomized

faint prism
#
let myArr = []
myArr[0] = someObj
#

What do you mean?

#

iirc arrays in JS can be any type of obj

carmine summit
#

nvm

#

Where do I put throw "Not Found" in let object = await axios(url).catch((e)=> {message.channel.send(e.message)}); ???

drifting wedge
#
@commands.group
    @cooldown(1, 0.5, BucketType.user)
    async def dep(self, ctx):
        await ctx.send(':lock: Command locked')```

 ```py
  @dep.command
    @cooldown(1, 0.5, BucketType.user)
    async def all(self, ctx, arg, member: discord.Member = None):```
this wont work?
fuction not attribute of command
sudden geyser
#

You put it where you want it to throw an error saying "Not Found". We can't really tell you where to place something, but .catch may have something to do with it? I'm confused on what you really want.

#

@drifting wedge what is the real error message pls

drifting wedge
#

discord.ext.commands.errors.ExtensionFailed: Extension 'currency' raised an error: AttributeError: 'function' object has no attribute 'command'

#

@sudden geyser

sudden geyser
#

Could you try calling .group() to see if anything changes? Also, what line is the error specifically coming from (is it @dep.command?).

modest smelt
#

hey i need help

#

in discordpy welcome channel

#

pls help me

slender thistle
#

@drifting wedge CaLl The DeCoRAToR

earnest phoenix
#

okay

#

i came back

#

after making other code

#

to fiond out

#

how to check if the user is doing the command

#

in the right channel

faint prism
#

Ok

drifting wedge
#

@drifting wedge CaLl The DeCoRAToR
@slender thistle fixed it

earnest phoenix
#

so

#

can you help

#

please

silver lintel
#

how do you make a mute role that overides every channel so a user cant type?

earnest phoenix
#

i used to know

#

ill check my code

#
  message.channel.overwritePermissions([
            {
                id: message.guild.roles.everyone, deny: ["SEND_MESSAGES",] 
            }
``` thats a channel permission override you can simply change it to be a role
modest smelt
#

Can someone help me?

#
@client.event
async def on_member_join(ctx, member):
    await member.send(f'Hope you like the server! {member.mention} make sure to check out the rules!')
    embed = discord.Embed(title = "Welcome", description = f"{member.mention} Just Joined \nWelcome to our server :partying_face: \nStay Here and Buy Some Discord Bots! \nYou are the {len(list(member.guild.members))} member!")
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text = f"{member.guild}", icon_url = f"{member.guild.icon_url}")
    embed.set_author(name = f"{member.name}", icon_url = f"{member.avatar_url}")
    embed.set_thumbnail(url=f"{member.avatar_url}")
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    channel = guildInfo[ctx.message.guild.id]

    await channel.ctx.send(embed = embed)
#

this is my code

silver lintel
#
let muteROle = guild.roles.create({ data: { name: 'Mod'});
muterole.overwritePermissions([
            {
                id: message.guild.roles.everyone, deny: ["SEND_MESSAGES",] 
            }
```? idk
modest smelt
#

but when i run it

#

it says: TypeError: on_member_join() missing 1 required positional argument: 'member'

#
@client.event
async def on_member_join(ctx, member):
    await member.send(f'Hope you like the server! {member.mention} make sure to check out the rules!')
    embed = discord.Embed(title = "Welcome", description = f"{member.mention} Just Joined \nWelcome to our server :partying_face: \nStay Here and Buy Some Discord Bots! \nYou are the {len(list(member.guild.members))} member!")
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text = f"{member.guild}", icon_url = f"{member.guild.icon_url}")
    embed.set_author(name = f"{member.name}", icon_url = f"{member.avatar_url}")
    embed.set_thumbnail(url=f"{member.avatar_url}")
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    channel = guildInfo[ctx.message.guild.id]

    await channel.ctx.send(embed = embed)

error: TypeError: on_member_join() missing 1 required positional argument: 'member'

#

pls help me

slender thistle
#

Why DM me personally again

sonic lodge
#

you're not providing all the required arguments?

silver lintel
#
thing1
await thing2
thing3

does thing3 only happen after await thing2 has been done?

modest smelt
#

@sonic lodge i tried doing this:

#
@client.event
async def on_member_join(member):
    await member.send(f'Hope you like the server! {member.mention} make sure to check out the rules!')
    embed = discord.Embed(title = "Welcome", description = f"{member.mention} Just Joined \nWelcome to our server :partying_face: \nStay Here and Buy Some Discord Bots! \nYou are the {len(list(member.guild.members))} member!")
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text = f"{member.guild}", icon_url = f"{member.guild.icon_url}")
    embed.set_author(name = f"{member.name}", icon_url = f"{member.avatar_url}")
    embed.set_thumbnail(url=f"{member.avatar_url}")
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    channel = guildInfo[member.guild.id]

    await channel.send(embed = embed)
#

but i get an error

#
    channel = guildInfo[member.guild.id]
KeyError: 747929495427874836```
sonic lodge
#

don't change the function header

#

show me where you call on_member_join

modest smelt
#

wdym

#

on_member_join is an event

#

when a member joins, this happens...

sonic lodge
#

oh, this is what happens when a js dev with little python experience tries to help

modest smelt
#

oh lol

silver lintel
#

you can see async def on_member_join(member):

#

its an event

sonic lodge
#

you are really overestimating my python knowledge

#

i just thought the problem was a general programming one

modest smelt
#

@silver lintel do u know how to help?

#
@client.event
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("filename.json", "w") as f:
        json.dump(guildInfo, f)

#allows server members to set channel for welcome messages to send to    
@client.command()
async def welcomeChannel(ctx):
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[ctx.message.guild.id] = ctx.message.channel.id #sets channel to send message to as the channel the command was sent to

    with open("filename.json", "w") as f:
        json.dump(guildInfo, f)
    
    await ctx.send(f"I have set the welcome channel!")

@client.event
async def on_member_join(member):
    await member.send(f'Hope you like the server! {member.mention} make sure to check out the rules!')
    embed = discord.Embed(title = "Welcome", description = f"{member.mention} Just Joined \nWelcome to our server :partying_face: \nStay Here and Buy Some Discord Bots! \nYou are the {len(list(member.guild.members))} member!")
    embed.timestamp = datetime.datetime.utcnow()
    embed.set_footer(text = f"{member.guild}", icon_url = f"{member.guild.icon_url}")
    embed.set_author(name = f"{member.name}", icon_url = f"{member.avatar_url}")
    embed.set_thumbnail(url=f"{member.avatar_url}")
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    channel = guildInfo[member.guild.id]

    await channel.send(embed = embed)
```my entire code
slender thistle
#

Are you going to keep messaging me and this server at the same time

modest smelt
#

no

sonic lodge
#

apparently KeyError appears when you try to access a dictionary with a key that doesn't exist

silver lintel
#

sorry, i cant help, my python knowledge is even less than pooled

sonic lodge
#

see if there exists a key in guildInfo before accessing it

slender thistle
#

P.S. just because you think it exists doesn't mean it actually exists

#

Workaround is to use guildInfo.get and check if it returned None

modest smelt
#

so what should i do?

slender thistle
#

I just said what you can do

silver lintel
#
thing1
await thing2
thing3

does thing3 only happen after thing2 is done?

slender thistle
#

As far as I'm familiar with asynchronousness (I barely am), yes

modest smelt
#

I'm not really sure what you mean by

Workaround is to use guildInfo.get and check if it returned None

slender thistle
#

Search dict.get python on Google

modest smelt
#

ok

#

so how should i use that?

#

@slender thistle when i look at my file, where it stores the dict

#

it shows this

#

{"747929495427874836": 748295756053741770}

#

maybe is it because the keyname is a string?

slender thistle
#

Yes

modest smelt
#

ok

#

how can i change that tho?

#

u saw my entire code

slender thistle
#

Stringify the ID when trying to access the key

modest smelt
#

ok

silver turtle
#

@earnest phoenix what should I see here? :)

earnest phoenix
#

Let see

#

You need to make a bot that detect when dsl bot give out the vote role

#

When the dsl give the vote role to someone, that mean that person voted your server

#

So yeah, thats all.

wanton aurora
#

hopefully iOS 14 gives me better file access so I can run this bih

#

Also the phone I’m using is stuck in beta and I can’t go back to 13

opal plank
#

i can tell you right now

#

you likely wont get anywhere using IOS

#

bots running on iOS? good luck

sudden geyser
#

Why would you want to do that in the first place.

fickle arch
#

I still don't understand the different of module.exports with exports.run

earnest phoenix
#

@fickle arch so

#

exports mean export stuff

#

You can get stuff by require the file

#

For example

#

example1.js

exports.hi = 'hello';
exports.bool = false;
exports.json = {
 "e":"i"
}
#

And on example2

#

example2.js

const example1 = require("example1.js");
example1.hi // hello
example1.bool // false
example1.json // that json data
#

module.exports mean export something as default

#

example

#

module.exports = "e"

#

require("example"); // e

#

I tried my best to explain it

fickle arch
#

I think I get it now.

#

Thanks for explaining it.

earnest phoenix
#

Np

boreal flume
#

Is there a way I can make a bot send a message in a channel if a member upvotes a server on the top.gg discord server list

earnest phoenix
#

Idk if server webhook exist or not

#

But if it exist, use the webhook method

#

But webhook method is not recommded

boreal flume
#

That is easy, you can just use the bot.on('roleUpdate') event listener, correct?

earnest phoenix
#

Yes

#

However, you need the owner to slecify the role id for the voting

#

So besure to do that

#

also

#

memberRoleUpdate

fickle arch
#

anyone could give me good API for punch command 🤔

earnest phoenix
#

@fickle arch
Theres alot

fickle arch
#

Let me see it.

worthy glacier
#

ty @quartz kindle that worked perfectly

boreal flume
#

There is not memberRoleUpdate listener

earnest phoenix
#

KSoftAPI,
nekos.life (not recommded),
nekos.club (not recommded),
asuna.ga (maybe recommded),
weebsh (invite only).

#

@boreal flume member update

boreal flume
#

Is there a role parameter for that?

earnest phoenix
#

well

#

memberUpdate return

#

oldMember:GuildMember and newMember:GuildMember

#

And guildMember class have .roles

boreal flume
#

So, I have to do some logic lol

earnest phoenix
#

Yes

boreal flume
#

is guildMember.roles.cache.has(...) a function?

earnest phoenix
#

Idk

#

maybe === will work ig

#

unless the discord collrctiom have compare functiom

boreal flume
#

does old guild member come first in parameters?

earnest phoenix
#

Yes

boreal flume
#

That was very easy logic

fiery stream
#
<html>
  <head>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <h4>Jazz</h4>
    <h4 style="text-align: right; margin-bottom: 20px;">Portfolio</h4>
    <h4>Contact me</h4>
    <hr>
  </body>
</html>``` somebody please help me get the pOrtfolio and contact me on right side
#

its been years since i coded so dont judge mee

#

i can get it on right side but cant get it on same line...

feral aspen
#
    if(srole.position >= message.member.roles.cache.position) return message.channel.send(noPermissions);```
Hello, Does anyone know if I did something wrong, cause it doesn't seem to return;
earnest phoenix
#

Why check 2 times

boreal flume
#

Also, you don't need to return message.channel.send

earnest phoenix
#

@boreal flume actually

#

You need

#

If you want the code to stop running

boreal flume
#
if(srole.position >= message.guild.me.roles.cache.position){ message.channel.send(noPermissions); return}
slender thistle
#

Ehh, more work somewhat

boreal flume
#

I always add return afterward

earnest phoenix
#

eh

slender thistle
#

More of a preference imo

boreal flume
#

I call the function, THEN return

earnest phoenix
#

return message.channel.send work fine

#
  • its easier
#

Unless your function return spefic value then you can use that

fickle arch
#

should I use ytdl or lavalink for music function ?

earnest phoenix
#

@fickle arch lavalink is better

boreal flume
#

I don't do music, but everything I have read about it uses ytdl

feral aspen
#

but

#

it doesnt return

fickle arch
#

a lot use ytdl kinda.

feral aspen
#

Why though

earnest phoenix
#

So yeah

#

@feral aspen use return message.channel.send

feral aspen
#

Bruh I did

fickle arch
#

Ima try use lavalink and let my brain processing a bit.

earnest phoenix
#

It didnt send error message?

feral aspen
#

if I do like !addrole <user> <role>, if role is higher than bot or the author, it doesnt return. It justs say it adds but it doesnt

#

I want it to return

#

but it doesnt

fickle arch
#

you mean of return ?

earnest phoenix
#

@feral aspen dude

#

You need to get the highest one

fickle arch
boreal flume
#

the only add-role commands I have made creates roles

earnest phoenix
#

So, instead of cache

#

use highest

#

And .position

#

And it will work

feral aspen
#

you mean like this for addrole stuff ?
@fickle arch Yes, but if the role is higher than the bot or the author performing the command, it should return

#

But it doesnt return

earnest phoenix
#

@feral aspen i already tell solutiob

#

solution

fickle arch
#

@fickle arch Yes, but if the role is higher than the bot or the author performing the command, it should return
@feral aspen Try starwoman solution, I'm still dumb dumb about coding 😆

silver lintel
#

how do you edit a message after like 3 seconds in js?

feral aspen
#

You need to get the highest one
@earnest phoenix THANK YOU sooo much]

earnest phoenix
#

@silver lintel .edit{timeout:

#

Or something

#

Let me check

twin shore
#

Idk what I'm doing rn-

silver lintel
#

message.channel.send("hi").edit{timeout: 3000} something i forgot

earnest phoenix
#

No

#

@silver lintel you have to create your own timrout

#

setTimeout(function, timeout in millisecond);

faint prism
#

Is that even calling syntax

earnest phoenix
#

Idk

#

I am dumb at explaining stuff but hey it work

silver lintel
#
message.channel.send('hi')
.then((msg)=> {
  setTimeout(function(){
    msg.edit('hello');
  }, 1000)
}); 
faint prism
#

It's not even a parameter of the method. Just an object thrown right there next to the method

silver lintel
#

so like this?

earnest phoenix
#

Yes

#

@faint prism yeah

boreal flume
#

I haves another question about the voting thing

#

Does it take the role off after the 12 hour period?

earnest phoenix
#

Yes

boreal flume
#

So, I can add in a feature that sends a message saying their vote wait has expired

earnest phoenix
#

Yeah

boreal flume
#

Though, that seems like kind of a dickish thing to do lol

#

"Oh, we see you have finished waiting for the vote. GO VOTE NOW!!!!!!"

silver lintel
#

TypeError: message.guild.createRole is not a function

#

how do i make a mute role with overide perms so a user cant type?

fickle arch
#

mute function 🤷‍♂️

silver lintel
#

how

earnest phoenix
#

@fickle arch he mean

#

Text channel mute

#

Not voice channel

fickle arch
#

Yes I mean that

earnest phoenix
#

You misunderstanding

fickle arch
#

overall channel mute chat right ?

earnest phoenix
#

Mute only work for vc

silver lintel
#
let mootRole = await message.guild.createRole({
          name: "Muted",
          color: "#ff0000",
          permissions: []
        });
        message.guild.channels.forEach(async (channel, id) => {
          await channel.overwritePermissions(mootRole, {
            SEND_MESSAGES: false,
            ADD_REACTIONS: false,
            CONNECT: false
          });
        });
#

i did this

#

but im pretty sure its wrong

fickle arch
#

wait how you send text like that I forget lol.

silver lintel
#

```js
blah blah blah
```

earnest phoenix
#

@silver lintel sur

#

Sir

#

It has been changed to

#

#Guild.roles.create in v12

silver lintel
#

ohh

fickle arch
silver lintel
#

TypeError: message.guild.channels.forEach is not a function i came back from 2 year coding break, so everything i type is v11, whats this function in v12?

earnest phoenix
#

@silver lintel uh

silver lintel
#

my way probably sucks

earnest phoenix
silver lintel
#

channel.updateOverwrite(channel.guild.roles.mootRole, { SEND_MESSAGES: false });?

earnest phoenix
#

sigh

#

In v11 .channels return collection of channels
But now in v12
.channels return ChannelManager

fickle arch
#

update your bot code to v12

earnest phoenix
#

channelManager.cache retuen collection of channels

silver lintel
#

yes, im rewriting a bot

earnest phoenix
#

So the correct one is

#

channels.cache.forEach

austere fern
#

How do I add my bot

#

???

silver lintel
earnest phoenix
austere fern
#

Ok

fickle arch
#

or just invite bot, and change the ID with your bot ID

earnest phoenix
#

@fickle arch bad practice

fickle arch
#

I do that before so 🤷‍♂️

earnest phoenix
#

Use api calculator and select the bot permission your bot need

#

Not admin directly

fickle arch
#

I see.

silver lintel
#

thank you starwoman it works

sick fable
#

So basically. I want a code and need someone to explain me that how to make a command that sends random memes

earnest phoenix
#

@sick fable your better learn coding language of your choice first

fickle arch
#

memes API

earnest phoenix
#

And no we wont spoon feed

sick fable
fickle arch
#

your choice.

sick fable
#

@sick fable your better learn coding language of your choice first
@earnest phoenix I am learning it

earnest phoenix
#

Heres how we do it

#

So first we need an reliable api

#

You know what api is?

sick fable
#

Nope😂

#

I am pretty dumb

earnest phoenix
austere fern
#

Same

earnest phoenix
#

Oh fuck

fickle arch
#

My brain stop working after writing lines of code.

sick fable
#

Lol

earnest phoenix
sick fable
#

My brain stop working after writing lines of code.
@fickle arch same bruh

earnest phoenix
#

You send request to api, then api sned back image, buffer, or url to the image

#

Nvm

sick fable
#

Oh*

earnest phoenix
#

@slender thistle

fickle arch
#

dadjokes api is so bad 😆

#

I mean bad jokes

#

xd

slender thistle
#

What am I needed for

sick fable
#

Idk

earnest phoenix
#

Explain them how to get memes

sick fable
#

Yes

earnest phoenix
#

Using python

slender thistle
#

pats aiohttp
This good boy is asynchronous and doesn't block your code

earnest phoenix
#

@slender thistle how about http?

#

Axios*

slender thistle
#

What is axios

#

You did say Python so I'm going with Python libraries :^)

earnest phoenix
#

Axios is python libaries wdym

slender thistle
#

Since when

lament meteor
#

wait wut

slender thistle
#

What did you sniff today

lament meteor
#

srsly

earnest phoenix
#

WHAT

#

Oh fick

#

FUCK

lament meteor
#

its only for browser and node?

slender thistle
#

requests for sync
aiohttp for async

earnest phoenix
#

Whats diffrent

#

Between async and sync

lament meteor
#

requests is blocking

earnest phoenix
#

Explain it in nodejs level please

#

Or java

slender thistle
#

While request is processing, the entire process stops and waits for it to finish

#

While that's happening, your client can't acknowledge heartbeats from Discord and your bot goes offline after a while

earnest phoenix
#

So sync bad

#

Async good?

lament meteor
#

depends

slender thistle
#

Async with async good
Async with sync good if it's not blocking too much

earnest phoenix
#

So if i understand correctly

#

Sync stop process and wait for stuff to be done
While async dont?

slender thistle
#

In a way

lament meteor
#

in simple terms ig

earnest phoenix
#

Ty ig

blazing ravine
#

what is code for wtch guild id

#

im trying to make command with bot can react to message // command : f!command {messageid} {emoji}

earnest phoenix
#

@blazing ravine Dont expect to be spoonfeeded code

blazing ravine
#

ok

earnest phoenix
#

@slender thistle do the spoonfeed commanf

blazing ravine
#

maybe fixed

earnest phoenix
#

gj

silver lintel
#
let mootRole = await message.guild.roles.create({
          data: {
            name: "Muted",
            color: "#FF0000",
          },
        });
``` how to change permissions of this role?
river thistle
#

permissions property

blazing ravine
#

not work 😦

river thistle
#

with an array of objects like this

blazing ravine
river thistle
#

{
id:"2342342",
allow:
deny:
}

#

i guess

#

its been a while since I didnt use djs

#

anyways readthedocs

#

@silver lintel

#

dammit

#

30 secs to search

silver lintel
#

what did you search?

river thistle
#

well thats for the data: {} part

silver lintel
#

ok

river thistle
#

well just the discord.js doc

#
silver lintel
#

let mootRole = await message.guild.roles.create({
data: {
name: "Muted",
color: "#FF0000",
permissions: "SEND_MESSAGES" false?
},
});

#

how im still confused

#

becAUSE THEY Dont really give an example

river thistle
#

lemme spoon feed u

silver lintel
#

thanks :}

earnest phoenix
#

@river thistle no

#

Dont you ficking dare do it

fickle arch
#

oh wow

river thistle
#

well

#

i wont then

#

search on stackoverflow or just understand the doc

fickle arch
#

or watch indian tech guy on youtube about programming language 🤔

river thistle
#

exactly

silver lintel
#

message.channel.overwritePermissions(mootRole.id, { SEND_MESSAGES: false});

fickle arch
#

they help me solved how to revive my dead phone from 2 years ago KEKW

silver lintel
#

how do i do it to all the channels in a server?

river thistle
#

put it in rice

fickle arch
#

how you expect to dry a dried phone 🤔

fickle arch
#

how you update node.js to current version ?

earnest phoenix
#

javascript is weird too much
functions are instances of the Function class
classes are special functions

silver lintel
#

how to check if a user's highest role is higher or equal to another user's?

earnest phoenix
#

@silver lintel #GuildMember.roles.highest.position

misty sigil
#

<member>.roles.highest.positon

silver lintel
#

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'position' of undefined

#
let authorHighestRole = message.member.highest.position;
    let mentionHighestRole = kickMember.highest.position;

    if (mentionHighestRole >= authorHighestRole) {
      return message.channel.send(
        "You can`t kick members with equal or higher position"
      );
    }
misty sigil
#

.roles.highest.position

#

lmfao

silver lintel
#

;-;

#

whoops

earnest phoenix
#

@austere salmon i would recommend https://repl.it for temporary bot hosting

#

@earnest phoenix never recommend free hosting

#

temporary

#

Dont

misty sigil
#

yea but PINS

austere salmon
#

I want it for free

#

@earnest phoenix

misty sigil
#

@austere salmon look at pins

earnest phoenix
#

I want it for free
@austere salmon repl.it is a good enough free service for doing bot stuff but you should move to a VPS ASAP

misty sigil
#

NO

#

CHECK 👏 THE 👏 PINS

earnest phoenix
#

@misty sigil any free vps

misty sigil
#

check the pins istg hayper

austere salmon
#

@earnest phoenix Thank you

misty sigil
#

@coral trellis come here stinky

earnest phoenix
#

@wintry niche don't submit bots like that

#

@slender thistle

wintry niche
#

ok

earnest phoenix
slender thistle
#

-faq 1 @wintry niche read this if you want to submit your bot on top.gg

gilded plankBOT
#

@wintry niche

Frequently Asked Questions 📜
earnest phoenix
#

@slender thistle this guy is talking via his bot

slender thistle
#

E?

earnest phoenix
slender thistle
#

🤔

earnest phoenix
#

Lemme try to invite it again

silver lintel
#

let kickMember = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);

console.log(kickMember);

avatar: 'e5a433d2ca73e2631441123689d2609b',
it comes up with ^, i want the avatar, but how do i get it with these numbetrs and letters?

earnest phoenix
#

@silver lintel its hash

silver lintel
#

oof

earnest phoenix
#

also

#

use .displayAvatarURL()

silver lintel
#

kickMember.displayAvatarURL() or kickMember.user.displayAvatarURL()?

earnest phoenix
#

It gib you the link directly

#

.user.

silver lintel
#

ok

elfin tulip
#

Hello how i can store json from webapi?

earnest phoenix
#

@elfin tulip let not use json database

ionic shard
#

is this the proper way of handling perms for purge command?

if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send('');

if (!message.guild.me.hasPermission('MANAGE_MESSAGES')) return message.channel.send('');
misty sigil
#

yes

ionic shard
#

anything else i need to worry about?

#

i dont wanna get exploited

silver lintel
#

maybe send a message saying you dont have perms

#

if you are not going to send anything

#

just do return;

#

no need for the message.channel bit

ionic shard
#

hum

#

the thing is with new bots people probs gonna think it my bot's bug and not there fault

silver lintel
#

yea..

digital ibex
#

btw ur gonna get errors when the command has been triggered

silver lintel
#

how

digital ibex
#

message.channel.send(“”)

#

cant send empty message

silver lintel
#

yea, dont do that, just do return

ionic shard
#

i have text in it dw

silver lintel
#

ok good

#

if u do wanna send empty message, do mesage.channel.send("_ _");

digital ibex
#

is the text saying u dont have perms or something

ionic shard
#

yeah

digital ibex
#

<im stupid>

#

oh

#

nvm

ionic shard
#

so something like this

if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send('**Error:** You can not do that. Missing permission `MANAGE MESSAGES`');
        if (!message.guild.me.hasPermission('MANAGE_MESSAGES')) return message.channel.send('**Error:** I can not do that. Missing permission `MANAGE MESSAGES`');

        const amount = parseInt(args[0]);

        if (isNaN(amount)) {
            return message.reply('**Error:** Not a valid amount.');
        } else if (amount < 2 || amount > 100) {
            return message.reply('**Error:** Input a number between 2 and 100.');
        }

        message.channel.bulkDelete(amount, true).catch(err => {
            console.error('Purge:\n' + err);
            message.channel.send('**Error:** Unable to pruge messages in this channel.');
        });```
silver lintel
#

you forgot a field @ionic shard

#

Args[0] could be a decimal

ionic shard
silver lintel
#

Then the code would error

#

Try it

ionic shard
#

welp

#

didnt give error

silver lintel
#

Well thats good then

ionic shard
#

well its scary it didnt

silver lintel
#

Yea..

#

How many messages did it purge?

ionic shard
#

typed 1,2,3,4,5
said purge 4.1
1,2 left

silver lintel
#

Ahh good

ionic shard
#

oh right

silver lintel
#

Bulk delete rounds

earnest phoenix
#

Just do integer.parse

silver lintel
#

I t hi nk

ionic shard
#

1 message is it self

silver lintel
#

Yea, do bulkDelet(amount + 1.....

ionic shard
#

okay so 4.9 is also 4

#

works

#

deci is ignored

pale vessel
#

that's what parseInt do lol

ionic shard
#

but i didnt use it

#

oh nvm

#

just discord guide things

#

i did copy it

silver lintel
#

so ive got let kickMember = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);, and i did console.log(kickMember), and the console is
a big big json like collection idk, but i wanna do something like kickMember.send(), but kickMember isnt a member. so like how do i make it a user

cyan mulch
#

Can someone give me a music code for my bot?

still merlin
#

No

elfin tulip
#

@elfin tulip let not use json database
@earnest phoenix ??

honest perch
#

Bruh

#

You just leaked your database

cyan mulch
#

Idk how to work that music for my bot

misty sigil
#

nice

#

also don’t use ytdl use lava link

ionic shard
#
try {
await member.kick();

} catch (err) {}
#

@silver lintel

honest perch
#

@cyan mulch i suggest deleting the message

#

you literally opened your database to the public

silver lintel
#

@ionic shard ik

#

but member isnt a member

ionic shard
#

humm message.guild.member(message.mentions.users.first())

silver lintel
#

i can get the id of kickMember tho

ionic shard
#

why
message.guild.member(message.mentions.users.first())
and not
message.mentions.users.first()

cinder patio
#

You can do message.mentions.members.first()

silver lintel
#

wait bruh

#

why do i have message.guild.member(message.mentions.users.first())

#

welp

ionic shard
#

also would like to ask
when the mentioned user gets kicked
he is only kicked from that server and not other servers right (if bot and user have in common)

or do i have to specify?

silver lintel
#

the current server

ionic shard
#

cool

#

hum so lets suppose
There are three roles
Bot
admin
mod

all of em have KICK_MEMBERS perms
as discord works mod cannot kick admin as he has a higher role
but what if he uses the bot and kicks admin sip

silver lintel
#

thats why you should have a special thing

#
let authorHighestRole = message.member.roles.highest.position;
    let mentionHighestRole = kickMember.member.roles.highest.position;

    if (mentionHighestRole >= authorHighestRole) {
      return message.channel.send("You can't kick members with equal or higher position");
    }
ionic shard
#

tasty pasta

pale vessel
#

doesn't member.kickable handle that for you already?

silver lintel
#

oh yea

ionic shard
#

i mean its kickable by the bot?

#

but shouldnt be kickable by the mod

#

let me google

pale vessel
#

the mod uses the bot

#

you should only do that if you want to check the mod's permission too

ionic shard
#

i didnt knew about member.kickable let me see

pale vessel
ionic shard
#
        if (!message.member.hasPermission('KICK_MEMBERS')) return message.channel.send('**Error:** You can not do that. Missing permission `KICK MEMBERS`');
        if (!message.guild.me.hasPermission('KICK_MEMBERS')) return message.channel.send('**Error:** I can not do that. Missing permission `KICK MEMBERS`');

        const member = message.mentions.users.first();
        if (!message.mentions.users.size) return message.reply('**Error:** You need to tag a user in order to kick them.');

        if (member.kickable) {
            try {
                await member.kick();
            } catch (err) {
                console.error(err);
            }
        }```
#

something like this?

silver lintel
#

from my limited and small understanding, member.kickable is if the bot can kick it?

ionic shard
#

that was what i asked

silver lintel
#

my kick command has this

#
if (!kickMember.kickable) {
      return message.channel.send("I don't have permissions to kick this user");
    }
#

i may be wrongh

ionic shard
#

no

#

check

#

Client

silver lintel
#

ah ok

#

if discord docs says so,....

#

then it is

ionic shard
#

cool feature