#development

1 messages ยท Page 956 of 1

river terrace
#

thats how the rest of my exports are

proven lantern
#
    return {
        name: 'advice',
        description: 'gives a random life advice',
        category: 'none',
        run: async (client, kayn, REGIONS, config, message, args, con, guilds) => {
            request
                .get('http://api.adviceslip.com/advice')
                .end((err, res) => {
                    if (!err && res.status === 200) {
                        try {
                            JSON.parse(res.text)
                        } catch (e) {
                            return message.reply('An API Error Occurred :(');
                        }
                        const advice = JSON.parse(res.text)
                        message.channel.send(advice.slip.advice)
                    } else {
                        console.error(`REST call failed: ${err}, status code: ${res.status}`)
                    }
                });
        },
    };
}```
river terrace
#

ill give it a shot

quartz kindle
river terrace
#

lol

#

guess

#

totally didnt copy this

quartz kindle
#

then thats why its not working

river terrace
#

yup

#

kinda guessed that from the beginning

quartz kindle
#

you cant copy things that dont exist and expect them to work, all of those only work if they are stuctured to work like that elsewhere

#

none of that code is self contained, it all depends on other code

river terrace
#

ohhhhhh

#

man that makes so much sense

#

holy crap

#

why are u so good at explaining things

#

lol

#

i litterally dont know what i would do without you tim

#

you are a freaking legend

#

you make everything so easy to understand

#

its so awesome

quartz kindle
#

remember the command handler? go to your main file, find the code that executes the run function

river terrace
#

uh huh

quartz kindle
#

something like commandFiles.get(cmd).run()

river terrace
#

yes

#

i know where that is

quartz kindle
#

show that line

river terrace
#

ive seen it before

#

ok

#

i think i found it

#
const xpCooldown = new Set()
function runCommand(cmd, message, args) {

    try {
        commands.get(cmd).run(message, args)
    } catch(e) {
        console.log(e)
    }

    try {
        if (!message.member) return
        if (!userExists(message.member)) return
    
        setTimeout(() => {
            try {
                if (!xpCooldown.has(message.member.user.id)) {
                    updateXp(message.member, getXp(message.member) + 1)
            
                    xpCooldown.add(message.member.user.id)
            
                    setTimeout(() => {
                        try {
                            xpCooldown.delete(message.member.user.id)
                        } catch {}
                    }, 45000)
                }
            } catch {}
        }, 10000)
    } catch {}
    
}```
#

is it somewhere in there?

#

i think its on line 6

#

@quartz kindle

#

there are a total of 5 instances where it says commands.get(cmd).run

quartz kindle
#

no

#

i mean yes

#

anyway

#

you see where it says: commands.get(cmd).run(message, args)

#

the run function is executed with two arguments: message and args

#

thats basically the entry point, the sender

#

and this run: async (client, kayn, REGIONS, config, message, args, con, guilds) => { is the exit point, the receiver

#

the arguments are passed by order, not by name

river terrace
#

hm

#

@earnest phoenix use repl.it and uptimerobot

quartz kindle
#

which means that
.run(something) sends the something
run: async (something) => { receives the something

river terrace
#

ofc

#

ok tim

#

i think i get it?

#

OHHHH

#

so i need to add a .run(something) to my main file and then that something needs to be one of the arguements defined in the new command

#

right?

#

such as message

#

or kayn

quartz kindle
#

no, it means that you cannot add things that dont exist to your commands

river terrace
#

oh

#

can i make them exsist by creating them?

quartz kindle
#

also, arguments are sent in order

#

for example

river terrace
#

a message and then args

#

ohhhh

#

so

quartz kindle
river terrace
#

OHH

#

i get it

quartz kindle
#

so basically in your command, what you think is client is actually a message

river terrace
#

so i should change client to message?

quartz kindle
#

and what you think is kayn is actually args

river terrace
#

ohhhhhh

quartz kindle
#

and all others are undefined

#

because thye dont exist

river terrace
#

ohh

#

so what if i do this....

#

run: async (message, args) => {

#

would that solve the issue?

#

or would i need to do something else too

quartz kindle
#

yes, that is the correct way to use your command handler

river terrace
#

ayeee ok so if i go do that it should work?

quartz kindle
#

yes it should

river terrace
#

yussss

#

thanks so much tim

#

imma implant this into my brain

#

TIMMMM

#

IT WORKED

#

WOOOOOOOOOO

#

thanks man

#

ur a legend

hasty lotus
#

does anyone know why i've got this error :

TypeError: Cannot read property 'id' of undefined``` While trying to read member.guild.id in a guildMemberAdd event ?
valid gyro
#

It means the member doesn't have an Id value, which probably means something is screwed up earlier in the process

earnest phoenix
#

no

hasty lotus
#

not member.ud

valid gyro
#

Like it's not reading a member at all

hasty lotus
#

member.guild.id

earnest phoenix
#

the guild is undefined which shouldn't be the case

valid gyro
#

Yeah srry

earnest phoenix
#

which d.js version are you on

valid gyro
#

I'm confused

hasty lotus
#

11.6.4

earnest phoenix
#

update to v12 ig

hasty lotus
#

i know i should update but no

earnest phoenix
#

you're going to have to anyways

hasty lotus
#

i know

gusty jolt
#

What do ido

limber flume
#

w/askali is u gay

hasty lotus
#

but i'm not here to hear ppl telling me "oh update"

limber flume
#

...

gusty jolt
limber flume
#

oh

hasty lotus
#

i'm here to get help with my pb

limber flume
#

this isnt

#

tttttttestin

earnest phoenix
#

you're using an outdated version, you cannot come in here and expect that people won't tell you to update

gusty jolt
#

I need help with my server

earnest phoenix
#

this is not the place for it

tall mist
#

@hasty lotus I have the same problem. And only with this server no other does it

#

My way around is a try catch

#

Also djs v11 wayyy better than v12 change my mind

amber fractal
#

well in a couple months it wont matter

earnest phoenix
#

alright: intents support

#

i changed your mind

amber fractal
#

it's 3 months right?

smoky spire
#

Yes

#

Well 2 full months

earnest phoenix
#

isn't it in october?

amber fractal
#

Yeah v11 wont support intents, so you'll be switching regardless of whether it's better or not

smoky spire
#

Yeah early october

amber fractal
#

idk, I thought it was september

earnest phoenix
#

so 4 months

smoky spire
#

Jesus I'm dumb

#

Why do I always think october is after July ๐Ÿ˜ซ

obtuse jolt
#

Is message.channel.startTyping() api abuse?

earnest phoenix
#

uh no

#

why would it be

obtuse jolt
#

Idk

#

Iโ€™ve seen studier things

shy turret
#

@earnest phoenix was ur bot ever on?

earnest phoenix
#

idk

#

im confused

shy turret
#

Same

#

I dont understand what u mean

earnest phoenix
#

can we go to a vc so i can share my screen cuz im super confused

shy turret
#

No i cant vc rn

earnest phoenix
#

oh oki

#

how do i host my bot

shy turret
#

You need to make one first

earnest phoenix
#

for App Whitelist it says pending invite

shy turret
#

And then host it which is different for different coding languages

#

Ignore app whitelist

earnest phoenix
#

oki

#

how do i code my bot

shy turret
#

I wish i can run the command

earnest phoenix
#

huh???

shy turret
earnest phoenix
#

do i go to that

shy turret
#

Nvm theres a cmd where it shows this msg link but only mods can run it

#

It's a message link

#

It shows you a message where it says how to make a bot

#

So i guess yes if u want

earnest phoenix
#

where do i go to code the bot

quartz kindle
#

pick a programming language and start some coding course

earnest phoenix
#

how do i find one

quartz kindle
earnest phoenix
split hazel
#

I hope you don't think codecadamy is a hosting website

#

Websites provided are for learning how to code, you will be instructed on them what to do

earnest phoenix
#

how do i host my bot @split hazel

split hazel
#

You should first be learning how to code

earnest phoenix
#

what do i go to to learn how to code

#

i have never code in my ife

quartz kindle
#

the websites i mentioned are for learning how to code

amber fractal
#

@quartz kindle would you suggest chai and mocha to unit test or do you have other suggestions

quartz kindle
#

no idea, i have never done unit testing lmao

amber fractal
queen crane
#

unit testing for what?

#

discord bots?

amber fractal
#

no

#

If I just developed discord bots I'd want death

queen crane
#

yeaah ok

#

I use jest

amber fractal
#

I'll look into it thanks

queen crane
#

yep

steel drum
#

mocha is fine from my experience

amber fractal
#

I just want to look for what works best, so I'd test the ones that I see recommended

queen crane
#

Jest is pretty popular and nice to use from my experience

#

haven't used mocha except once a long time ago though so I can't say

shy turret
#

#development message
Well, first time i made a discord(.js) bot, I never knew js and just went on lol

quartz kindle
#

test in production :^)

misty swallow
#

for discord.py, is anyone getting this warning
Unclosed client sessionclient_session: <aiohttp.client.ClientSession object at 0x7f689ac50240>

#

i am running a task on loop in the background. everytime i terminate the bot, i get this warning

#

once i run the bot again, the task i was running beforehand continues alongside the newly started task loop

#

so each time i run, it does the same task +1 more times

#

for example, if i had a task that posts a message every hour to a log channel, and then run and terminate the bot 7 times, it will post 7 messages every hour

#

i am running the bot as following

some_other_task.start()
bot.run(token)
amber fractal
#

Did you .cancel() it after?

#

Or .stop() it, which is graceful

misty swallow
#

where would i put that though?

#

i'm terminating the script with just ctrl+c, so i'd imagine any processes that are running would get killed?

amber fractal
#

Im not a python dev, just showing what the docs say

misty swallow
#

and this kind of just started suddenly, i've been running it like this for months with no problems

amber fractal
#

Not sure, doesnt even make sense that it'd continue running

misty swallow
#

this also only happens in production, which is very frusturating

#

i suspect it has something to do with tmux

river terrace
#
const MessageEmbed = require("discord.js");

module.exports = {
    name: 'advice',
    description: 'gives a random life advice',
    category: 'none',
    run: async (message, args) => {
        request
            .get('http://api.adviceslip.com/advice')
            .end((err, res) => {
                if (!err && res.status === 200) {
                    try {
                        JSON.parse(res.text)
                    } catch (e) {
                        return message.reply('An API Error Occurred :(');
                    }
                    const advice = JSON.parse(res.text)
                    const embed = new MessageEmbed()
                    .setColor("YOUR_COLOR")
                    .setDescription(`**${advice.slip.advice}**`)
                    .setTimestamp()
                    .setFooter(message.member.displayName, message.member.user.displayAvatarURL());

                    message.channel.send(embed)
                } else {
                console.error(`REST call failed: ${err}, status code: ${res.status}`)
                }
            });
    },
};```
#

got this lovely advice command

#

written in javascript

#

but

#

it throws an error

#

says that const embed = new MessageEmbed() is not a constructor

#

please @ me when u see this and let me know what all i did wrong

vernal rivet
#

@river terrace it should be const {MessageEmbed} = require('discord.js'); using {} allows you to call on what you need. If you don't use it, then you are calling on the entire package.

river terrace
#

Ok ty

vernal rivet
#

Np

copper cradle
#

Ok so do I have to guess?

#

or will you show your code

#

@earnest phoenix

earnest phoenix
#

uhm

#

I think I found it

#

srry xd

#

my friend helped xd

earnest phoenix
#

hello

#

can anyone help me?

#

I need help with a bot

#

i am making with python

#

it wont work!!!

#

no errors

#

just wont work

#

it includes, ban, kick , and mute

cosmic girder
#

Sorry my magic globe broke so I can't see ur code

earnest phoenix
#

sorry about that

cosmic girder
#

Lol

earnest phoenix
#

it's over 2000 characters

cosmic girder
#

Oh just send me 1 cmd like kick cmd

earnest phoenix
#

no errors

#

just wont work

cosmic girder
#

Ur started it up and stuff like tht correct

earnest phoenix
#

?

#

is there any errors?

#

i have a client run in the end

cosmic girder
#

Not tht I see I use js not py but when I began to it looked similar I'm no expert but I believe there's none

earnest phoenix
#

ohhh

#

many use JS

cosmic girder
#

@earnest phoenix yes but u have to run the bot

earnest phoenix
#

how?

cosmic girder
#

For it to go online

earnest phoenix
#

its online

cosmic girder
#

Hmmm

earnest phoenix
#

one command work

cosmic girder
#

It is

earnest phoenix
#

the first one

#

"Official Zombia Bot"

#

it works

#

the rest

#

ban, kick, mute wont work

cosmic girder
#

Did u copy & paste ?

earnest phoenix
#

?

#

what do you mean

cosmic girder
#

like did u go on the internet and search cmds up and cop and paste

earnest phoenix
#

cmds?

#

what is cmds?

#

no i didnt

#

i went on YT

cosmic girder
#

Cuz sometimes the internet doesn't give the most updated

earnest phoenix
#

i copied the YT

cosmic girder
#

What date were they made?

earnest phoenix
#

seriously?

#

lemme check

cosmic girder
#

Yuh I switch js so many times lmao as a beginner

earnest phoenix
#

ii believe it was 2019

#

or 18

cosmic girder
#

To be honest js is better

#

@earnest phoenix damn

#

Thts about 3+ updates outdated

earnest phoenix
#

bruh

cosmic girder
#

Not really depends what ur running

earnest phoenix
#

im on glitch

cosmic girder
#

U can change the version

earnest phoenix
#

he didnt run on glitch

#

change wat?

cosmic girder
#

Its fine

#

The py ur using

#

Idk how to

earnest phoenix
#

Oh

cosmic girder
#

But I'm sure there's a wY

#

U can do It ez with js

earnest phoenix
#

do you know what rewrite is

cosmic girder
#

I've heard of it

earnest phoenix
#

what is it?

#

should i have used the rewrite?

#

people said it is up to date

cosmic girder
#

I dont really know

#

I know what type script is but rewrite nah

#

Can say nunnin bout tht

earnest phoenix
#

king?

#

do you know anything?

tired nimbus
#

If I have an array of objects, how would I delete the entire object instead of the properties?

earnest phoenix
#

?

#

what

tired nimbus
#

i dont use python

earnest phoenix
#

oh

tired nimbus
#

also python for glitch isnt well supported

earnest phoenix
#

?

#

what?

tired nimbus
#

if you use glitch, you should use node.js

rough walrus
#
const math = require('math.js');
const Discord = require('discord.js');

module.exports.run = async (bot, message, args) => {

    const helpembed = new Discord.MessageEmbed()
    .setColor("#B30000")
    .setTitle("โŒ Too few arguments given. Missing a ``calulation value.``")
    .addField("**Usage**", "``calculate <calculation value>``")
    .setTimestamp()
    .setFooter(message.member.displayName, message.member.user.displayAvatarURL());

    const lolembed = new Discord.MessageEmbed()
    .setColor("#B30000")
    .setTitle("โŒ Too few arguments given. Invalid ``calculation value``.")
    .addField("**Usage**", "``calculate <calculation value>``")
    .setTimestamp()
    .setFooter(message.member.displayName, message.member.user.displayAvatarURL());

    if(!args[0] || args[0 === "help"]) return message.channel.send(helpembed);
    let resp;
    try {
        resp = math.eval(args.join(" "));
    }catch (e) {
        return message.channel.send(lolembed);
    }
    const embed = new Discord.MessageEmbed()
    .setColor("#C8A3FF")
    .setTitle("Math Calculation")
    .addField('Input', `\`\`\`js\n${args.join(' ')}\`\`\``)
    .addField('Output', `\`\`\`js\n${resp}\`\`\``)
    .setTimestamp()
    .setFooter(message.member.displayName, message.member.user.displayAvatarURL());

    message.channel.send(embed);
}
module.exports.config = {
    name: "calculate",
    aliases: ["cal", "calc", "calculator"]
}```
hey so that's a calculate command but it doesn't give the calculation result, it returns the second embed and i don't get errors, anyone can help?
earnest phoenix
#

i dont know node.js

dusky marsh
#

i didnt really read over any of the code but this args[0 === "help"] isnt valid

earnest phoenix
#

I need help

#

does anybody have the discord.js 11.5.1 code where you can generate a code and you can use it to get premium

earnest phoenix
#

Anyone here?

pale vessel
#

yeah

turbid bough
#

@dusky marsh that is obviously invalid

dusky marsh
#

yeah? i wasnt asking if it was

turbid bough
#

Nah I mentioned that you can obviously see what's wrong

#

You are basically doing args[false]

#

Oh wait you weren't the one asking lol

dusky marsh
#

yes i was confused

#

didnt expect a ping from dbl haha

earnest phoenix
#

help

#

someone

mossy vine
#

get premium what

earnest phoenix
#

can someone help

#

pls

pale vessel
#

hover over the red circle

mossy vine
#

495 lines in what seems to be 1 commands file thats cursed

wicked pivot
#
var config = JSON.parse(fs.readFileSync("./config.json", "utf8"))
function save(){
    fs.writeFile('./config.json', JSON.stringify(config, null, 2), (err) => {
        if (err) console.log(err)
    })
}
//in command

config.prefix = input
save()```

```{"prefix" : "!", "colorEmbed" : "", "logsChannel" : ""}```when i change the prefix everything deletes in the json
pale vessel
#

๐Ÿ˜ฉ

pure lion
#

Ah yes

mossy vine
#

var config = JSON.parse(fs.readFileSync("./config.json", "utf8"))
wtf

pale vessel
#

xd

earnest phoenix
#

hello

#

can anyone help pls

#

i used this guide to use and setup free hosting

#

everything was okay

#

but my bot still isnt online

#

hey

#

please help someone

#

hey helo

restive furnace
#

just dont use fr$$ hosts

tight forum
#

never used heroku ๐Ÿฅบ

earnest phoenix
#

why not

#

i am just a student

#

i cant afford a non-free vps

tight forum
#

me too

restive furnace
earnest phoenix
#

rx what do u use

tight forum
#

but u can find a chip vps

golden condor
#

Use Google cloud free one

tight forum
#

using a simple vps

#

and yeah im just a student

earnest phoenix
#

i dont know how

restive furnace
earnest phoenix
#

i am new to programing

tight forum
#

so use glitch

#

or use ur pc

#

for hosting

earnest phoenix
#

but i cant

tight forum
#

you are not working on a big project

earnest phoenix
#

i live in pakistan where there is no electricity for hours!

restive furnace
tight forum
#

mm

#

glitch is useful

#

use it

earnest phoenix
#

can u help me to use glitch please

tight forum
#

its very simple

#

to use

restive furnace
#

glitch only for js, repl.it is for actually like for almost every known programming language

earnest phoenix
#

i have a github,heroku and glitch account

tight forum
#

just create an account

earnest phoenix
#

i use js

tight forum
#

create a new project

earnest phoenix
#

i have a account on glitch

#

ok

#

wait

tight forum
#

node.js project btw

earnest phoenix
#

which one

#

there thare 3 types

tight forum
#

can u send a screenshot

earnest phoenix
#

well ok

#

here

tight forum
#

hello-express

earnest phoenix
#

ok

#

next

tight forum
#

now change your project name

#

what do u want

#

and make it private

earnest phoenix
#

my bot name is

#

CODELyon

tight forum
#

not important you can do whatever you want

restive furnace
#

i like default project names

tight forum
#

me too

earnest phoenix
#

ok thanks but i did it

tight forum
#

๐Ÿ˜‹

earnest phoenix
#

i like dark theme

#

so next

tight forum
#

is there a tools button?

earnest phoenix
#

i heard that glitch auto saves every keyword

#

that is not good

#

THERE IS A TOOLS BUTTON
yes

tight forum
#

and no

#

that is good

#

i think

earnest phoenix
#

no its not

tight forum
#

why

earnest phoenix
#

because ueverytime it saves it logins the bot and discord api changes the token for every 1000 login per day

#

i heared in a guide

#

Finally, we need to Disable some auto-save features. Glitch automatically saves the file, quite literally, on every keypress you make. And restarts it. This is not only slightly visually annoying, but also damaging to bots โ€” the Discord API will reset your botโ€™s token if you login 1000 times in a day. That means, if you type 1000 characters in your code, as it is. QUITE an issue.
Create a new file in the project, and call it โ€œwatch.jsonโ€.
Paste in the following code in it:
{
โ€œinstall": {
"include": [
"^package\.json$",
"^\.env$"
]
},
"restart": {
"exclude": [
"^public/",
"^dist/"
],
"include": [
"\.js$",
"\.json"
]
},
"throttle": 900000
}
This number, โ€œ900000โ€, means that every 15 minutes, if any files have changed, the bot will restart. Now there is a caveat here, which is that this also means any change you do in the bot will not take effect (will not reboot) until, up to, 15 minutes. But hey. Itโ€™s free, letโ€™s not look a gift horse in the mouth!

tight plinth
#

so I have this code which prevent a user for creating a tag with a name similar to a command name/aliases https://cdn.lumap.me/92r5wd3j.png . When i try to create a ta created help, for example, it returns me the error message about command names, but the tag is still created after. why?

earnest phoenix
#

sorrry about spam im not spamming

tight forum
#

oh looks great

#

just use tools button

#

you can upload your github project to glitch

earnest phoenix
#

ok

#

shouldnt i create that file first

tight forum
#

what file

#

just use import from github

earnest phoenix
#

ok what files do i need to import from github

rough walrus
#

does glitch support lavalink?

tight forum
#

ur bot project

earnest phoenix
#

no no what files

tight forum
#

all files

earnest phoenix
#

inde.js package .json

#

even node_modules

tight forum
#

just import it

#

dude

golden condor
#

so I have this code which prevent a user for creating a tag with a name similar to a command name/aliases https://cdn.lumap.me/92r5wd3j.png . When i try to create a ta created help, for example, it returns me the error message about command names, but the tag is still created after. why?
@tight plinth args[0].toLowerCase() ?

earnest phoenix
#

ok

tight plinth
#

yes

#

but thats not the problem

pale vessel
#

because you can't return using forEach

#

you need a for loop

tight plinth
#

oof

golden condor
#

Oh yeah

#

Do for(const c in client.commands)

earnest phoenix
#

wait a bit rx

tight forum
#

k

pale vessel
#

for of

golden condor
#

Oh yeah fuck

earnest phoenix
#

i didnt import nodemodules

#

do i need them

#

@golden condor can u pls mind your language

golden condor
#

Scuse me

earnest phoenix
#

excused?

golden condor
#

No no no, excuse me what?

tight forum
#

do i need them
@earnest phoenix no

earnest phoenix
#

just stop it

#

ok

tight forum
#

use console

#

and install ur packages

earnest phoenix
#

ok wait

#

i have index.js, Procfile, paqackage .json

tight forum
#

@earnest phoenix

#

use pnpm

#

not npm

earnest phoenix
#

what is that

#

i use npm

tight forum
#

if you are working on a glitch project

strong tundra
#

glitch uses pnpm

tight forum
#

^

earnest phoenix
#

ok that means that i dont need index.js , package.json and Procfile

tight forum
#

no u need

earnest phoenix
#

what do i dont need

tight forum
#

ok, if you imported everything

#

you dont need to delete anything

#

just install packages

#

using console

#

and pnpm

earnest phoenix
#

ok i imported only index , package and Procfile

#

ok what command

#

pnpm install discord.js

#

?

tight forum
#

check your packages.json

#

yeah

#

thats it

earnest phoenix
#

for what

golden condor
#

in discordjs, how can I use ffmpeg with ytdl-core to add filters to music?

tight forum
#

for check your packages mate

earnest phoenix
#

ok

#

i installd

#

the pmnp]

#

thing

tight forum
#

got it

#

is there a error?

earnest phoenix
#

no but it says downloaded 0

#

reused 15

tight forum
earnest phoenix
#

total 15

tight forum
#

check logs

earnest phoenix
#

how

tight forum
#

is your bot online?

#

using tools again

earnest phoenix
#

no

#

its offlime

#

n

#

8

tight forum
#

add ur bots token

earnest phoenix
#

should i run the cmmand again

tight forum
#

what command?

#

pnpm

#

why

earnest phoenix
#

to check agian

tight forum
#

did u remove auto saving?

earnest phoenix
#

no

tight forum
#

uh ok

iron scroll
tight forum
#

is there a token file or smth

earnest phoenix
#

no

tight forum
#

or did u add ur bot's token in index.js

earnest phoenix
#

yes

tight forum
#

mm

earnest phoenix
#

the command is const token

tight forum
#

and

earnest phoenix
#

const token = 'NzE2OT........................................................................'

#

Yo does anyone here know how to use tensorflow

#

no i dont

#

idk

tight forum
#

did u add bot.login(token) or smth

earnest phoenix
#

bot.login(token);

tight forum
#

mm

earnest phoenix
#

Also don't leak the token

#

hey i didnt leak

#

i just got some letters

#

Ik I'm just saying

tight forum
#

check the packages.json

#

install another packages that if needs to be installed

earnest phoenix
#

ok bt for what

#

{
"name": "discord-bot",
"version": "1.1.2",
"description": "JUST FOR TESTING",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "MUHAMMAD RAFFAY",
"license": "ISC",
"dependencies": {
}
}

#

i changed some things

#

{
"name": "CODELyon",
"version": "1.1.2",
"description": "A BOT TO CHEER YOU UP",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "MUHAMMAD RAFFAY",
"license": "ISC",
"dependencies": {
}
}

#

What is the bot supposed to do

tight forum
earnest phoenix
#

It has no dependencies which is probably incorrect

#

A store server is running. All store manipulations are delegated to it.
โ€‰WARNโ€‰ discord.js: prism-media@1.2.2 requires a peer of ffmpeg-static@^2.4.0 || ^3.0.0 but none was installed.
โ€‰WARNโ€‰ discord.js: prism-media@1.2.2 requires a peer of @discordjs/opus@^0.1.0 but none was installed.
โ€‰WARNโ€‰ discord.js: prism-media@1.2.2 requires a peer of node-opus@^0.3.1 but none was installed.
โ€‰WARNโ€‰ discord.js: prism-media@1.2.2 requires a peer of opusscript@^0.0.6 but none was installed.
โ€‰WARNโ€‰ discord.js: ws@7.3.0 requires a peer of bufferutil@^4.0.1 but none was installed.
โ€‰WARNโ€‰ discord.js: ws@7.3.0 requires a peer of utf-8-validate@^5.0.2 but none was installed.
โ€‰WARNโ€‰ discord.js@12.2.0 requires a peer of bufferutil@^4.0.1 but none was installed.
โ€‰WARNโ€‰ discord.js@12.2.0 requires a peer of erlpack@discordapp/erlpack but none was installed.
โ€‰WARNโ€‰ discord.js@12.2.0 requires a peer of libsodium-wrappers@^0.7.6 but none was installed.
โ€‰WARNโ€‰ discord.js@12.2.0 requires a peer of sodium@^3.0.2 but none was installed.
โ€‰WARNโ€‰ discord.js@12.2.0 requires a peer of utf-8-validate@^5.0.2 but none was installed.
โ€‰WARNโ€‰ discord.js@12.2.0 requires a peer of zlib-sync@^0.1.6 but none was installed.

#

this comes when trying to install

#

Lots of missing dependencies

#

blob

#

i dont know, what should be the dependencies

tight forum
#

blob thx for handling this

#

cuz i gtg

#

need take shower

earnest phoenix
#

so now he is helping me cool

#

COOL

#

Apparently

#

COOL

#

Try getting all the dependencies listed

tight forum
#

not cool

earnest phoenix
#

hwo

#

how

#

With yarn or npm

#

why not cool

#

how

tight forum
#

anyway

#

gtg

#

see ya

earnest phoenix
#

Which are you using

#

first of all what is a dependencie

#

It's a lib that your script is dependent on

#

ok

#

what should i add

#

All of the things listed as missing

#

???

#

Idk if there is more then that you posted

#

what is that supposed to meeN

#

I DONT UNDERSTAND

#

can u speed up a bit (just asking)

#

ffmpeg-static@^2.4.0 || ^3.0.0
@discordjs/opus@^0.1.0
โ€‰node-opus@^0.3.1
โ€‰opusscript@^0.0.6
bufferutil@^4.0.1
โ€‰utf-8-validate@^5.0.2
erlpack@discordapp/erlpack
libsodium-wrappers@^0.7.6
โ€‰sodium@^3.0.2
zlib-sync@^0.1.6

#

wow

#

That should be all the dependencies you're missing in the text you send

#

If you install those then those warnings should go away

#

{
"name": "discord-bot",
"version": "1.0.0",
"description": "JUST FOR TESTING",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "MUHAMMAD RAFFAY",
"license": "ISC",
"dependencies": {
"discord.js": "^12.2.0"
ffmpeg-static@^2.4.0 || ^3.0.0
@discordjs/opus@^0.1.0
โ€‰node-opus@^0.3.1
โ€‰opusscript@^0.0.6
bufferutil@^4.0.1
โ€‰utf-8-validate@^5.0.2
erlpack@discordapp/erlpack
libsodium-wrappers@^0.7.6
โ€‰sodium@^3.0.2
zlib-sync@^0.1.6 }
}

#

Yeah and also you need to install them

#

ONE BY ONE

#

I think you can do a multi install

#

using npm

#

ok

#

yeah just add a space between packages

#

Then it will install them all

#

can u tell how cause errors appear

#

Yeah

#

It's trying to use libs that aren't there and it will fail because of that

placid cobalt
#

Hey does anyone here know how to fox the npm librarys

summer torrent
#

wdym

earnest phoenix
#

At line:1 char:22

  • ffmpeg-static@^2.4.0 || ^3.0.0 @discordjs/opus@^0.1.0 โ€‰node-opus@^0.3 ...
  •                  ~~
    

The token '||' is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLin

placid cobalt
#

I cant get my bot to boot

#

All it says is an invalid aomething was guven

earnest phoenix
#

type node .

placid cobalt
#

You i am

earnest phoenix
#

or install pm2

placid cobalt
#

Right

summer torrent
#

show error

placid cobalt
#

Will

#

Do

golden condor
#

in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream

earnest phoenix
#

npm install pm2

placid cobalt
#

Just give me ainite fir my laptop to start

earnest phoenix
#

blob

#

You need to remove the version

#

WHAT version'

placid cobalt
summer torrent
#

your token is incorrect

earnest phoenix
#

That's one

placid cobalt
#

But its not thats the thing

summer torrent
#

regenerate it

earnest phoenix
#

Also get a promise rejection handler

placid cobalt
#

Whats that?

earnest phoenix
#

It handeds promise rejection

placid cobalt
#

And how

summer torrent
#

process.on(...

#

by listening that event

placid cobalt
#

Where do i put that

#

Cli

#

Or bot itsself

earnest phoenix
#

blob

placid cobalt
#

Which part of the common wrrors am i looking at?

golden condor
#

in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream [ping me if you can help out thaks in advance]

earnest phoenix
#

Yeah discord.guide is a good resource

#

blob

placid cobalt
#

i will regen the token and try that. ive done it a few tmes before but i will try it again anyway

earnest phoenix
#

Yeah

#

Like this
npm i ffmpeg-static @discordjs/opus node-opus opusscript bufferutil utf-8-validate erlpack@discordapp/erlpack libsodium-wrapper โ€‰sodium zlib-sync

#

That should install

pale vessel
#

get rid of node-opus

sacred oyster
#

can someone help me

earnest phoenix
#

get rid of node-opus
@pale vessel why

pale vessel
#

just ask

sacred oyster
#

this is my api code

#

doesnt work

pale vessel
#

node-opus is deprecated, @discordjs/opus is enough

earnest phoenix
#

Aight

placid cobalt
pale vessel
#

nice token

placid cobalt
#

hm?

earnest phoenix
#

Pls get a promise rejection handler

placid cobalt
#

how do i do that?

sacred oyster
#

const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGdSJdsnajdDJDciOiJIUz233egESwiaWF0IjoxNTkxMTkxNzAyfQ.1g5UJNv70sPfDosr203d_pjtoXPb5-2dsahdhds-dsadhdhn', client);

dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})

dbl.on('error', e => {
console.log(Oops! ${e});
})

pale vessel
#

wait a minute

placid cobalt
#

where do i put that in my bot?

sacred oyster
#

can u help?

summer torrent
#

@sacred oyster delete this and regenerate your dbl token

sacred oyster
#

lol thats fake

#

i edited it

summer torrent
pale vessel
#

i realized lol

earnest phoenix
#

ok

pale vessel
#

still not good to post tokens though

sacred oyster
#

heres the real one

pale vessel
#

no thanks

placid cobalt
#

blob how to i get a promise rejection handler?

pale vessel
#

use .catch or await and try catch

sacred oyster
#

const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcxMzc0MTA2OTEwMzM5ODk2MyIsImJvdCI6whyNTkxdoMTkxNzAyouyfQ.wantUJNv70sPfDtoosr2know03STOPd_pjtoXPb5-2jGrn-cdoiiq8n', client);

dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})

dbl.on('error', e => {
console.log(Oops! ${e});
})

#

hellp

pale vessel
#

client.Id?

earnest phoenix
#

process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});

pale vessel
#

bad practice

earnest phoenix
#

thats how you handle promise rejections

placid cobalt
#

ok. where do i put that?

#

just at th start?

#

or in client.ready

sacred oyster
#

can u help pls

earnest phoenix
#

after client.on('ready')

placid cobalt
#

kk

#

asininside that statement or its own seperate one?

earnest phoenix
#

seperate

placid cobalt
#

ok above or below?

earnest phoenix
#

below

placid cobalt
#

kk

#

will try that and then send in a picture

#

Is that giod?

#

I am going to regen token after

earnest phoenix
#

const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcxMzc0MTA2OTEwMzM5ODk2MyIsImJvdCI6whyNTkxdoMTkxNzAyouyfQ.wantUJNv70sPfDtoosr2know03STOPd_pjtoXPb5-2jGrn-cdoiiq8n', client);

dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})

dbl.on('error', e => {
console.log(Oops! ${e});
})
passing client will already handle server stats

placid cobalt
#

Wait have i to put this un too?

earnest phoenix
#

also yes owen

#

no thats not for u

placid cobalt
#

Oh thats fine

#

So i can run it now?

#

And see what happens?

earnest phoenix
#

yeah

sacred oyster
#

@earnest phoenix what?

#

wdym

placid cobalt
#

Still not working

earnest phoenix
#

dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})
that should be taken care of by passing client in new DBL

sacred oyster
#

oj

#

oh

#

so

#

so i do not need to add this dbl.postStats(client.guilds.cache.size, client.Id, client.total);?

placid cobalt
#

its not just this bot either. every bot i make is doing this

#

i created a new one and still did it

earnest phoenix
#

at least the promise rejection is now handled

placid cobalt
#

yeah

earnest phoenix
#

are you sure you are using the right token

placid cobalt
#

oh yeah there is less errors now lol hadnt realised

#

idk. i only have one bot so im assuming so

#

i deleted all my other ones

earnest phoenix
#

no you have a client secret and a token

#

they are quite similar

#

but make sure your using the token

placid cobalt
#

am i allowed to swear?

earnest phoenix
#

yes

placid cobalt
#

dont take this the wrong way and i dont mean this. but go fuck of

#

no i was using secret

#

lemme get the token

earnest phoenix
#

yeah it was looking kinda short

sacred oyster
#

@earnest phoenix still doesnt work

placid cobalt
#

i got the token now one sec

earnest phoenix
#

@earnest phoenix still doesnt work
it should post server stats to top.gg

placid cobalt
#

yeahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh. woohooooooooooo it works now

#

thanks blob your the best man

sacred oyster
earnest phoenix
#

np man

placid cobalt
#

also

sacred oyster
#

doesnt work

placid cobalt
#

how can i get my bot to stay online?

#

for free?

sacred oyster
#

use heroku

placid cobalt
#

ok thanks

golden condor
#

in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream [ping me if you can help out thaks in advance]

earnest phoenix
#

or self host

placid cobalt
#

how do i self host?

earnest phoenix
#

in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream [ping me if you can help out thaks in advance]
we still dont know

#

how do i self host?
install pm2 add the process and leave ur pc running

placid cobalt
#

oh ok

sacred oyster
#

doesnt work @earnest phoenix

placid cobalt
#

i will proboably just use heroku tn. but when i get back to school i will load it onto the schools server lol

earnest phoenix
#

fluster is the token still good

sacred oyster
#

yes

placid cobalt
#

thx for the help blob will proboably be back in a few minutes when i break my bot again bye fn

earnest phoenix
#

cause this is the only line im using
const dbl = new DBL(token, client);
and that works

sacred oyster
#

rlly?

earnest phoenix
#

yes

sacred oyster
#

let me try that

#

thanks for telling me

earnest phoenix
sacred oyster
#

heroku

placid cobalt
#

didnt break it yet. just a question

#

how do i get my bot to say

#

that its playing .

#

sorry playing .help

earnest phoenix
#

client.user.setActivity('.help', {type: 'PLAYING' });

sacred oyster
#

should this work?

placid cobalt
#

kk. where do i put that?

sacred oyster
#

const DBL = require("dblapi.js");
const dbl = new DBL(topggtoken, client);

#

inside a client ready event

earnest phoenix
#

that should work

placid cobalt
#

ok thank you

sacred oyster
#

like this

earnest phoenix
#

yeah

#

i have it set to watching everyone

placid cobalt
#

thank you so much guys

earnest phoenix
#

np man

sacred oyster
#

OH BLOB IT WORKS

#

TYSM!!

earnest phoenix
#

nice

#

np man

cosmic girder
#

How do I create a uptime?

earnest phoenix
#

client.uptime

#

its in ms tho

#

so you might want something like this

function msToTime(ms){
    days = Math.floor(ms / 86400000); // 24*60*60*1000
    daysms = ms % 86400000; // 24*60*60*1000
   hours = Math.floor(daysms / 3600000); // 60*60*1000
   hoursms = ms % 3600000; // 60*60*1000
    minutes = Math.floor(hoursms / 60000); // 60*1000
    minutesms = ms % 60000; // 60*1000
    sec = Math.floor(minutesms / 1000);

    let str = "";
    if (days) str = str + days + "d";
    if (hours) str = str + hours + "h";
    if (minutes) str = str + minutes + "m";
    if (sec) str = str + sec + "s";

    return str;
  }
cosmic girder
#

Ok

earnest phoenix
#

!invite

turbid bough
earnest phoenix
#

yes

#

Oh boy here i go learning tenserflow

turbid bough
#

tensorflow discord bot ThonkDumb

modest maple
#

You have no idea how much of a pain it it

#

it is* todo for bots or large scale stuff

#

and have it not cost and arm and a leg to run

earnest phoenix
#

tensorflow discord bot :ThonkDumb:
yeah im trying to make it say stupid shit when you dm it

#

im currently using dialogflow but i dont like making intents because there isnt any

#

so it will respond to almost all question with that is doesnt know

modest maple
#

thats gonna want a thicc model to go off

earnest phoenix
#

yeah

#

or do you think it will be worth it to play for cleverbot api

modest maple
#

ehh idk

#

it depends on your skill rlly

#

cleverbot is already trained

earnest phoenix
#

true and i have no experience with making ai

earnest phoenix
#

How nice they don't accept PayPal payments

spice smelt
#

hi! i'm trying to add the Reddit API to my bot, but I don't understand how to find the right url. I only found stuff like that : /api/v1/me/karma. Does that mean https://reddit.com/api/v1/me/karma ? Then where do I put the client secret of the reddit app to auth the bot?

turbid bough
#

you put client secret in the headers

earnest phoenix
#

ok

spice smelt
#

@turbid bough then am I right about the url syntax?

cinder patio
#

you are

spice smelt
#

thank you

#

I've already got these types of errors before with JSON files. What does that mean? ```
Unhandled promise rejection: FetchError: invalid json response body at https://www.reddit.com/r/dankmemes/hot reason: Unexpected token < in JSON at position 0

wicked pivot
#
var config = JSON.parse(fs.readFileSync("./config.json", "utf8"))
function save(){
    fs.writeFile('./config.json', JSON.stringify(config, null, 2), (err) => {
        if (err) console.log(err)
    })
}
//in command

config.prefix = input
save()```

```{"prefix" : "!", "colorEmbed" : "", "logsChannel" : ""}```when i change the prefix everything deletes in the json
cinder patio
#

a2b, it means that the response isn't JSON

spice smelt
cinder patio
spice smelt
#

then how should I do?

cinder patio
#

append /api/v1/me/karma to it

#

so you interact with the Api

#

I am not familiar with how reddit's API works

spice smelt
#

append /api/v1/me/karma to it
@cinder patio what does that mean?

cinder patio
#

I figured it out add .json at the end of the 'https://reddit.com/r/dankmemes/hot/'

#

That will return JSON and not HTML

pale vessel
#

that's what i use for my meme command lol

spice smelt
#

cool. (because this doesn't seems like it can be usable by the bot ๐Ÿ˜“ )

pale vessel
#

it is lol

astral remnant
#

:0

spice smelt
#

it seems like it's the html with .text()

cinder patio
#

can you show your updated code

spice smelt
#

This: ```js
fetch('https://reddit.com/r/dankmemes/hot.json')
.then(res => res.json())
.then(body => console.log(body))

Returns this : ```json
{
  kind: 'Listing',
  data: {
    modhash: '',
    dist: 27,
    children: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object]
    ],
    after: 't3_gw0pys',
    before: null
  }
}
#

btw how can I insert my modhash with headers? Idk how to use them even if I tried

cinder patio
#

yup, console.log body.data.children maybe those are the posts

spice smelt
#

yes I think so

pale vessel
#

those are the posts

#

yes

cinder patio
#
  "Header-Name": "Header-Value"
}});```
to add headers
spice smelt
#

thanks OK

#

I also have another problem (this has nothing to do with reddit) : discord.js's Intellisense (on VSCode) doesn't work anymore. Do you know why/ how to fix that please?

earnest phoenix
#

Memes

spice smelt
#

if that can help, I deleted the .vscode file in my workplace a few days ago, but idk if it's related

#

i think it's just some ssh config stuff

#

oops

#

excuse me

#

there isn't any pic

pure lion
#

objectobjectobjectobjectobjectobjectobjectobjectobjectobjectobject

spice smelt
#

[edited and resent : see below]

#

OooOOps

#

the token ๐Ÿ˜“

pure lion
#

gg

#

\๐Ÿ‘

spice smelt
#

smol brain

pure lion
#

no escape the emoji-

#

\๐Ÿ‘

#

NO

spice smelt
#

XD

#

๐Ÿ‘

pure lion
#

\๐Ÿ‘

#

ISTG

#

\๐Ÿ‘

#

JJJJJJJJJJJJ

spice smelt
#

lmfao

#

anyway

pure lion
#

c l p a

spice smelt
#

โซ

#

I resend it:
if got another issue: with this code : ```js
fetch('https://reddit.com/r/dankmemes/random.json', {headers: { "X-Modhash": "token here" }})
.then(res => res.json())
.then(body => console.log(body))

i got this, and `[Array]`s are empty. why? thats weird. ```json
[
  {
    kind: 'Listing',
    data: {
      modhash: '',
      dist: 1,
      children: [Array],
      after: null,
      before: null
    }
  },
  {
    kind: 'Listing',
    data: {
      modhash: '',
      dist: null,
      children: [Array],
      after: null,
      before: null
    }
  }
]
mossy vine
#

are they actually empty tho

opaque seal
#

Why doesn't my reaction collector stop even when I emit the 'end' event on it?

spice smelt
#

@mossy vine yes they are

mossy vine
#

so logging body[0].data.children is an empty array?

spice smelt
#

yes lemme show u

mossy vine
opaque seal
#

I use the collector.stop()

#

method

spice smelt
#

@mossy vine it's a conspiracy

#

it isn't empty now

#

i swear

opaque seal
spice smelt
#

why is there 2 objects? ```json
[
{
kind: 'Listing',
data: {
modhash: '',
dist: 1,
children: [Array],
after: null,
before: null
}
},
{
kind: 'Listing',
data: {
modhash: '',
dist: null,
children: [Array],
after: null,
before: null
}
}
]

what does `dist` mean?
mossy vine
#

ask the documentation

spice smelt
#

it doesn't say anything about it.

#

(when i search dist in the site. in the subreddit/random section, there is nothing at all)

placid hamlet
#
Could not extract html5player key: https://www.youtube.com/s/player/c31b936c/player_ias.vflset/en_US/base.js
/rbd/pnpm-volume/5de0ff72-89a9-4da9-9125-fd31caae7a64/node_modules/.registry.npmjs.org/opusscript/0.0.7/node_modules/opusscript/build/opusscript_native_wasm.js:8
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow){throw toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMEN
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined
    at Url.parse (url.js:154:11)
    at Object.urlParse [as parse] (url.js:148:13)
    at doDownload (/rbd/pnpm-volume/5de0ff72-89a9-4da9-9125-fd31caae7a64/node_modules/.registry.npmjs.org/miniget/1.7.0/node_modules/miniget/dist/index.js:90:28)
    at process._tickCallback (internal/process/next_tick.js:61:11)
#

ยฟWhats is?

placid vault
#

The "url" argument must be of type string. Received type undefined

#

@placid hamlet

golden condor
#
async def on_message(message):
    if message.author.bot:
        return
    if not message.content.startswith(prefix):
      return
    args = message.content.split(" ")
    command = args.pop(0).replace(prefix, "").lower()
    print(f'!{command} {" ".join(args)}')
    if command == "ping":
        await message.channel.send(f'Pong! {client.latency}ms')``` How could I make a better command handler than this (this works atm) I am new to discord.py
slender thistle
#

Are you confident that you don't need commands.Bot instead :p

golden condor
#

what is that

slender thistle
golden condor
#

o

#

How can I do external command files?

slender thistle
#

External what

#

Do you have a file per command nekothinking

golden condor
#

I mean like

placid vault
#

you can but it's a waiste of time

#

idk it's just an ideea

golden condor
#

ok

#

I was a bit confused how the command extension worked

spice smelt
#

does anybody know how to toggle intellisense for a library in VSCode?

prime glacier
#

Hi

placid vault
#

hello

pure lion
#

does anyone know how to get just the url from yt-search?

tight plinth
#

<song>.url i guess

earnest phoenix
placid vault
#

what is this

prime glacier
#

does anyone know how can i do it like i had created setup command bot make a new log channel on it with perm everyone cannot read and the message author can read but i want that bot also read message and send message there

earnest phoenix
#

Javascrpit test

placid vault
#

ah

#

does anyone know how can i do it like i had created setup command bot make a new log channel on it with perm everyone cannot read and the message author can read but i want that bot also read message and send message there
execusemewtf

river wing
#

im trying to get a list of servers that my bot is in and get the members data in each server but the error is that cannot read forEach of undefined?

tight plinth
#

what the fuck

digital ibex
#

uh

#

m

tight plinth
#

bot.guilds.cache.get().forEach

#

why .get()

river wing
#

isnt get() like the function to get id?

digital ibex
#

no

tight plinth
#

no

#

get rid of .get()

#

and see

prime glacier
#

does anyone know how can i do it like i had created setup command bot make a new log channel on it with perm everyone cannot read and the message author can read but i want that bot also read message and send message there
@prime glacier ?

#
          {
              id: message.guild.id,
              deny: ['VIEW_CHANNEL'],
          },
          {
              id: message.author.id,
              allow: ['VIEW_CHANNEL'],
          },
       
      ],
  })```
i want to add bot perms
tight plinth
#

here, the get function is normally used to get a guild object by their id (like bot.guilds.cache.get("264445053596991498") returns the guild object of this server)

earnest phoenix
#

JavaScript is ECMAScript ??

#

๐Ÿค”

summer torrent
#

yes

tight plinth
#

kinda

earnest phoenix
#

not really

summer torrent
earnest phoenix
#

ecmascript is a standard

#

that

prime glacier
#
          {
              id: message.guild.id,
              deny: ['VIEW_CHANNEL'],
          },
          {
              id: message.author.id,
              allow: ['VIEW_CHANNEL'],
          },
       
      ],
  })```
i want to add bot perms

does anyone know how to do?!

summer torrent
prime glacier
digital ibex
#

no

prime glacier
#

ok

#

can we make role with these type of cmds

earnest phoenix
digital ibex
#

i believe so

earnest phoenix
#

if anyone want to do it :

https://www.tutorialsteacher.com/online-test/javascript-test
digital ibex
#

if theres a type when overwriting permissions, the type would be 'role'

prime glacier
#

if theres a type when overwriting permissions, the type would be 'role'
@digital ibex ok let me try

river wing
#

is there a way to get a list of members of all the server that my bot is in and if the member is in multiple servers how do i only keep one of them?

summer torrent
#

which lib

prime glacier
#

is there a way to get a list of members of all the server that my bot is in and if the member is in multiple servers how do i only keep one of them?
@river wing in status?

#

client.users.cache.size

earnest phoenix
#

Py or Js

digital ibex
#

wow

#

i was so close to finishing it

#

and that happens

prime glacier
#

@earnest phoenix { id: client.user.id, allow: ['VIEW_CHANNEL'] },how can we add multiple permission's

#

@digital ibex nice

summer torrent
#

add inside allow array

prime glacier
#

like how?

earnest phoenix
#

javascript tests or any online tests for programming languages are useless

prime glacier
earnest phoenix
#

it's not the questions that prove your knowledge and that you would get asked in an interview lol

summer torrent
#

yes

prime glacier
#

@summer torrent it gave error

#

RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.

summer torrent
#

show code

prime glacier
#
      type: 'text',
      permissionOverwrites: [
          {
              id: message.guild.id,
              deny: ['VIEW_CHANNEL'],
          },
          {
              id: message.author.id,
              allow: ['VIEW_CHANNEL'],
          },
        {
          id: client.user.id,
          allow: ['VIEW_CHANNEL','READ_MESSAGES']
        },
       
      ],
  })```
summer torrent
#

VIEW_CHANNEL and READ_MESSAGES are same thing

prime glacier
#

๐Ÿ™„

#

but i also gave error on send

summer torrent
#

READ_MESSAGES was renamed to VIEW_CHANNEL

prime glacier
#

oh thanks @summer torrent

summer torrent
prime glacier
#

@summer torrent can i make role's like this ?

summer torrent
#

yes

prime glacier
#

can you tell me how

summer torrent
#

use role ID

prime glacier
#

message.guild.roles.create('muted', {
type: 'role',
permissionOverwrites: [
{
id: message.guild.id,
deny: ['VIEW_CHANNEL'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
{
id: client.user.id,
allow: ['VIEW_CHANNEL','READ_MESSAGES']
},

  ],

})

#

liek this?

summer torrent
#

no

#

type is the type of channel

#

text, voice or category

prime glacier
#

@summer torrent i want to make role like it can you tell?

prime glacier
#

๐Ÿ™„

#

message.guild.roles.create('Muted', {
permissionOverwrites: [
{
color: 1
},
{
deny: ['SEND_MESSAGES']
}

  ],

})

wicked pivot
#

what are the events that require no special permission (example: "message") ?

summer torrent
#

id: role ID,
allow: [perms]

prime glacier
#

ok

summer torrent
#

@wicked pivot guildMemberAdd/Remove etc

wicked pivot
#

are there no docs for that?

earnest phoenix
#

@prime glacier

if (!muterole) {
        try {
            muterole = await message.guild.createRole({
                name: "Muted",
                color: "#514f48",
                permissions: [],
            });
            message.guild.channels.forEach(async (channel, id) => {
                await channel.overwritePermissions(muterole, {
                    SEND_MESSAGES: false,
                    ADD_REACTIONS: false,
                    SEND_TTS_MESSAGES: false,
                    ATTACH_FILES: false,
                    SPEAK: false,
                });
            });
        } catch (e) {
            console.log(e.stack);
        }
}
summer torrent
#

discord.js right?

earnest phoenix
#

here to create a mute role

sinful harness
#
let muterole = message.guild.roles.cache.find(r => r.name === "Muted")
        if(!muterole) {
            try{
                muterole = await message.guild.roles.create({ data: {
                    name: "Muted",
                    color: "#514f48",
                    permissions: []
                 } })
#

or like this

earnest phoenix
#

yes

#
let muterole = message.guild.roles.cache.find(r => r.name === "Muted")
        if(!muterole) {
            try{
                muterole = await message.guild.roles.create({ data: {
                    name: "Muted",
                    color: "#514f48",
                    permissions: []
                 } })

for v12

prime glacier
#

for v12
@earnest phoenix muterole = await message.guild.roles.create({ data: {
SyntaxError: await is only valid in async function

earnest phoenix
#

yes

#

i am using it in async

#

but if you dont use it in async

#

so remove the await

prime glacier
#

@earnest phoenix module.exports = { name: "setupmute", category: "moderation", usage: "setupmute>", description: "Setup the mute role", run: (client, message, args) => { let muterole = message.guild.roles.cache.find(r => r.name === "Muted") if(!muterole) { try{ muterole = await message.guild.roles.create({ data: { name: "Muted", color: "#514f48", permissions: [] } })

#

is it it?

knotty steeple
#

i dont think u can just "remove the await"

earnest phoenix
#

@earnest phoenix module.exports = { name: "setupmute", category: "moderation", usage: "setupmute>", description: "Setup the mute role", run: (client, message, args) => { let muterole = message.guild.roles.cache.find(r => r.name === "Muted") if(!muterole) { try{ muterole = await message.guild.roles.create({ data: { name: "Muted", color: "#514f48", permissions: [] } })
@prime glacier try async(client, message, args)

knotty steeple
#

make run an async function

#

dont put it like that

#

add a space

prime glacier
#

after that it say's SyntaxError: Missing catch or finally after try๐Ÿ™„