#development

1 messages · Page 1327 of 1

solemn latch
#

where you want to acess meme.data.children

opal plank
#

children[0] will likely bring you the same shape you had before

tardy hornet
#

where you want to acess meme.data.children
@solemn latch idk what that means

opal plank
#

those [Object] in [children] are where the memes are at

#

hot means hot page, so you'll get a lot of results

#

just get the first one of the children, that'll be ONE meme

tardy hornet
#

ok then what do i do

opal plank
#

wdym?

tardy hornet
#

meme.data.children[index]

solemn latch
#

i want to access my mailbox, so i walk to my mailbox and read whats in it. if i find a letter with a bill in them, i take it to my desk and write a check and put it in a new letter and send it.

if you want to access children.data.thumbnail
you need to use that in the location you want it.

opal plank
#

assign that to a variable and use it or use that directly multiple times

tardy hornet
#

so like

#

.setImage( meme.data.children[URL] );

#

im sorry that im that dumb

solemn latch
#

you should really look into how to use objects

opal plank
#

here, you need to know how to play with arrays first

solemn latch
#

and arrays

sonic lodge
#

so i think my bot has some infinite loop somewhere; i run pm2 list every once in a while and i see cpu usage to 100%, and the bot is entirely unresponsive

#

how am i supposed to debug this?

solemn latch
#

check all your loops

#

i actually dont know how you solve those otherwise 🤔

sonic lodge
#

crap

#

i mean it probably isn't super hard to do that, just time consuming ig

tardy hornet
#

@opal plank yo btw, my bot got added to 43 servers, and till today he was not even 24/7. i ran him on my pc, node .

tulip ledge
#
for (thisPrefix of prefixes) {
  // Magic
}

thisPrefix is not defined
WTF?

solemn latch
#

whats prefixes

tulip ledge
#

an array

#

arrays are iterable right?

solemn latch
#

should be

#

const thisPrefix?

tulip ledge
#

so it should work right?

#

There's no other thisPrefix in the file

solemn latch
#

no i mean

#

for(const thisPrefix of...

tulip ledge
#

ill try

pine crow
#

I am on mobile and i have made a bot and i cant host 24/7 help lol

tulip ledge
#

That fixed it

solemn latch
#

use a VPS

pine crow
#

What dat

solemn latch
#

virtual private server

#

cheap hosting method commonly used for bots

pine crow
#

Ahh cool ill try thx im new to the bot thing

opal plank
#

@tardy hornet eeey nice, just remember that your production bot shouldnt be going offline

tardy hornet
#

ik

#

ty

green vale
#

Okay--I'm redesigning my bot's command handler (Discord.js v12 and Node v14), and I want to define my metadata using multiple functions. Here's my code.

module.exports = class BaseCommand {
  async meta() {
    async function core({name, level}) {
      this.name = name;
      this.level = level;
    }

    async function settings({aliases, testing}) {
      this.aliases = aliases;
      this.testing = testing;
    }

    async function help({description, usage, notes}) {
      this.description = description;
      this.usage = usage;
      this.notes = notes;
    }
  }
}

I would then proceed to use it like:

meta() {
  core({ name: "a", level: 27 });
  settings({aliases: ["1", "2"], testing: true});
  help({description: "games", usage: "a", notes: null});
}

Would the following work, or would it produce errors? (I'm asking this as I cannot reproduce it, since I'm not able to recreate my bot's environment and I don't want to push this change to the main branch of my bot.)

tulip ledge
#

Why is message.mentions.users.first(); returning undefined?

#

Yes, I am mentioning someone

green vale
#

Chances are that the message doesn't have a user ping in it.

tulip ledge
#

It does

earnest phoenix
#

Try members.first()

tulip ledge
#

@green vale What I'm doing is I have a class called Command with a construcer like for example:
this.run, this.name, etc
Then in the command file u can do class <command> extends Command and have ur contructor and super and run method in there

#

members doesn't work either

green vale
#

Yeah, that's currently how my bot is structured. I don't really like super() as it's a bit cluttery and I'd like to separate each aspect of the command metadata into different functions.

tulip ledge
#
  mentions: MessageMentions {
    everyone: false,
    users: Collection [Map] {},
    roles: Collection [Map] {},
    _channels: null,
    crosspostedChannels: Collection [Map] {}
  },
green vale
#

That's odd.

tame kestrel
#

ChickenDev check if msg.mention.users is coming back undefined

#

or empty

tulip ledge
#

Collection [Map] {}

#

honoured, I don't really know a different way to do it, you could have objects in the constructor but then I'd prefer to use a super imo

green vale
#

Fair--what I said above is what I want to do, I just wanna know if that would be feasible

tame kestrel
#

@green vale honestly, the second code block doesn't sit right with me, but I might just be too new to understand why you're using meta() like that.

tulip ledge
#

its a method

green vale
#

^

#

it's a method within a class

#

used in a class that extends the base class

tulip ledge
#

this.meta() would return all the functions inside of there

tame kestrel
#

Well yeah, but like method () {function()}?

tulip ledge
#

Yes you'd do this.meta().core({name:"a", level: 27}) to "configure" it

tame kestrel
#

oh that's cool

tulip ledge
#

Classes are really flexible and that's why I enjoy using them

green vale
#

yea

tame kestrel
#

anyways, I'm happy to show you my interface for my commands so you can sort of see how I did it, slightly less oop-y but it gets the job done rlly well

tulip ledge
#

imo if u know js basics, OOP and are feeling ready I'd learn to use classes

green vale
#

I'd love to see it, sure!

tulip ledge
#

any ideas how I would resolve my issue?

drifting wedge
#

how do i get what shard my bot is on? discord py?

tulip ledge
#

how do i get what shard my bot is on? discord py?
@drifting wedge if u sharded ur bot isn't it supposed to be on all ur shards?

green vale
#

Chicken, I've never actually experienced that before, maybe you're using the wrong message object?

drifting wedge
#

?

tulip ledge
#

no, the content seems right

drifting wedge
#

like basicaslly i want a command to find what shard the bot is on

#

so like if i have 10 shards

tulip ledge
#

oh like that

drifting wedge
#

how can i find which one bot is in?

tulip ledge
#

wich shard that instance is on?

drifting wedge
#

yes

tulip ledge
#

I've never sharded before but can't u do client.shard

solemn latch
#

the py lib docswould tell you

tulip ledge
#

oh yeh he used py

drifting wedge
#

shard id

#

imma try

tulip ledge
#

sooo anyone knows how I could fix my issue

reef carbon
#

is there a way to get the maximum amount of posts in a subreddit with the reddit API?

earnest phoenix
#

hello o have a probleme

reef carbon
#

so I can get the maximum amount of posts in a subreddit instead of the last 100 or 200 or something

earnest phoenix
#

i get this error

reef carbon
#

that's been happening for the last week

solemn latch
#

the api probably has a max number

reef carbon
#

it's something wrong with the server or something

#

oh ok

solemn latch
#

its very common to have 100 as a max

misty sigil
#

@earnest phoenix server side error

solemn latch
#

my api only has 50 max from one request

earnest phoenix
#

oww

misty sigil
#

wait for them 2 fix

reef carbon
#

I do 100 but if I go over 300 it says list index not found

solemn latch
#

yeah that would be their limit, whereever it cuts off

#

it will be in their api docs

tame kestrel
#

anyone try faunadb?

peak osprey
#
else if (command === 'purge') {

if(!message.member.hasPermission("MANAGE_MESSAGES")) {
return message.reply("You cant delete messages.....").then(m => m.delete(5000));

}

if (isNaN(args[0]) || parseInt(args[0]) <= 0) {
return message.reply("Thats not a number you thick shit").then(m => m.delete(5000));
}

if (!message.guild.me.hasPermission("MANAGE_MESSAGES")){
return message.reply("sorry i cant delete messages").then(m => m.delete(5000));

}
let deleteAmount;

if(parseInt(args[0]) > 100) {
deleteAmount = 100;
} else{
deleteAmount = parseInt(args[0]);
}

message.channel.bulkDelete(deleteAmount, true)
.then(deleted => message.channel.send(`i deleted \`${deleted.size}\` messages.`))
.catch(err => message.reply(`Something went wrong... ${err}`));

}```
#
(node:11032) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied options is not an object.
    at Message.delete (c:\Users\alexg\Downloads\LightBot\node_modules\discord.js\src\structures\Message.js:537:44)
    at c:\Users\alexg\Downloads\LightBot\index.js:120:73
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
 <node_internals>/internal/process/warning.js
(node:11032) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
 <node_internals>/internal/process/warning.js
(node:11032) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
 <node_internals>/internal/process/warning.js
#

oh i see the error

tame kestrel
#

"Thats not a number you thick shit"

peak osprey
#

lmao

#

dont question it

polar girder
#

i made a music bot and it turns on but will not connect to the Voice Channel

#

like it wont do anything for the !play cmd

solemn latch
#

is it erroring

polar girder
#

no there is no error its just wont work

#

switch (args[0]) {
case 'play':

            function play(connection, message){
                var server = servers[message.guild.id];

                server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));

                server.queue.shift();

                server.dispatcher.on("end", function(){
                    if(server.queue[0]){
                        play(connection, message);
                    }else {
                            connection.disconnect();
                    }
                    
                });


            }
#

thats the code for the !play

charred nimbus
#

can anyone help me

blissful coral
#

Sup

#

Don’t ask to ask but what is it

sonic lodge
#

@polar girder you have a function play, but you never call that function

charred nimbus
#

ok

polar girder
#

then what i do?

sonic lodge
#

as in you need to do:

function play() {
  console.log('currently running code in play function');
}

play(); // <-- call the function```
tulip ledge
#

Why is message.mentions.users.first(); returning undefined?
Yes, I am mentioning someone

blissful coral
#

It shouldn’t?

solemn latch
#

is members also undefined?

blissful coral
#

^

polar girder
#

my friend help me so i dunno

solemn latch
#

or, are you awaiting the message(if you sent it)

tulip ledge
#

are u talkin to me?

solemn latch
#

yeah i was @tulip ledge

polar girder
#

oh i thought u were talkin to me lol

tulip ledge
#

yes it also returns undefined

#

could it be cuz I'm doing this message = new Message(this, JSON.parse(JSON.stringify(message)), message.channel);?

sonic lodge
#

there ya go

tulip ledge
#

wdym there ya go

#

It shouldn't be but it might be

solemn latch
#

im confused, who are you mentioning in the new Message()

sonic lodge
#

why do you need the message constructor

tulip ledge
#

It's a class extended on, the discord message

solemn latch
#

oh psh

tulip ledge
#

I'm not mentioning anyone in the new Message

#

It's just that message is an "extended" version of the discord message

polar girder
#

@sonic lodge my problem is the bot wont respond to the command i have it if like ur not in a vc its gives u a error but it doesnt do anything

tulip ledge
#

args: [ '@tulip ledge' ]

sonic lodge
#

like i said, call the function

polar girder
#

oh so it just goes to that?

#

ok ill let u know if it dont work

charred nimbus
#

hmu

#

pls

sonic lodge
#

try running the command again with sudo at the beginning

charred nimbus
#

ok

polar girder
#

hey pool so i do this right? play(); @sonic lodge

blissful coral
#

What are you using? Ubuntu?

charred nimbus
#

yes

#

tysm

polar girder
#

im so confused

solemn latch
#

call the function

#

if you dont know what that means, google it

blissful coral
#

Call the function by doing play()

#

You made a function should prob know how to call it

balmy anchor
#

Hi guys I want to make a command that changes the current guild's command prefix
I'm already using a database (mongodb)
And I was wondering if you guys can help me thx (discord.js)

blissful coral
#

Uh

#

Just get the art

#

Arg*

#

And then update it

#

In your database

balmy anchor
#

I already did

polar girder
#

@blissful coral my friend is helpin me so im lost

blissful coral
#

Then what do you need

balmy anchor
#

but I want to know how to set it the the prefix

dapper compass
#

Good evening! Is it possible to have an on_message() function but using the bot.commands lib ?

(I want my bot to add random reactions on random messages but still having its normal comportment with commands and all)

balmy anchor
#

i mean

blissful coral
#

@polar girder if he doesn’t know what he is doing then he doesn’t need to be helping

polar girder
#

he isnt here so i tried doin it myself @blissful coral

blissful coral
#

@balmy anchor do const prefix = your db checking prefix per guild

balmy anchor
#

ok thx ill try

dapper compass
#

Good evening! Is it possible to have an on_message() function but using the bot.commands lib ?

(I want my bot to add random reactions on random messages but still having its normal comportment with commands and all)
@dapper compass I'm using Discord.py and I heard that it was possible to divide our code with an on_message event at top, and then the bot.commands part..

#

I think I found what I'm searching for

polar girder
#

ummmm @blissful coral is there a way of not having to deal with function?????

blissful coral
#

Don’t make a function then?

#

Lol

polar girder
#

well i mean im a dumb as all get out with JavaScript

solemn latch
#

functions are also generally the first few things you should learn and are extremely basic programming

blissful coral
#

You wanna look it up then

polar girder
#

i did

blissful coral
#

Function is one of the most basic things in JavaScript

polar girder
#

im doing it rn

balmy anchor
polar girder
#

@blissful coral im lookin rn

balmy anchor
#

Should I do it like this?
@balmy anchor @blissful coral

#

?

#

(Sorry for the mention)

blissful coral
#

Dude

#

Don’t ping

#

No point

#

Someone will respond if they can help you

balmy anchor
#

😦 sorry

blissful coral
#

I don’t use mongo db

#

So I don’t know

balmy anchor
#

didnt knew sry dude

ionic dawn
#

What people do to make multiguild xp levels, they make a table for every single guild the bot joins?

solemn latch
#

no

#

you have two primary collumns, one the user id and one the guild id

balmy anchor
#

Woo what database are u using?

#

if ur using..

solemn latch
#

mysql

balmy anchor
#

huhhh

#

i need someone that knows mongo lol

solemn latch
#

if you have a specific question, i can tell you to look at the docs

#

lmao

balmy anchor
#

i did already lol

solemn latch
#

whats the issue?

balmy anchor
#

i want to make a per-server prefix

solemn latch
#

make a table(mongo calls it a document or something?) with the guild_id and prefix

balmy anchor
#

i already did but to define the prefix i'll just put there my default bot prefix?

solemn latch
#

you should only make a row in the database if they have changed the prefix from default

#

if they do have one, then get it

balmy anchor
#

like !settings setprefix <prefix>
and then it'll update?

solemn latch
#

yeah, then you make a row

#

but not before then

balmy anchor
#

ok i think i got it ill try 1 sec

opal plank
#

make sure to rather than checking constantly, you map your prefixes on startup

solemn latch
#

^

opal plank
#

so you save up on database calls

balmy anchor
solemn latch
#

I actually had a problem with that, I ended up making so few database calls that mysql would dc me after 8 hours

charred nimbus
#

pm2 not working

solemn latch
#

did you install pm2?

charred nimbus
#

yes

solemn latch
#

is node installed

charred nimbus
#

node is

#

installed

solemn latch
#

can you try running your bot with just node just incase?

charred nimbus
#

ok

solemn latch
#

if it works, then idk :p

polar girder
#

Alright my problem i fixed early now it responds to the cmd but it crashes after i SAY "!play" and gives and error saying "Type Error: Cannot Read Property 'connection' of undefined"

#

Alright my problem i fixed early now it responds to the cmd but it crashes after i SAY "!play" and gives and error saying "Type Error: Cannot Read Property 'connection' of undefined"
@polar girder no i meant no "iplay" its "!play 'songname' "

solemn latch
#

make sure whatever your doing .connection on is defined

#

before using .connection

stark abyss
#

For some reason its generating that box

polar girder
#

ok i think i did that lol @solemn latch

stark abyss
#

?bins

solemn latch
#

you mean the 275e?

stark abyss
#

yeah

#

i need a bin

#

i am using canvas

solemn latch
#

are you using a char that the font doesnt have?

stark abyss
#

whats a char?

polar girder
#

make sure whatever your doing .connection on is defined
@solemn latch wut u mean

solemn latch
#

character

stark abyss
#

oh shit

#

you are right

solemn latch
#

if you do
hi.connection
and hi doesnt exist, you cannot do .connection

#

so you must check if hi exists first

stark abyss
#

Problem solved you are a genius

solemn latch
#

nah, just lucky guess

polar girder
#

switch (args[0]) {
case 'play':

            function play(connection, message)  {
                var server = servers[message.guild.id];

                server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));

                server.queue.shift();

                server.dispatcher.on("end", function(){
                    if(server.queue[0]){
                        play(connection, message);
                    }else {
                            connection.disconnect();
                    }
                    
                });


            }
stark abyss
#

aight ty

polar girder
#

thats what i think my problem is but i dunno

#

that bit of code @solemn latch its just i dunno what to do 😦

solemn latch
#

ngl, i dont even see where you are reading .connection in that code

polar girder
#

i fugired it out its cause its outdated lol

solemn latch
#

🤷‍♂️

polar girder
#

its 2 years old lmao

#

almost 2 years

#

but i gotta redo it lol

tame kestrel
#

switch (args[0]) {
case 'play':

            function play(connection, message)  {
                var server = servers[message.guild.id];

                server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));

                server.queue.shift();

                server.dispatcher.on("end", function(){
                    if(server.queue[0]){
                        play(connection, message);
                    }else {
                            connection.disconnect();
                    }
                    
                });


            }

@polar girder is the play function even being called

solemn latch
#

we mentioned that earlier he made it sound like he was going to google it

charred nimbus
#

why node wont install

charred nimbus
#

on my vps

solemn latch
#

?

#

are you following the instructions

charred nimbus
#

i did sudo apt-get install nodejs

solemn latch
#

thats not the only thing you need to d

#

do

charred nimbus
#

and it tells me ask ur admin

solemn latch
#

ask your vps provider then?

charred nimbus
#

its google cloud

solemn latch
#

good thing google cloud has support

charred nimbus
#

yeah

polar girder
#

const { Client, Message } = require('discord.js')
const ytdl = require('ytdl-core')
const PREFIX = '$'

const client = new Client({ disableEveryone: true })

client.on('ready' , () => console.log('Active'))
if(Message.author.bot) return
if(!Message.content.startsWith(PREFIX.length)) return

const args = message.content.substring(PREFIX.length).split(" ")

if(message.content.startsWith(`${PREFIX}play`)) {
    const voiceChannel = message.member.voice.channel
    if(!voiceChannel) return message.channel.send("You Need To Be In A Voice Channel")
    const permissions = voiceChannel.permissionsFor(message.client.user)
    if(!permissions.has('CONNECT')) return message.channel.send("I don't have permissions to connect to this channel")
    if(!permissions.has('SPEAK')) return message.channel("I Don't Have permission to speak in this channel")

    try {
        var connection = await voiceChannel.join()
    } catch (error) {
        console.log(`There Was An Error Connecting To The Voice Channel: #{error`)
        return message.channel.send(`There Was An Error Connecting To The Voice Channel: #{error`)
    }

    const dispatcher = connection.play(ytdl(args[1]))
    .on('finsish', () => { 
        voiceChannel.leave()
    })
    .on('error', error => {
        console.log(error)
    })
    dispatcher.setVolumeLogarithmic(5 / 5)
} else if (message.content.startsWith(`${PREFIX}stop`)) {
    if(!message.member.voice.channel) return message.channel.send("You Need To Be In A Voice Channel To Stop The Music")
    message.member.voice.channel.leave()
    return undefined
}

Client.login(process.env.TOKEN)

#

whats wrong with it?

quartz kindle
#

lots of things

solemn latch
#

just saying "whats wrong with it" isnt really that useful for people

polar girder
#

SyntaxError: await is only valid in async function

#

is the error msg

quartz kindle
#

lmao

solemn latch
#

you can only use await in async functions

quartz kindle
#

thats not even the first of your problems

polar girder
#

thats the error i got so lol

#

i suck at this

quartz kindle
#

next you will likely get "cannot read property bot of undefined"

polar girder
#

ok

quartz kindle
#

the entire structure of your code is wrong

polar girder
#

so do i just remove await?

quartz kindle
#

you need to create a message event listener

polar girder
#

ok this is complicated

solemn latch
#

await is needed if you need the promise resolved

polar girder
#

this is going to be "fun"

quartz kindle
#

you're working on the wrong thing, you're trying to use Message, but Message is the class itself, not the instance

#

you dont use Message directly like that

#

you need to create a message event listener

#

the same way you have a ready event listener

polar girder
#

so like what do i need to change or add?

quartz kindle
#

like this

#
client.on("message", message => {
  // code here
})
#

that is the correct message to work on

#

not the Message you're getting from discord.js

polar girder
#

so the first line i replace with this?

stark abyss
#

does anyone know if i can use shadowColor to text in canvas?

#

or is it just to objects?

quartz kindle
#

no, you need to put all the code you have after client.on("ready") inside a client.on("message")

#

except client.login()

#

check the guide for discord.js

#

and start from there

#

@stark abyss there is shadowBlur

stark abyss
#

shadowBlur got it thanks tim

quartz kindle
#

closest thing you can get

stark abyss
#

ok ok

polar girder
#

client.on('ready' , () => console.log('Active'))

client.on('message', async message => {
if(Message.author.bot) return
if(!Message.content.startsWith(PREFIX.length)) return

const args = message.content.substring(PREFIX.length).split(" ")
#

its that right?

#

@quartz kindle

blissful coral
#

Close the ready event if you haven’t already

#

And you capitalized Message on message.author.bot

#

Everywhere is capitalized

#

Needs to be lower case

polar girder
#

now i got an error of emitter.on is not a function damn my code is full of problems

faint prism
#

Message.content.startsWith(PREFIX.length)
Is that right...?

#

Not Message.content.startsWith(PREFIX) ?

polar girder
#

i fixed it yeah i just noticed it to

split hazel
#

anyone else hate nodejs has no multithreading support mnp_cry

blissful coral
#

Yep

split hazel
#

so easy to block the main thread

blissful coral
#

Yeah

split hazel
#

i think there was someone that added threading support to nodejs

blissful coral
#

Ooooo

split hazel
#

dont know how well that works

blissful coral
#

Prob not well

split hazel
#

or if its just a boring worker process

stark abyss
#

i am little confused on how createLinearGradient works

white night
#

im not good with server side of things why is my is my thing doing this
Error: Cannot find module '/home/container/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

#

where as my other server here at my home is not doing this

stark abyss
#

it can't find the module you are calling

#

weird

#

nvm I found the answer

sand shore
#

Would anyone make me a music bot for free? Don't care if the code is copied or whatever. Like from a yt video or something. Just needs to work. Saying this cause I want the bot to be 'custom'. So its our bot and not like groovy or rhythm. Code could literaly be copied from them, but don't know how to do that kind of stuff so thats why im asking. Like no nothing about bots and making them. Thanks, sorry bout long msg if u made it this far. Dm me if u are willing

polar girder
#

i swear to JESUS CHRIST i have an error saying my token is undefined

white night
#

f

pale vessel
#

bismillah

polar girder
#

client.login(process.env.TOKEN)

#

is what i got but my token is where TOKEN is

thick raven
#

If someone answers animeboi's question can you also dm me with the source code

polar girder
#

Would anyone make me a music bot for free? Don't care if the code is copied or whatever. Like from a yt video or something. Just needs to work. Saying this cause I want the bot to be 'custom'. So its our bot and not like groovy or rhythm. Code could literaly be copied from them, but don't know how to do that kind of stuff so thats why im asking. Like no nothing about bots and making them. Thanks, sorry bout long msg if u made it this far. Dm me if u are willing
@sand shore i mean im making one and i dont understand code as well but i mean if u want a crappy one here u go!

sand shore
#

i mean all i need it to do is play, pause, unpause basically

#

if it does that...

pale vessel
#

ask somewhere else

polar girder
#

i mean i can its mine wont login cause coding is like that

#

const { Client, Message } = require('discord.js')
const ytdl = require('ytdl-core')
const PREFIX = '$'

const token ='';

const client = new Client({ disableEveryone: true })

client.on('ready' , () => console.log('Active'))

client.on('message', async message => {
if(message.author.bot) return
if(!message.content.startsWith(PREFIX)) return

const args = message.content.substring(PREFIX.length).split(" ")

if(message.content.startsWith(`${PREFIX}play`)) {
    const voiceChannel = message.member.voice.channel
    if(!voiceChannel) return message.channel.send("You Need To Be In A Voice Channel")
    const permissions = voiceChannel.permissionsFor(message.client.user)
    if(!permissions.has('CONNECT')) return message.channel.send("I don't have permissions to connect to this channel")
    if(!permissions.has('SPEAK')) return message.channel("I Don't Have permission to speak in this channel")

    try {
        var connection = await voiceChannel.join()
    } catch (error) {
        console.log(`There Was An Error Connecting To The Voice Channel: #{error`)
        return message.channel.send(`There Was An Error Connecting To The Voice Channel: #{error`)
    }

    const dispatcher = connection.play(ytdl(args[1]))
    .on('finsish', () => { 
        voiceChannel.leave()
    })
    .on('error', error => {
        console.log(error)
    })
    dispatcher.setVolumeLogarithmic(5 / 5)
} else if (message.content.startsWith(`${PREFIX}stop`)) {
    if(!message.member.voice.channel) return message.channel.send("You Need To Be In A Voice Channel To Stop The Music")
    message.member.voice.channel.leave()
    return undefined
}

})

client.login(token);

#

thats my code

sand shore
#

thanks wow

polar girder
#

the problem im having is it wont login in why

white night
#

ima hust use my pc as a server

half plinth
#

for discord.py: Can someone tell me how to properly use get_user_vote(user_id: int)

solemn latch
#

looks like its just a function

#

so

#

get_user_vote(user.id)

polar girder
#

ayo @solemn latch my bot is running and connected to the VC but there is no sound how do i fix?

solemn latch
#

🤷‍♂️

half plinth
#

Woo this is the full code fromt he documentation

#

async def get_user_vote(self, user_id: int):
"""This function is a coroutine.

    Gets information about the user's upvote for your bot on top.gg.

    Parameters
    ==========

    user_id: int
        ID of the user you wish to lookup.

    Returns
    =======

    vote status: bool
        Info about the user's upvote.
    """
    await self._ensure_bot_user()
    data = await self.http.get_user_vote(self.bot_id, user_id)
    return bool(data['voted'])
#

would i put it in a commands.Cog.listener()

polar girder
#

IT WORKS LETS GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

pale vessel
#

well if it accespts it like that, try get_user_vote(self, user_id=ID)

balmy anchor
#

Does anyone knows why does it sends a message 500x times almost lol?

fickle sapphire
#

Because you send it and then it reacts on that message

blissful coral
#

Not from there

fickle sapphire
#

XD

blissful coral
#

Where?

balmy anchor
#

wdym?

fickle sapphire
#

wdym?
@balmy anchor You react on every message sent by the bot, but the message you send then is also a message what triggers that event over and over again

balmy anchor
#

oh ok

#

so how do i send this message only 1 time?
is there a way to block it?

lost stone
#

client.on('message', message => {
if(message.content === 'lock') {
message.channel.updateOverwrite(message.channel.id, { SEND_MESSAGES: false, VIEW_CHANNEL: true});
message.reply('Locked')
}
}}

#

who can tell me how to change this to lock all the channels

pale vessel
#

why channel id for the overwrite?

#

it needs to be a member or a role

#

not a channel

lost stone
#

who

pale vessel
#

ugh

balmy anchor
#

@lost stone

lost stone
#

?

balmy anchor
#

this is what u need

#

huh

solemn latch
#

spoonfeeding is against the rules

balmy anchor
#

and spoonfeeding is sorry about the q?

lost stone
#

@solemn latch he just helped me

solemn latch
#

giving copy paste code

#

is against rules

balmy anchor
#

its mine code

#

btw

lost stone
#

i hate a person who says spoonfeed , he didnt spoonfood me he forkfeeded me

balmy anchor
#

im using it for my bot and i dont care if he uses this

solemn latch
#

yikes

balmy anchor
#

wow

#

ur rude today

solemn latch
#

your breaking rules today

#

:p

lost stone
#

@balmy anchor thanks❤️

balmy anchor
#

for what?

balmy anchor
#

ok

#

but if i dont care about it?

#

and its my code

#

that I made

solemn latch
#

still against rules

opal plank
#

its about the rules dude, just follow them

balmy anchor
#

so if i dm him this its still against the rules idk?

solemn latch
#

its not in the server, but your avoiding the rules which are inplace to help

#

spoonfeeding is bad for those learning

opal plank
#

feeding someone pre-made code doesnt help in any way, as they are likely not gonna learn from it and simply copy paste it, whcih will in turn make them just come back for more when they are stuck in the same thing

balmy anchor
#

yeah but I just wanted to help tho u guys know this lol

opal plank
#

i know your intentions werent bad

#

just please give them docs or a rough explanation of what they need

#

if they still struggling, provide some more help ontop

balmy anchor
#

Nothing I can say about it

sudden geyser
#

Giving the source code is not necessarily a problem, but the issue is it teaches newbies to write in only one style rather than seeing how to implement it themselves.

balmy anchor
#

ok so ill not send him that wow

#

bye gn

lost stone
#

what the hell

balmy anchor
#

idk

#

talk to them

#

Woo and Not Erwin I can understand why u guys are saying that but it doesnt means I cant help him u know

#

😛

solemn latch
#

no one said dont help him

#

we said dont break the rules

lost stone
#

show the number of this rules @solemn latch

solemn latch
#

the no spoonfeed rule is to help devs, not hurt them

lost stone
#

Xignotic#0001

solemn latch
#

you two might be taking this too personally, i reminded erwin about spoonfeeding today too 🤷‍♂️

#

ive been asked to not do it multiple times

opal plank
#

sometimes we get carried away

drifting wedge
#

how do premium bots work? like to give users access to them?

solemn latch
#

i dont have any premium features added yet, but i do have it setup

drifting wedge
#

how does it work?

solemn latch
#

i just have patreon bot that gives a role and the bot checks for that role

thin turret
#

How can I have my bot's github repo be public and keep the token private/hidden

opal plank
#

on payment => add id to whitelist => when command is run, check if the user who issed the command is part of the whitelist

drifting wedge
#

what is the best way for payment?

solemn latch
#

setup for $3 > $5 > $10 roles

opal plank
#

best? idk

solemn latch
#

as many as possible

opal plank
#

paypal, stripes and patreon are the most used afaik

solemn latch
#

i use venmo for some stuff. sites that use venmo im 10x more likly to buy from

drifting wedge
#

is patreon the best for subscriptions?

solemn latch
#

yes and no

#

patreon has done some really crappy things to people

drifting wedge
#

patreon has done some really crappy things to people
@solemn latch ?

sudden geyser
#

How can I have my bot's github repo be public and keep the token private/hidden
@thin turret store the token in a file that you don't push to GitHub, such as a .env file.

drifting wedge
#

subscriptions r the best, cuz its like recurring

sudden geyser
#

It can be any file as long as your credentials are stored there.

#

Then use that file to pull your credentials in your source code.

thin turret
#

so just like token.env and require it to index as any other file?

white night
#

omg i finnaly got my bot to work

solemn latch
#

ay

drifting wedge
#

gg

balmy anchor
#

gj

sudden geyser
#

Elite what language are you using

thin turret
#

djs

white night
#

stupid thing need its own folder

sudden geyser
#

This is what you'll want.

thin turret
#

Epic thanks

sudden geyser
#

Keep in mind as long as you keep the credentials stored in some file you don't push to GitHub, it's fine. You could even have a .json file you don't push then require it.

foggy cove
#

exports.run = (client, message, args) => {
const serverQueue = client.queue.get(message.guild.id);
if (!message.member.voiceChannel) return message.channel.send('You are not in a voice channel!');
if(!serverQueue) return message.channel.send('Not playing anything right now');
serverQueue.loop = !serverQueue.loop;
return message.channel.send(I have now ${serverQueue.loop ? Enabled:Disabled} loop.)

};

can someone please tell me why the only response i get is 'You are not in a voice channel' even if i am ;-;

sudden geyser
#

because .voiceChannel is probably resolving to undefined because the property doesn't exist.

#

You're probably looking for .voice.channel, assuming you're using Discord.js v12

haughty bough
#

How do I check if a bot is connected to a voice channel?

solemn latch
#

depends on the language and library

haughty bough
#

Js

#

v12

foggy cove
#

that's weird, last time i actually did so, voice.channel according to VSC doesn't exist

solemn latch
#

the question just above yours is the same practically @haughty bough

#

.voice.channel

sudden geyser
#

What version of Discord.js are you using

white night
#

my bot seems to love crashing when it doesnt have perms to join a voice channel

sudden geyser
#

Have you checked that it has permission beforehand

#

or added error handling

solemn latch
#

you need to check perms for pretty much every request that does something

white night
#

yeah i made the invite requie the perms

sudden geyser
#

That's not enough

solemn latch
#

you also need to check in code

foggy cove
#

discord.js v12

What version of Discord.js are you using
@sudden geyser

white night
#

ok will do

foggy cove
#

nvm i see why now

sudden geyser
#

yup

foggy cove
#

constants.jpeg be tripping

silver lintel
#

https://hastebin.com/tavedidoci.typescript
(node:18665) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType at RequestHandler.execute (/rbd/pnpm-volume/6da398da-dcf5-499a-9395-ab3ac6de59c5/node_modules/.registry.npmjs.org/discord.js/12.3.1/node_modules/discord.js/src/rest/RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:88:5) (node:18665) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:18665) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero

foggy cove
#

it actually works! i am doodoo brain

sudden geyser
#

Plebus the stacktrace doesn't tell us much. Are you able to debug where it's coming from which may have caused the error.

ember lodge
#

Someone know how can i put a button next to a textbox?

pale vessel
#

inline

#

make input inline

ember lodge
#

thanks

silver lintel
#

all that shows that error, and with the kick cmd, all i changed is await banMember.ban(banReason); to await kickMember.kick(banReason); and it works

haughty bough
#

the question just above yours is the same practically @haughty bough
@solemn latch I'm trying to check if the bot I'm working on is on a voice channel, if it is, it will come out of it. I tried to use message.member.voice.channel, but it tells me sorry if the member who sent the message is on a channel (I think it must be ".member", right?). ps: I'm a beginner 😦

solemn latch
#

any Member class has .voice
message.member.voice.channel would be the person who sent the message.

#

if you wanted for example the bots member object, you could use message.guild.me
.me being the bot itself.

silver lintel
#

ohhh i fixed because i forgot to put correct parameters :/

haughty bough
#

if you wanted for example the bots member object, you could use message.guild.me
.me being the bot itself.
@solemn latch This solved my problem! Thank you very much

solemn latch
#

np

digital ibex
#

hi

#

im sending an array to my frontend and its getting transferred into a number for some reason

#

so im sending: ['123', '123'] and its in the frontend its 123,123

#

any idea how i can turn it back into an array? i've tried google but the commas are screwing everything up

pale vessel
#

array.toString() does that

digital ibex
#

1 sec

pale vessel
#

did you send it as text?

ionic dawn
#

do I have to make a mysql connection in every single command that its gonna use the db or can I make the mysql connection in the main and use it somehow in other command file

pale vessel
#

both work fine

digital ibex
#

im just using res.render

#

in express

pale vessel
#

that's probably the problem

ionic dawn
#

so it dsnt matter if I make a connection in every command?

pale vessel
#

you want to display it as an object instead

#

yes, just make sure you're closing the connection after done

digital ibex
#

the way im doing it is like res.render('e', { array: ['123', '123']})

pale vessel
#

that's going to .toString() it

#

use JSON.stringify()

digital ibex
#

in the frontend?

pale vessel
#

yes

digital ibex
#

kk

#

it works ty

#

oh wait it didnt

#

it just added the numbers together

pale vessel
#

bruh

#

what did you do

digital ibex
#

this is what i done js const roles = JSON.stringify(<%- modRoles %>); document.getElementById('modroles-to-show').innerHTML += roles

pale vessel
#

isn't modRoles an array

#

oh wait

#

nmnm

solemn latch
#

isnt stringify turning the array into a string

pale vessel
#

yes

solemn latch
#

which drops the []

pale vessel
#

nope

solemn latch
#

o

digital ibex
#

how do i turn it into an array then?

#

client side

pale vessel
#

that's .toString()

digital ibex
#

1 sec

pale vessel
#

try logging modRoles

digital ibex
#

it logs the mod roles of the server, im using a different pc on discord and different to code

#

my other pc is too slow to handle discord now lol

pale vessel
#

so it logs the array just fine

digital ibex
#

server side yes, not client side

pale vessel
#

what does it look like on the frontend?

digital ibex
#

like id,id,id 123456789,123456789,123456789

pale vessel
#

can you try console.log(<%- modRoles %>)

digital ibex
#

its like id,id,id

#

not [id, id,id]

pale vessel
#

looks like it's a string yea

#

you can just JSON.stringify() it on the back end actually

#

way easier

digital ibex
#

kk

#

ah ha

#

that fixed it, thanks

pale vessel
#

aa very nice

digital ibex
#

alssosooon one last thing

#

im doing a similar thing to the way mee6 has the mod role and u click on it and it gets removed as a role, how do i go about doing this?

#

i just realised im talking about how discord does it too

pale vessel
#

discord use their rest api i guess

#

as for bots, i think it handles it on the backend

digital ibex
#

i mean like the frontend part

#

if im talking any sense lol

pale vessel
#

can't you do an API request on the backend from the input from the frontend?

#

or maybe a websocket server between the dashboard and your bot with some kind of authentication. the bot handles the request on the backend

digital ibex
#

yeah, but like the way it like does overflow

#

uh idk how to explain

#

nvm, im confusing myself here somehow. thanks for the help tho

tame kestrel
#

any way to get accurate mem use/mem cap info with node?

faint prism
#

User - Front end - Back end - 3rd party APIs

#

any way to get accurate mem use/mem cap info with node?
@tame kestrel for the running process or system?

tame kestrel
#

process

#

I guess process.memoryUsage().rss could give me what I need

faint prism
#

Yeah

#

And if you wanted system memory you'd import the os module

tame kestrel
#

i c
thank you

cyan junco
#

Hi

#

Kk

faint prism
#

Np safe

carmine summit
#

let rolesArray = await message.member.roles.cache.map(r => r.id)

blissful coral
#

uh

#

that is right

carmine summit
#

so uh

#

what now

stable snow
#

python

faint prism
#

just pass in that string as the URL?

blissful coral
#

@carmine summit try removing await and console.log it

stable snow
#

just pass in that string as the URL?
@faint prism didnt work

faint prism
#

so what, nothing happened? or an error?

#

What's the embed look like?

stable snow
#

there was a blank embed

carmine summit
#

no fix...

stable snow
faint prism
#

have you tried (url="thelink")

stable snow
#

yea

faint prism
#

wb set_thumbnail(url="url")?

stable snow
#

hmm lemme try that

carmine summit
#

@carmine summit try removing await and console.log it
@blissful coral no fix

blissful coral
#

Says its not a function?

#

Tf

stable snow
#

i got another blank embed @faint prism

blissful coral
#

@carmine summit it may not be cached

#

try restarting

carmine summit
#

ive restarted it many times

tame kestrel
#

is cache undefined or something... try logging it

blissful coral
#

console.log(message.member.roles.cache)

sonic lodge
#

@stable snow could you possibly fetch the url, and turn the response into a buffer?

carmine summit
#

returned the roles

stable snow
#

hmm ok

blissful coral
#

I have never seen this

#

weirdest error

stable snow
#

like this?

carmine summit
#

also

stable snow
#
    @commands.command()
    async def servers(self, ctx):
        servers = 'https://top.gg/api/widget/servers/742073065034481756.png?noavatar=true'
        servers = requests.get(servers)
        embed=discord.Embed()
        embed.set_image(url=servers.content)
        print(servers)
        embed.set_thumbnail(url=servers)
        await ctx.send(embed=embed)```
@sonic lodge
carmine summit
#

if i ?eval it

blissful coral
#

wait can you show screenshot

#

plz

carmine summit
#

works fine

blissful coral
#

show code

carmine summit
sonic lodge
#

fetch, as in use the fetch api

stable snow
#

whats that

sonic lodge
#

oh ok nvm, i was confused for a bit because it's python

#

try it and see if it works

stable snow
#

k

#

it said not a well formed url

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.image.url: Must be 2048 or fewer in length. Not a well formed URL.
In embed.thumbnail.url: Not a well formed URL.```
#

@sonic lodge

sonic lodge
#

well when you fetch the image, the response isn't a url, but instead a buffer

stable snow
#

how do i make it a buffer

sonic lodge
#

it is a buffer, you just need to attach it to the message as a file

stable snow
#

oh ok

sonic lodge
opal plank
#

ugh this is annoying

sonic lodge
#

😐

opal plank
#

how the f am i suppose to return a retry?

#

that is nested inside 3 funtions?

stable snow
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not Response

#
    @commands.command()
    async def servers(self, ctx):
        servers = 'https://top.gg/api/widget/servers/742073065034481756.png?noavatar=true'
        servers = requests.get(servers)
        file = discord.File(servers, 'servers.png')
        embed=discord.Embed()
        embed.set_image(url='attachment://servers.png')
        print(servers)
        await ctx.send(file=file, embed=embed)```
sonic lodge
#

servers.content

stable snow
#

OH yeHA

carmine summit
#

@opal plank help

#

i need helpppppp

stable snow
#
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/VxRP/cogs/botlists/topgg.py", line 76, in servers
    file = discord.File(servers.content, 'servers.png')
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/file.py", line 73, in __init__
    self.fp = open(fp, 'rb')
ValueError: embedded null byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 198, in on_command_error
    raise error
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: embedded null byte```
#

yikes

sonic lodge
#

i feel like i should stop before my smol python knowledge breaks your computer bot

stable snow
#

lmao i use rEpL

faint prism
#

that is nested inside 3 funtions?
@opal plank recursion mmLol

stable snow
opal plank
#

im gonna go PATCH method rather than proper stuff tbh

#

await =>
function => join channel
inside join channel => if fail , retry
inside retry function => if fail, retry again & attempts ++ / if attempts > maxAttempts return ??

#

fml

stark abyss
opal plank
#

i works already though, but the display is bugging me a ton cuz its not properly waiting for the responses. The shards are working just fine

sonic lodge
#

hm @stable snow, maybe discord.File(BytesIO(servers.content), 'file.png')?
if it doesn't work ima stop there lol

stark abyss
#

I don't understand why that got messed up ;-;

carmine summit
#

@opal plank .map() is not a function let rolesArray = message.member.roles.cache.map(r => r.id)

stable snow
#

hm @stable snow, maybe discord.File(BytesIO(servers.content), 'file.png')?
if it doesn't work ima stop there lol
@sonic lodge ok

#

omg it worked

#

ty @sonic lodge

drifting wedge
#

my whole website is lightmode

#

is making it darkmode hard?

stable snow
#

wdym

#

or yours

stark abyss
#

how to detect a blank line

#

is it just ' '

#

test frame 2 Bokura ga Ita
"I want to go back and change the past. If I could - I would, if that would stop you from crying."
~Motoharu Yano

#

as you can see its messing up

#

it works fine if if i don't leave the rest of line blank

foggy cove
#

please help i dont know where my errors are coming from-

tame kestrel
#

each of those errors you can click and it will take you to where the typescript compiler didn't like whatever you're doing

#

@foggy cove

sage bobcat
#

One message removed from a suspended account.

foggy cove
#

damn i wanna cry

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

foggy cove
#

i guess so, ill retype it anyways

#

all i feel is pain

stark abyss
#

can anyone help me 😔

#

i am asking for your help once again 😔

sonic lodge
#

you dont have to retype everything

opal plank
#

welcome to typescript, where, y'know, you TYPE

tame kestrel
#

lmao

opal plank
#

Type...Script

#

bruh im legit pulling my hairs rn

sonic lodge
#

so you type your scripts in typescript, very nice

stark abyss
#

erwin my guy do you think u can help me pepeStomach

opal plank
#

with?

stark abyss
opal plank
#

if the lagg does kill my pc first for emulating massive traffic i might be able to lmao

stark abyss
opal plank
#

first thing

#

var

#

stop that shit

#

you dont need scoped variables to be declared globally

stark abyss
#

okay I will use let or const

foggy cove
#

my bot runs on a server and god i cant count how many times ive crashed it

opal plank
#

is that canvas?

stark abyss
#

yes

opal plank
#

then im not much help

#

i dont use canvas

stark abyss
#

its my wrap text function

#

but you have big brain skills

opal plank
#

my brain has been beaten to a pulp debugging my sharding rn

stark abyss
#

ok

#

well do you know a way i can tell if it's blank? like it's console logging a blank line i if i can somehow detect that and do something i can fix it

opal plank
#

define blank

stark abyss
#

like

#

literally a blank line

opal plank
#

you mean empty string

stark abyss
#

yeah that

opal plank
#

empty strings are falsey by nature

#

just do a simple if !string

stark abyss
#

oh okay thx

#

didn't work ;-;

opal plank
#

it do

stark abyss
#

I mean I don't doubt you

#

can't figure out why it didn't

opal plank
#

BRUH

#

am i being stupid or concat not working like i thought it would on arrays?

stark abyss
#

var words = text.split(' ');
I am doing that and this also picks up empty line i believe is there a way to prevent that?

sudden geyser
#

@opal plank are you using .concat on it

#

because concat is known for being very slow

opal plank
#

exbrain pliz. _a has a value, then i concat an array with _a, now the array is empty? WOT?

pearl trail
#

hewo, i have question, i think it's a stupid question but i don't understand. i want to send random image from my file, this is my code


module.exports = {
    name: "chino",
    description: "show random chino pic",
    async execute( message ) {
        var files = fs.readdirSync("./Picture/Chino")

        let chosenFile = files[Math.floor(Math.random() * files.length)]

        message.channel.send(chosenFile);
    }
}
#

and it just send the picture's name

sudden geyser
#

@opal plank .concat returns a new array

blissful coral
#

lul

opal plank
#

oh that explains it

blissful coral
#

Theres ya answer

opal plank
#

fml

sudden geyser
#

yeah also I recommend using the spread operator to merge two or more arrays instead

#

concat is very slow compared to it

opal plank
blissful coral
#

@pearl trail Because that isn't how you do a file attachment

stark abyss
pearl trail
#

oh, so how ;-;

stark abyss
#

var words = text.split(' ');
I am doing that and this also picks up empty line i believe is there a way to prevent that?

blissful coral
#

Examples

// Send a basic message
channel.send('hello!')
  .then(message => console.log(`Sent message: ${message.content}`))
  .catch(console.error);

// Send a remote file
channel.send({
  files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
  .then(console.log)
  .catch(console.error);
// Send a local file
channel.send({
  files: [{
    attachment: 'entire/path/to/file.jpg',
    name: 'file.jpg'
  }]
})
  .then(console.log)
  .catch(console.error);
// Send an embed with a local image inside
channel.send('This is an embed', {
  embed: {
    thumbnail: {
         url: 'attachment://file.jpg'
      }
   },
   files: [{
      attachment: 'entire/path/to/file.jpg',
      name: 'file.jpg'
   }]
})
  .then(console.log)
  .catch(console.error);
#

@pearl trail

sudden geyser
#

.readdirSync returns an array of the names of the files and directories in an array. Of course it only returns the name of the file. You need to use the name of that to get the file's local path.

pearl trail
#

owh, but i have more than 1 image,

sudden geyser
#

the examples above are also good

pearl trail
#

i want to pick random

sudden geyser
#

So pick the random image, and use the name of that image in the file path

tame kestrel
#

yes, so use what you have so far to get the name of the string, and plug the name into the code above to send the file

opal plank
#

the more i code the dumber i get, its insane

pearl trail
#

lemme try

tame kestrel
#

relatable

opal plank
#

fml, i wasted every single one of my brain cells

sudden geyser
#

are you writing code at 2 in the morning

opal plank
#

its midnight rn, and i got no alcohol, so that might be some of the causes

tame kestrel
#

Erwin finishing off his free trial of brain cells pepeCRY

opal plank
sudden geyser
#

don't worry, some more will respawn tomorrow

opal plank
#

this should work now

#

actually

#

i might stream this

#

for those who want to see tears

stark abyss
pearl trail
#

why i always get Error: ENOENT: no such file or directory, stat '/Users/arya/Documents/Bot/Music Bot/Neko-Bot-master/Users/arya/Documents/Bot/Music Bot/Neko-Bot-master/Picture/Chino'

opal plank
#

that was it

stark abyss
#

nice

opal plank
#

they still going over what they should be

#

but the spawner is working fine

#

i just need to put the websocket to sleep until the whole thing finishes

stark abyss
#

the only thing i can do is wish some luck. letsdance

opal plank
#

sankyu

#

this code is legit a nightmare

#

im not even kidding

#

idk if you caught the actual code in the background

#

time to push this to the main branch and watch as shit legit dies

#

time to test on prod again

#

no nononono

pearl trail
#

finally, thank you spooky extreme

opal plank
#

i think i did it

#

cost me all my braincells

#

but i done did it

earnest phoenix
#

This is a bit of a general question but does anyone know good ways to store data. What I mean by that is like when you mute someone (example) and maybe want to store that mute in a database, so that it can be fetched even after restarting your code. I know that you would use a file system but is there any efficient way to do it, and if so, pls dm me or ping me with tips

opal plank
#

@earnest phoenix database

solemn latch
#

its called a database

earnest phoenix
#

but what kind

solemn latch
#

any

earnest phoenix
#

hm so i can just look one up?

opal plank
#

up to you, right tool for the right job

earnest phoenix
#

alright, i'll look into it

opal plank
#

goes by preference and usability

#

just look at something thats ACID compliant

earnest phoenix
#

i'm new to bots and this was the biggest obstacle for me

solemn latch
#

people get spooked by databases, but the basics can be learned in an afternoon

#

if you actually research the topic

drifting wedge
#

@opal plank how many servers leviathan in?

#

Also u make any money from it?

opal plank
#

in which platform?

drifting wedge
#

Discord

opal plank
#

i think 70 something

earnest phoenix
#

@solemn latch just so ik, when ur using a standard database, is it easy to index and modify? or would u have to rewrite files to alter them

opal plank
#

it would've been on many more if i didnt have the auto-leave guilds function

#

inactive guilds / bot hells it just leaves

drifting wedge
#

Why?

opal plank
#

cuz its a streaming bot, why would i want to be in any server thats not a streamer/active server?

drifting wedge
#

cuz its a streaming bot, why would i want to be in any server thats not a streamer/active server?
@opal plank true

#

U make any money?

opal plank
#

not currently, no

solemn latch
#

indexes are super simple, modifying is all databases do(lookups are easy too)

drifting wedge
#

Also how does it work? Like night bot?

solemn latch
#

you are not directly editing files in most databases

earnest phoenix
#

alr tysm @solemn latch

opal plank
#

its quite different than nightbot

#

more towards utility rather than moderation

drifting wedge
#

Same idea?

opal plank
#

you are comparing apples to oranges tbh

drifting wedge
#

Like chat bot?

#

Like use in twitch chat

opal plank
#

well, both are chat bots, though they work in different manners

drifting wedge
#

Okok

#

Cool idea

opal plank
#

ty

drifting wedge
opal plank
#

twitch is a pain and a half to deal with though

#

discord is the easy mode of bots, not gonna lie

drifting wedge
#

Lol

#

Topgg queue is the final boss fight

opal plank
#

tons of bots lol

drifting wedge
#

My bots at 91 servers, so it’s doing ok I’d say

tame kestrel
#

isn't twitch just irc?

drifting wedge
#

IRC?

tame kestrel
#

I guess just is underplaying it but

opal plank
#

yeah

drifting wedge
#

Also wuts iirc?

opal plank
#

though not JUST IRC

tame kestrel
#

yeah haha

opal plank
#

its quite a pain not even kidding

#

their docs are messy and very not friendly

tame kestrel
#

irc bots are the original chat bots

drifting wedge
#

And iirc? An acronym?

opal plank
#

now everyone just be like : ey, i got a lib that does what i want

tame kestrel
#

if i remember correctly

#

@drifting wedge

drifting wedge
#

Oooh ty

opal plank
#

IRC is not iirc btw

drifting wedge
#

Ik

opal plank
#

we talking about IRC

tame kestrel
#

discord js makes it so ez pepeCRY

opal plank
#

not only d.js

#

anything you need you have readily available

#

try finding a js lib for youtube

tame kestrel
#

oh well that's just like, the javascript experience

opal plank
#

not for other chats

#

discord is the easy mode of bots

#

people dont ever have to deal with connections or handling anything tbh

#

its like: hey, heres my token, take care of everything for me

#

-twitch does the connection for you, but nothing else

-youtube throws you at the lions

-discord provides everything you need, handy methods, connection handling, everything pre-made packed with a hug

#

youtube has been the worst so far

#

there are no chatbot libs for it

#

here's the docs, have fun

astral yoke
#

discord bots are the easiest compare to the real world shit

#

some websites has so much code

#

or even like actual servers

thick raven
#

I’ve been making an economy bot and I’ve been struggling on making the jobs does somebody have code I can use?

astral yoke
#

thats the worse way to be a developer

#

is to source code the main part of the bot economy

thick raven
#

Sorry

#

I’ve made everything else and I’m just having trouble do u have any tips on what to do

astral yoke
#

i can help with it

drifting wedge
#

@thick raven jobs? Do what you can

#

What you can’t, Google

#

What you can’t Google, probably ask scltxn

#

Lol

astral yoke
#

lmao

restive notch
#

how can i get the avatar url of a specific ID

#

i have let usericon = message.author.avatarURL(); for the avatar url of the author of the message

pale vessel
#

resolve the id to a user first

restive notch
#

i know the ID

pale vessel
#

you can use client.users.cache.get(id)

restive notch
#

its my bots ID

pale vessel
#

just use client.user.avatarURL() then if it's the bot

restive notch
#

oh

#

thanks

carmine summit
#

So uh, when I do db.push with a number as value, Instead of it being an array, it becomes a number. Then when I do db.push again, Its gonna error that it is not an array

db.push("foo", 10)
db.get("foo")
//Returns 10
//Expected ["10"]
db.push("foo", 11)
//Gives error that "foo" is not an array
pale vessel
#

the initial value must be an arrayjs db.set("foo", [10]); // [10] db.push("foo", 11); // [10, 11]

carmine summit
#

Ok thanks

#

How can I get a role ID by mention

#

ya know @rolename

#

without .replace()

#

nah im just gonn use .replace

solemn latch
#

message.mentions.roles

#

?

carmine summit
#

ah right

agile lance
#

message.mentions.roles.first()

carmine summit
#
message.guild.roles.cache.get(args[0]) || message.guild.roles.cache.find(r => r.name == args[0]) || message.mentions.roles.first()
```??
charred jetty
#

i wanna set setInterval() in a collection by forEach() but with different time... how to do it? discord.js

#

i wanna set setInterval() in a collection by forEach() but with different time... how to do it?
if you can then dm me...

feral aspen
#

How can I get or put the bot profile picture in the title embed?

#

Anyone?

tame kestrel
#

discord.js? or py?

#

or other?

feral aspen
#

js

#

client.user.avatarURL() doesnt work in the .setTitle()

tame kestrel
#

You need to put your image url where they accept it

feral aspen
#

Im trying to make the title like that.

tame kestrel
#

That's the author photo

#

.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')

opal plank
#

^^

feral aspen
#

Oh.

tardy hornet
opal plank
#

i finally got this shit to work properly, its now respecting the 2500 limit

feral aspen
#

Can't seem to understand why it needs a 3rd link @tame kestrel

opal plank
tame kestrel
#

The third link is an override iirc, it's optional

opal plank
#

isnt it the link?

#

for when you click it

tame kestrel
#

si

opal plank
#

redirect or something, i forgot the actual nomenclature

tame kestrel
#

slave0 pepeCRY

opal plank
#

console spam

#

slave0 dying hard

#

idk why tbh

#

slave0 has 1057 channels, it failed over 1,5k

#

im waiting for them all to populate to see a shard6 spawning

#

i should add a failed count and then route the traffic to more stable shards tbh if too many fail

#

im fairly certain the shard0 got ratelimited

earnest phoenix
#

@opal plank why the hell are you ddosing twitch in the first place

opal plank
#

erm

#

eeerm

earnest phoenix
#

Hi i need help

#

got some erroe

#

error

#
const client = new Discord.Client();

client.once('ready', () =>{
    console.log('YesBot is online!')

});

client.login('XXX')
#

when i run it

#

it shows an error

#

what error?

#

can you show the first line of the error