#development

1 messages · Page 924 of 1

copper cradle
#

remember

#

you always return something

#

if you don't add one yourself then it'll be return undefined; or just return; by default

wicked pivot
#

okay thx

copper cradle
#

if you want the code to stop from executing use a return

#

there can't be code below a return statement unless the return is inside of an if statement

#

bc once it reaches the return the function 'returns' and stops from executing

nimble escarp
#

ŗ̸̉e̶͋̚t̴̽͋u̵̇͋r̸̛̍n̷̛̈ ̴͆͑v̸̐̽o̷͋͌ì̴̲d̶̏̄;̵̽͝

ashen ridge
wicked pivot
#

can someone help me for something else?

pale vessel
#

just ask

#

please

summer torrent
#

don't ask2ask

pale vessel
wicked pivot
#

I would like to create a text file that groups all my results, and if the result and I even raised everything

earnest phoenix
#
discord.ext.commands.errors.MissingRequiredArgument: url is a required argument that is missing.
params: self, ctx, *, url

#

python

copper cradle
#

you're not passing in an url parameter

earnest phoenix
#

so?

copper cradle
#

so???

#

how come you're even asking

#

pass in the url param

#

when you run the command

earnest phoenix
#

i do -play <url_here>

copper cradle
#

remove that *

earnest phoenix
#

ok

copper cradle
#

why do you even need that

#

where did you copy the code from?

earnest phoenix
#

for -play <name>

#

i dont copy that

wicked pivot
#

suddenly someone can help me on what I want to do:
I would like to create a text file that groups all my results, and if the result and I even raised everything

earnest phoenix
#

i need url parameter for this

        player = await YTDLSource.from_url(url, loop=self.client.loop)
```@copper cradle
#

wait nvm

#

but dont work

copper cradle
#

show you code

earnest phoenix
#
@client.command()
async def play(self, ctx, url):
    """Plays from a url (almost anything youtube_dl supports)"""

    async with ctx.typing():
        player = await YTDLSource.from_url(url, loop=self.client.loop)
        await ctx.voice_client.play(lista[0], after=lambda e: funcion2(ctx))

    await ctx.send('Now playing: {}'.format(player.title))

slender thistle
#

You don't need self if the function is outside of a class

earnest phoenix
#

just ctx, url?

slender thistle
#

Yup

earnest phoenix
#
        player = await YTDLSource.from_url(url, loop=client.loop)
        await ctx.voice_client.play(lista[0], after=lambda e: funcion2(ctx))```
#

play is nonetype

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'play'
slender thistle
#

voice_client is None

earnest phoenix
#
@client.command()
async def play(ctx, url):
    """Plays from a url (almost anything youtube_dl supports)"""

    async with ctx.typing():
        player = await YTDLSource.from_url(url, loop=client.loop)
===>    await ctx.voice_client.play(lista[0], after=lambda e: funcion2(ctx))    <===

    await ctx.send('Now playing: {}'.format(player.title))
pine jacinth
#

So I have a problem where I get a Null exception from the top.gg Api

I am using Discord Net and the DBL-dotnet-library.

In my ReadyAsync() I have the following code:

AuthDiscordBotListApi AuthDBApi = new AuthDiscordBotListApi(_client.CurrentUser.Id, Environment.GetEnvironmentVariable("DBO_TOKEN"));

_ = Task.Run(async () => {
  IDblSelfBot DB_Bot = await AuthDBApi.GetMeAsync();
  await DB_Bot.UpdateStatsAsync(_client.Guilds.Count);
  await Task.Delay(1000 * 60 * 10);
            });

But the 4th line (IDblSelfBot DB_Bot = ...) returns a NullReference Exception.
Does anyone know what I am doing wrong?

earnest phoenix
#

i want to find the options.webhookAuth the docs said The string for Authorization you set on the site for verification. but I can't find that string

quartz kindle
#

go to your top.gg bot edit page

#

under webhooks

#

you have URL and Authorization

earnest phoenix
#

How do you get the channel ID and save it that differs from server to server?

#

how i get the hours? 11v

#

It's for a welcome com

#

I'd really appreciate the help rn

heavy anchor
#

I need to get data from this json but can't figure out the right path

[{
    "type": "qrcode",
    "symbol": [{
        "seq": 0,
        "data": "Hello Test!!!",
        "error": null
    }]
}]

I am trying: js await fetch(QR_URL) .then(response => response.json()) .then(json => { console.log(json.symbol.data) }
and that is giving me error Cannot read property 'data' of undefined

earnest phoenix
#

why array?

heavy anchor
#

It's from an API I can't change it

white anvil
#

response.json() returns a promise

#

u should probably use await separately here instead of chaining .then

midnight blaze
#

Is there a simple command to make the bot delete new messages in a certain channel?

#

I want to create a channel, where people can write commands, they will deleted after they write them

#

something like that?

quartz kindle
#

@heavy anchor its an array, access it as such: json[0].symbol.data

heavy anchor
#

Thank you Tim I will read up on it

midnight blaze
#

So, I tried to make it like that, but I get an error message.

    if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'opti
ons', 'object', true);
                                     ^

TypeError [INVALID_TYPE]: Supplied options is not an object.

The code was this:
if(message.channel.id =="id")
{message.delete(1000);}

amber fractal
#

delete takes an object in v12

midnight blaze
#

aha

#

I see

#

thanks, it works^^

#
message.delete({ timeout: 1, reason: 'It had to be done.' });
white gyro
#

Why even provide the timeout if it's 1ms

digital ibex
#

hi

#

i'm trying to overwrite the permissions for every channeljs message.channel.guild.channels.forEach(async(channel) => {await channel.editPermission(message.member.id, {allow: 0, deny: 2048 })})
why can i still speak?

#

and other users can

#

when they use that code, with eris

white gyro
#

Update to v12, v11 won't receive more support

#

Ok, nvm

topaz fjord
#

Should I cast my dictionary to a custom class for simplicity purposes or should I keep it as a dictionary?

#

Im using a config file and when I load it, it gets turned into a dictionary

lyric mountain
#

@sturdy hare are you using js?

sturdy hare
#

yes

lyric mountain
#

Then watch some tutorials on how to setup a webserver with express

#

It's not hard at all

midnight blaze
#

@white gyro how but you chill out?xD It was just randomly a number I have put in to show the function, maybe there are people who also want to know how I solved my problem.

lyric mountain
#

Once you have a working webserver all you need is to pass the url to the bot's page config

sturdy hare
#

ok i will take a look

#

thanks

lyric mountain
#

Btw, check whether you have nginx or apache tomcat installed in your vps

#

If you do have, you'll need to setup a proxy connection

clear wraith
#

What does this mean?

#
(node:116) UnhandledPromiseRejectionWarning: SqliteError: database disk image is malformed```
golden vessel
#

Hlww

#

Anyone help me?

clear wraith
#
const db = require('quick.db')

module.exports.run = async(client, message, args) => {
  let user = message.mentions.users.first() || message.author //This will show us how much money a user has when we mention them
  let money = await db.fetch(`money_${user.id}`) //This will fetch the amount of money we have in our account
  message.channel.send(`${user} has a balance of $${money}`)
}

module.exports.help = {
  name: "balance",
  aliases: ["bal"]
}
golden vessel
#

My Bot Not showing his status in top.gg ??
Solution please

clear wraith
#

ScreenShot?

summer torrent
#

@elfin yarrow

golden vessel
#

Yes

#

Done

#

Done

#

Thanks

#

Now showing thanks

clear wraith
#

Ok

golden vessel
#

😁

split hazel
#

What does this mean?
@clear wraith something in your database goofed up while writing and now you have a corrupt entry which you can only find and get rid by yourself before the database works again

clear wraith
#

Uhhhh

#

oof

split hazel
#

I don't remember how I fixed the issue but you can do it by exporting your database into sql, and importing it to make a new fresh sql file

#

Which will work

clear wraith
#

Ok

#

So just redo the sql file ?

split hazel
#

If the data there doesn't matter too much just delete the database and restart really, but you need to export the database and create a new one with the Sql file

#

You also need to ignore malformed queries

clear wraith
#

Alright, Thanks.

sudden geyser
#

I don't remember how I fixed the issue but you can do it by exporting your database into sql, and importing it to make a new fresh sql file
@split hazel I've had this before, how would you do this?

split hazel
#

I did it with the standard sqlite3 driver

#

It comes with many utilities

sudden geyser
#

ty

pale vessel
grizzled raven
#

it is on topic

pale vessel
#

it's deleted

#

it was lastedguide saying "xd "

patent birch
#

Hi

#

Add bot command ?

#

Pleae

earnest phoenix
#

no

pale vessel
#

please speak english

patent birch
#

Translate to turkish

pale vessel
midnight blaze
#

@patent birch translate to English

summer torrent
#

@gleaming glen

patent birch
#

No

midnight blaze
#

No u

summer torrent
#

@patent birch I took a screenshot

patent birch
#

Np

reef heath
#

What is the code for setting a bot's status? I want it to say "Playing a.help" as if it's playing a game, but I can't get it to work. here's what I have:

setInterval(function() {
        bot.user.setActivity("a.help", {type: "ONLINE"});
})```
patent birch
#

@summer torrent Add bot helping?

summer torrent
#

"type" must be a "WATCHING", "LISTENING" etc. @reef heath

reef heath
#

so like... put "PLAYING" then?

summer torrent
#

no

reef heath
#

oh. will it affect how it shows up visually if I choose different options?

#

I mean like is there a difference between watching and listening?

patent birch
#

@summer torrent Add bot helping?
@patent birch

#

Help please

#

Bot Add list

summer torrent
patent birch
#

Thx

summer torrent
#

I mean like is there a difference between watching and listening?
@reef heath watching

reef heath
#

Okay then

#

It comes back with "TypeError: Cannot read property 'setActivity' of null"

summer torrent
#

bot.user is null

#

what is bot

reef heath
#

the client

#
const bot = new Discord.Client();```
#

^^^

summer torrent
#

🤔

reef heath
#

i use "bot" instead of "client"

#

it works

summer torrent
#

where is this code? ready event?

#

oh ok

reef heath
#

do you want all of the code?

summer torrent
#

if it works for you, no

reef heath
#

No, i mean using "bot" instead of "client" works.

#

the status is still not working

summer torrent
#

where is this code? ready event?

reef heath
#

"ready event"
?

#

i don't know what you mean

compact shoal
#

The ready event is when the bot is ready.

reef heath
#

Oh

#

hang on

compact shoal
#

Hes asking where is this code in?

summer torrent
#

bot.on("ready"...

compact shoal
#

or in a event handler

reef heath
#
//creates bot as client
const bot = new Discord.Client();

//token acts as access password
const token = 'NOPE';

//set bot prefix
const PREFIX = 'a.';

//terminal sends message when bot is online
bot.on('ready', () =>{
    console.log('bot is online')
})

setInterval(function() {
        bot.user.setActivity("a.help", {type: "WATCHING"});
})
high bough
#

What did I miss? The name didn't get updated.

setInterval(async () => {
  const guildw = await client.guilds.cache.get('709197832006926380')
  const channelu = await client.channels.cache.get('709575417857572984');
  const channelb = await client.channels.cache.get('709575836302442546');
  const channelg = await client.channels.cache.get('709576263265681481');
  channelu.setName(`💮 User Count: ${guildw.members.cache.filter(m => m.user.bot === false).size}`).catch(err => console.log(err));
  channelb.setName(`💮 Bot Count: ${guildw.members.cache.filter(m => m.user.bot === true).size}`).catch(err => console.log(err));
  if (guildw.members.cache.filter(m => m.user.bot === false).size >= 1000) channelg.setName('💮 Next Goal: 2000').catch(err => console.log(err));
}, 1000);
reef heath
#

i'm using Visual Studio

compact shoal
#

well thats every second, just saying thats against TOS

#

you might wanna add another 0 to that.

high bough
#

ouch k

compact shoal
#

but other than that i dont really know.

high bough
#

K thanks anyway

summer torrent
#

@reef heath put the code in "ready" event

reef heath
#

okay

#

so replace java setInterval(function() {

#

?

#

with java bot.on('ready', () =>{

compact shoal
#

No,

#

Put the code in the ready event

#
bot.on('ready', () =>{
    console.log('bot is online')
setInterval(function() {
        bot.user.setActivity("a.help", {type: "WATCHING"});
})
});```
reef heath
#

OH

#

i'll try that!

#

you're the best @compact shoal thank you sm!

#

that worked

compact shoal
#

dont thank me thank NMW03, i just explained it better for you >_>

summer torrent
#

👀 👀

reef heath
#

<333 nmw

summer torrent
#

np

patent birch
#

@summer torrent

summer torrent
patent birch
#

Okey sorry my bad

wide ridge
#

is there any downside to having your bot react with 4 different reactions every 7 seconds for thousands of users? Is there a bottleneck somewhere with this situation? Unfortunately I don't think discord.js lets your bot perform 4 different reactions with just 1 request to the api...?

compact shoal
#

Well i wouldn't know, but my guess is cpu usage 😔

digital ibex
#

hi, uh any ideas why await m.findOne({ id: client.user.id }); would be null? m is require('../../models/Bot');

fallow quiver
#

I'm using Discord.js, message.guild.members.cache.get(id).avatarURL() tells me that it is not a function, but client.user.avatarURL() is and works, what is the issue?

#

Also what are you trying to do @digital ibex

sudden geyser
#

@fallow quiver the difference is you're calling avatarURL on the GuildMember instance, while you called it on the ClientUser (extension of User) for the client user instead. Try using the method on the user (<GuildMember>.user)

fallow quiver
#

I figured it must've been some simple oversight like that

ember atlas
#
   search = search.toLowerCase(); 

        if(!(msg.channel.type === 0 || msg.channel.type === 5)){ return;}
        if(!members){
            members = msg.channel.guild.members;
        } 
        
        let member = members.find(user => (`${user.username}#${user.discriminator}` === search) || (user.id === search) ||
            (user.username === search) || (msg.mentions[0] && user.id === msg.mentions[0].id) || (user.nick != undefined && user.nick === search));
    
        if (member == undefined) member = members.find(user => (user.username.toLowerCase() + "#" + user.discriminator === search.toLowerCase()) ||
            (user.username.toLowerCase() === search.toLowerCase()) || (user.nick != undefined && user.nick.toLowerCase() === search.toLowerCase()));
    
        if (member == undefined) member = members.find(user => (user.username.toLowerCase().includes(search.toLowerCase())) ||
            (user.nick != undefined && user.nick.toLowerCase().includes(search.toLowerCase())));

       
        return member;
    }
``` I am using this user resolver, and when I run the avatar command (a command i made using this), it doesnt find the author's avatar, it pulls from a random server member
#

Any idea why? Im using eris

pale vessel
#

can you send me the whole function?

#

you can try console.log(member) before return member to see what it got

#

@ember atlas

ember atlas
#
module.exports = {
    resolveUser: function(msg, members, search = '') { 
        search = search.toLowerCase(); 

        if(!(msg.channel.type === 0 || msg.channel.type === 5)){ return;}
        if(!members){
            members = msg.channel.guild.members;
        } 
        
        let member = members.find(user => (`${user.username}#${user.discriminator}` === search) || (user.id === search) ||
            (user.username === search) || (msg.mentions[0] && user.id === msg.mentions[0].id) || (user.nick != undefined && user.nick === search));
    
        if (member == undefined) member = members.find(user => (user.username.toLowerCase() + "#" + user.discriminator === search.toLowerCase()) ||
            (user.username.toLowerCase() === search.toLowerCase()) || (user.nick != undefined && user.nick.toLowerCase() === search.toLowerCase()));
    
        if (member == undefined) member = members.find(user => (user.username.toLowerCase().includes(search.toLowerCase())) ||
            (user.nick != undefined && user.nick.toLowerCase().includes(search.toLowerCase())));

       
        return member;
    }
    
    }
#

this is just my function

#

do you want me to still console.log it?

pale vessel
#

yeah sure

#

and does the avatar command need user input? (or would it resolve to message author by default?)

ember atlas
#

it should resolve the message author if no args

#

theres the console.log

pale vessel
#

oh that one got dyno haha

ember atlas
#

ya lulw

pale vessel
#

you can make your function a lot shorter and cleaner by omitting some brackets and combining stuff into one variable (member)

white gyro
#

You should be able to easily get the member object from the person who authored the message, instead of having to search every member in the server.

sudden geyser
#

Boss are you using ERis?

pale vessel
#

Any idea why? Im using eris

sudden geyser
#

Ah sorry

pale vessel
#

send the avatar command

sudden geyser
#

Also the search is being converted to lower case but the user's username is not.

pale vessel
#

it's intentional

#

wait a minute

sudden geyser
#

really horithinkingsmirk

pale vessel
#

you're right

ember atlas
sudden geyser
#

So first you look with the name not being lower cased then you check again for if the user's username is lower cased (which is kind of slower with little benefit except for cases).

ember atlas
#

ya idk why it pulls a random member

#

did i forget to add where it pulls the author?

sudden geyser
#

Can you show the avatar command?

pale vessel
#

are you sure you provided the correct arguments

ember atlas
#
 async execute(callisto, msg, args) {
        const member = resolveUser(msg, args.join(' ')); 

        if(!member) { 
        return callisto.createMessage(msg.channel.id, `${error}Invalid user!`)
        }
        callisto.createMessage(msg.channel.id, { 
            embed: { 
                author: { 
                    name: `${member.username}#${member.discriminator}`, 
                    icon_url: `${member.avatarURL}`
                }, 
                color: `${defaultColor}`, 
                image: { 
                    url: member.avatarURL
                }, 
                timestamp: new Date 
                
            }
        })
    }
}
module.exports.cmd = Avatar;
sudden geyser
#

The second argument should be the guild members collection

#

The third argument should be the search.

pale vessel
#

so msg, null, args.join(" ")

sudden geyser
#

I think it pulls a random member due to "some person's username".includes("") will pretty much return anyone

ember atlas
#

oh

pale vessel
#

by the way, it's not really resolveUser because it returns a member

#

you might want to make it return member.user

rose warren
#

Hi, I'm just wondering if it's possible to make a bot with ES9 or if it is only applicable to Javascript.

white gyro
#

You need it to return msg.member if no args were passed (empty search).

smoky spire
#

Well you can make a bot using javascript 🤔 @rose warren

reef heath
#

I'm trying to get my bot to host on heroku/github 24/7 so that it stays on. i got to the very last step but my worker dyno will not show up, and idk what the problem is. please help

#

if you have used this before or use it now, please help

#

the code in my procfile reads:

Worker: node index.js```
#

index.js IS the name of the file that stores my code

white gyro
#

It's worker not Worker

reef heath
#

that's really the issue?

pale vessel
#

and it's Procfile

reef heath
#

OKOK sorry haha

white gyro
#

Of course it can be, things are case sensitive

reef heath
#

right

#

lets see

#

did not work

pale vessel
#

try refreshing

reef heath
#

refreshing what? heroku? i did

pale vessel
#

refresh the resources page

reef heath
#

i did

#

that's where i'm at

pale vessel
#

then you suck

reef heath
#

...dang-

pale vessel
#

can you show the directory tree?

#

or basically the files

reef heath
#

like... take a screenshot?

pale vessel
#

ye

white gyro
#

Try deploying your github repo again, otherwise it's probably because it can't find the procfile.

pale vessel
#

i'm sure they turned on automatic deployment

reef heath
wide ridge
#

Hey tenpi, just going off of what you said earlier. How come big bots hit the api limit very frequently if they’re sharding?

#

Too many people flooding in one channel?

reef heath
#

@white gyro You mean like disconnect from github?

#

disconnect the app?

pale vessel
#

no

#

click deploy branch

white gyro
#

No, there's always an option to "deploy" the code again

reef heath
#

i deployed again

#

all the checkmarks

#

but still no worker in resources

pale vessel
#

are you sure you pushed your changes

reef heath
#

yes

pale vessel
#

try clicking on the build log

#

and send a screenshot

reef heath
#

in the github desktop app under history?

pale vessel
#

no, in heroku

#

should be on overview or something

reef heath
#

in "actvity"

pale vessel
#

exists on both actually

reef heath
#

there's a log

pale vessel
#

view build log

reef heath
#

latest one?

pale vessel
#

yeah

white gyro
#

There might be run time errors in your app

reef heath
#

"mis-cased procfile"

#

?

pale vessel
#

something is wrong with your procfile

reef heath
#

it's capital

#

Procfile

pale vessel
#

send the content

#

just in case

reef heath
white gyro
#

On your github repo it's still "procfile"

pale vessel
#

you said you pushed the changes already

#

wow

white gyro
#

Git ignores filename case changes by default

reef heath
#

Oh

pale vessel
#

but he changed Worker to worker

reef heath
#

Then what do I do

#

no we mean procfile to Procfile

pale vessel
#

i know

#

but github should detect that change

reef heath
#

oh ik what u mean

pale vessel
#

along with the filename

#

so both should be saved

#

can you send me the repo

reef heath
#

yeah git doesn't detect a change

pale vessel
#

just add a newline and push

reef heath
#

okay

#

wait how do i push

white gyro
#

use git config core.ignorecase false

pale vessel
#

are you serious

white gyro
#

Or delete and remake the file

reef heath
#

git push

#

right?

#

i'll delet and remake

#

uh okay i fixed Procfile but

#

oh wait hang on

#

YES WOOHOO

#

THANK YOU BOTH MWAH MWAH

white gyro
#

np

fallow quiver
#

I am using FS with Javascript to write to a file, upon restart however the file seems to revert, I am calling the fs.writeFile() in an imported file, is there a way in said imported file to force it to save the file?

pale patio
#

Y'all considering a saved playlist feature?

smoky spire
#

Who is y'all

pale patio
#

I know I can add a bot to keep from disconnect but a command or feature to save would be nice

#

Devs @smoky spire

#

Command being no disconnect would be nice

smoky spire
#

Devs of what

pale patio
#

Ah fux .. Thought I was in Rythm lmao .. Please delete my messages

fallow quiver
#

Essentially all I want to do, is at the end make sure that the changes are saved to the next reboot

white gyro
#

You'll probably need to save it in a database so that it persists when the bot restarts

fallow quiver
#

Changes I make in the main file persist, but any changes in the imported command file disappear after the reboot

#

It's weird and I don't really get it

earnest phoenix
#

yes

#

because it's all in memory

#

you shut the process down

#

memory goes bye

#

use a database

tight plinth
#

how can I run lavalink with pm2

#

or smth like that

mossy vine
#

how do you start lavalink

#

without pm2

tight plinth
#

java -jar Lavalink.jar

mossy vine
#

try pm2 start java -- -jar Lavalink.jar

tight plinth
#

I didnt get the --

#

but it seems to work

mossy vine
#

-- means that whatever is coming afterwards, you pass to the process instead of treating them as pm2 arguments

#

so what this really means is

#

hey pm2, please start java and give it the args -jar Lavalink.jar

twilit rapids
#

Create a pm2 config file

mossy vine
#

or that

#

but a long ass command looks cooler

twilit rapids
tight plinth
#

i needed to install java

#

but it worked

#

thx!

twilit rapids
tight plinth
#

how to obtain shard count using eris-sharder

#

nvm,I guess I have to put it manually

pale vessel
#

why are you using eris-sharder? are you clustering?

tight plinth
#

yes

pale vessel
#

how much

tight plinth
#

I use it so in the future I'll not have to worry about shards being dicks

#

nvm, it wont connect

#

password is good, host is set as "localhost"

#

even in the application.yml

twilit rapids
#

Are you sure it's running then

tight plinth
#

yes it is

twilit rapids
#

pm2 logs <whatever you named the app> --lines 100

tight plinth
tight plinth
#

im definitively blind

twilit rapids
#

👏

tight plinth
#

eris later

twilit rapids
#

What version of djs do you use

tight plinth
#

12

twilit rapids
#

I would recommend shoukaku

tight plinth
#

ok

#

seems complicated

#

but worth it

earnest phoenix
#

no

#

:((

#

so how i can fix

#

xD

#

oh

#

i know why

#

i do 1 request per 1 min

#

now they blocked

#

how many requests per minute?

#

oh nvm

#

Well yeah you're being ratelimited, time to optimize your code eh

#

yes

#

Some of the servers seem to have been deleted because of shard. xd

tight plinth
#

holy fuck its not ez

#

more difficult than I though

toxic jolt
#

With db.get?

#

how do we do

steep tundra
#

how do i make a command handeler?

honest perch
#

language, library?

steep tundra
#

what

#

for a discord bot

honest perch
#

what library are you using

steep tundra
#

discord.js

earnest phoenix
heavy marsh
#
channel.fetchMessages({ limit: 100 })
``` Is this an invaild option in v12
pale vessel
heavy marsh
#

OOh thank you that helps alot 🙂

pale vessel
#

slice

quartz kindle
#

catching errors on .send() should catch that too

uneven lichen
quartz kindle
#

are you using ytdl-core-discord?

uneven lichen
#

im using ytdl-core

quartz kindle
#

afaik that was fixed in the last ytdl-core update

uneven lichen
#

ok

tranquil wedge
#

im waiting 2 days

#

send to web veryfi support 🙂

earnest phoenix
#

no

slender thistle
#

-faq 2 @tranquil wedge

gilded plankBOT
earnest phoenix
#
let date = Date.prototype.getDate() + Date.prototype.getMonth() + Date.prototype.getFullYear()

(node:1092) UnhandledPromiseRejectionWarning: TypeError: this is not a Date object.
Why am I getting this error?

knotty steeple
#

please dont do that

earnest phoenix
#

?

#

Why not?

knotty steeple
#

what do u want

earnest phoenix
#

full year full day full month

zenith terrace
#

is this for server info or something

earnest phoenix
#

no

#

to get current date

zenith terrace
#

ah

knotty steeple
#

u cant just add it like that

earnest phoenix
#

so how can I

knotty steeple
#

so

#

template literal..?

earnest phoenix
#

wdym

template literal..?
@knotty steeple

#

Not a native English speaker

knotty steeple
earnest phoenix
#

I just asked what you meant by "template literal"

#

lmao

zenith terrace
#

U got to use the new Date(); so

var Date = new Date();```
earnest phoenix
#

I tried but it didnt work for some reason

#

Let me try again

zenith terrace
#

I dont think that prototype is part of the date

knotty steeple
#

also that

earnest phoenix
#
if(command === "date") {
    let date = Date.getDate() + Date.getMonth() + Date.getFullYear()
    message.channel.send(date)
  }```
Currently have this code
#

(node:2770) UnhandledPromiseRejectionWarning: TypeError: Date.getDate is not a function

knotty steeple
#

cuz it isnt

earnest phoenix
#

how do you make a bot that send a message every 3 message by a user?

#

I used a google answer lmao
I tried to find something but that's the first thing I found

knotty steeple
#

maybe look at the docs

earnest phoenix
#

Will do

#

Thanks

knotty steeple
#

u have to use the constructor first

earnest phoenix
#

Did it

#
message.channel.send(d.toLocaleDateString());```
#

Ty

knotty steeple
#

cool i just woke up so im being stupid

earnest phoenix
#

Didn't use it in a long time lmao

#

All good, you helped

#

❤️

zenith terrace
#

@earnest phoenix u want a bot that sends a messages every 3 user messages?

earnest phoenix
#

yes

knotty steeple
#

but why

#

is the question

earnest phoenix
#

I am trying to recreate tembot from LilyPichu discord server

knotty steeple
#

are u sure thats what it does

#

speaking of which i was gonna join

earnest phoenix
#

I think it’s twitch sub only

knotty steeple
#

fucking

earnest phoenix
#
    request(options, function(err, result) {
        if(err) console.log(err);
        let xp = JSON.parse(result.body);
        console.log(xp); 
        return;
    })
#

ahm how i can stop request

#

cuz it keep console.log

#

return is not working

mossy vine
#

stop calling it

earnest phoenix
#
const attachment = new Discord.Attachment(canvas.toBuffer(), 'picture.png');```
#

oh wait

#

why is this not working in v12?

#

oof i am dumb

#

(node:6397) UnhandledPromiseRejectionWarning: TypeError: Discord.Attachment is not a constructor

#

i couldnt find it in the guide of v11 => v12

mossy vine
#

Attachment no longer exists

#

its MessageAttachment now

earnest phoenix
#

so what do i use ?

#

oh

#

ok thanks

mossy vine
grizzled raven
#

is it not allowed to have a server leaderboard

#

say like total xp earned on the server idk

knotty steeple
#

actually why wouldnt it be

reef heath
#

Hello. I have my bot set up to run on heroku 24/7 but it keeps going offline every couple minutes anyways. what do i do?

zenith terrace
#

¯_(ツ)_/¯

reef heath
#

"Hoes Mad" Indeed.

#

Someone please still help me if you can^^^

grizzled raven
#

@knotty steeple why would it be allowed or why wouldnt it be allowed?

knotty steeple
#

why wouldnt it be allowed

#

go ahead and do it cuz lots of bots have server leaderboards

grizzled raven
#

are there some examples?

slender mountain
#

Tatsu

#

Theres no reason why it wouldnt be allowed

white anvil
#

@reef heath heroku automatically closes the websocket connection if there’s no activity

#

don’t host using heroku

#

you’re wasting your time

modest maple
#

pretty much

grizzled raven
#

idk because having a list of servers your bot is in isnt allowed

reef heath
#

Then what do I host with?

modest maple
#

dont want it offline? use an actual paid host

grizzled raven
#

a vps

white anvil
#

a paid vps

#

you can’t expect reliable free hosting, it doesn’t exist

reef heath
#

There's no code that could keep renewing the connection to Heroku?

white anvil
#

there is, but don’t use heroku

vivid crescent
#

All your data will be erased on shutdown

#

and there is an uptime cap

white anvil
#

they force you to pay stupid sums of money if you use them for too long, the environments are very heavily containerised would running other services is near impossible, and the stability is awful

reef heath
#

I'm just saying like.. I'm a kid. I don't have any source of income or a card to even pay for a paid host

white anvil
#

¯_(ツ)_/¯

vivid crescent
#

DigitalOcean minimum is $5/month

white anvil
#

you can get cheap vps for $3/mo

quartz kindle
#

glitch is good enough for a very basic bot

reef heath
#

This is aggravating.

#

glitch can host for free?

vivid crescent
#

It also goes down

#

when inactive

quartz kindle
#

its the same as heroku, but more people use it, and its also easier to use

vivid crescent
#

Can I plug my digitalocean referral code smugMLG

knotty steeple
#

tell ur mom get a credit card and use savings

#

lmao

vivid crescent
#

a referral can get you 3 months to use $100 of credit on DigitalOcean

reef heath
#

huh

knotty steeple
#

i could pay for a $10 host if i save money from school

zenith terrace
#

if u use glitch then u can use uptimerobot to keep it alive for free

reef heath
#

THAT^

#

please explain more

zenith terrace
#

nothing really else to explain, use glitch to make the bot then use uptimerobot to keep it up :/

reef heath
#

what is uptimerobot

zenith terrace
quartz kindle
#

glitch is meant for the web, websites and webservices, so it automatically sleeps when not in use, then it wakes up when it received a connection/request

#

discord bots use websockets, which is a kind of connection that glitch doesnt count as a request

#

so you simply need to periodically make a web request to your glitch project while your bot is running

#

to keep it alive

vivid crescent
#

Using an actual VPS would still be a lot better though

zenith terrace
#

we all know a VPS is better but not everyone can afford one

#

even if it is cheap

earnest phoenix
#

hello, i need help, im tryting to do a command that read a file where i put

  Premium: ["486460106792239104", "648133423722135563"]
}```
But when i put in the command
const premiums = data.config.premiums
if(premiums === message.author.id) {
messahe.channel.send(prob);
}
#

im tryting to doto this
{
Premium: ["486460106792239104", "648133423722135563"]
}
only work with 1 id

#

and i want 2 or 3 or more ids

#

but idk how

knotty steeple
#

premiums["id"]

earnest phoenix
#

but i want more ids

rigid raven
#

Hi there! Is no way to read group messages from other bot? On Discord.Net

knotty steeple
#

u can just check if premium[id] exists

#

id being the user id

#

tho idk does this work with arrays

indigo cloud
#

i need help with something

quartz kindle
indigo cloud
knotty steeple
#

yes thanks tim

#

im 0iq

earnest phoenix
#

ok

#

thanks

knotty steeple
#

@indigo cloud what are u running

indigo cloud
#

visual studio code

quartz kindle
#

?

#

he means what did you type in the terminal

indigo cloud
#

a discord bot\

#

oooh

#

this is the code i have set for now

#

i am not really good at coding tho tried to follow a yt video

quartz kindle
#

you didnt save the file

#

also, how did you run it? (what did you type in the terminal)

indigo cloud
#

console

knotty steeple
#

thats what im asking

#

what did u type

indigo cloud
#

uuh how do i save it lmao

quartz kindle
#

ctrl+S

#

or file > save

indigo cloud
#

nvm thanks

knotty steeple
#

yikes

indigo cloud
#

thanks

#

it worked

quartz kindle
#

👍

rigid raven
#

Hi there! Is no way to read group messages from other bot? On Discord.Net
@rigid raven noone? :(

knotty steeple
#

also learn js from a site instead of a video saying how to make a bot specifically

quartz kindle
#

@rigid raven you mean group DMs?

knotty steeple
#

not much people use d.net so u have to wait

indigo cloud
#

alright

quartz kindle
#

bots cant access group DMs

earnest phoenix
#

hi

#

ı need nsfw bot codes

indigo cloud
#

wait u know codelyon?

knotty steeple
#

lmfao

#

sololearn

#

codecadamy

indigo cloud
#

i am following his tutorial

knotty steeple
#

@earnest phoenix horny much

rigid raven
#

I > bots cant access group DMs
@quartz kindle I mean read a bot on the same server chat, like users do

knotty steeple
#

read the docs

quartz kindle
#

im not understanding what you mean

still merlin
#

CodeLyon is good

mossy vine
#

messages from bots come through just like regular messages

still merlin
#

but his code is outdated

cinder dove
#

Did anyone ever had this problem on ytdl core?

ERR_INVALID_ARG_TYPE

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

It happens randomly, and I try&catch everything but I still get this error. It does not happen on the same video and it is a rare event.

earnest phoenix
#

@knotty steeple need xd

knotty steeple
#

for urself or for others?

#

go on ph lmao

quartz kindle
#

@cinder dove you tried giving it an undefined string

knotty steeple
#

use some api

earnest phoenix
knotty steeple
#

thay provides with it

quartz kindle
#

just check if the url is defined before giving it to ytdl

earnest phoenix
#
    premiums: ["486460106792239104", "648133423722135563"]
}```
#

and i try it removing prmeiums: []

knotty steeple
#

put it in a string

earnest phoenix
#

and only put "" wit the ids

cinder dove
#

The problem is it happens like once in 100 times. Very rarely and random

knotty steeple
#

or double quotes

earnest phoenix
#

and nothin

cinder dove
#

I can't troubleshoot it ;/

knotty steeple
#

put premiums in dougle quotes

quartz kindle
#

@earnest phoenix json files require quotes on keys too

earnest phoenix
#

quotes?

#

im spanish

quartz kindle
#

" <- quote

knotty steeple
#

""

earnest phoenix
#

ok

rigid raven
#

im not understanding what you mean
@quartz kindle haha sorry, my english sucks, I mean:
I have two bots on a server. And one of them says something. Can I read this message from the other bot?

quartz kindle
#

@cinder dove show your code, where you put ytdl(url)

knotty steeple
#

messages from bots act like normal messages from users

quartz kindle
#

@rigid raven its a normal message

#

should come through your message event

rigid raven
#

Humm i'll check again

#

Thanks :)

earnest phoenix
cinder dove
#

Yup sec.

quartz kindle
#

@earnest phoenix show code

knotty steeple
#

what is premiums defined as

earnest phoenix
#
        if(premiums.includes(message.author.id)) {
            return message.channel.send(`prob`)
        }```
quartz kindle
#

premiums.premiums

knotty steeple
#

ur not getting the premiums key

#

ye

earnest phoenix
#

ok

knotty steeple
#

or add .premiums where u require

earnest phoenix
#

ok

#

ok, now work, thanks

#

discord.py bot. i have a clear command, but when there is lets just say 5 messages and i say clear 100 messages it returns cleared 100 messages. is there anyway i can clear 100 messages but it only says the amount of messages that have been actually cleared like mee6?

#

and ALSO how do i make my bot delete its own messages after about 5 seconds

#

no one?

#

count the amount of items you have when you get the messages to delete

#

that will be your number of actually deleted messages

cinder dove
#
const song = null;
const songInfo = null;

The ytdl.getInfo function:

try {
songInfo = await ytdl.getInfo(url);
song = {
title: songInfo.title,
url: songInfo.video_url,
duration: songInfo.length_seconds
};
} catch (error) {

// then I either return copyright protection message, either use the search, I will skip the copyright handler:
const results = await youtube.searchVideos(search, 1);
songInfo = await ytdl.getInfo(results[0].url);
// then I define song like I do to an URL

//The other YTDL function I use on the second file on the play function is:
var stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });

The error i've mentioned earlier can happen while shifting the queue (after a song ends - it starts another) or when you use play. I use try and catch for all of those mentioned above, and also using if url === undefined returns, but still getting the error..

The bad thing is that It doesn't lead me to where the error is and since it is happening so rarely, I didn't know for about 2 weeks this error is in my code.
I've searched it up online but seems useless. @quartz kindle

earnest phoenix
#

@earnest phoenix yea ik

#

but how do i make it return that

#

in ctx.send

#

i have it set to {amount}

#

so it sends the amount that I said

#

but not that has actually been cleared

#

count the amount of items history().flatten() returned

#

😐

#

that is python fundamentals

#

i have 0 experience in python and i know how to do it, or well learned with a 5 second google search

#

i searched

#

alot

#

and couldn't find shit

quartz kindle
#

@cinder dove the error can happen in any of the youtube/ytdl functions, there is nothing saying from which it is, so you can just check them all:
if(!search) return
if(!results[0] || !results[0].url) return
if(!song || !song.url) return
each before the line that uses it

#

you can return an error or a warning if you like

cinder dove
#

I'm pretty sure it may be this one var stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });
However I really don't understand where I went wrong in this code 🤔 .
Thanks for the suggestion. I will someday need to fix this to encounter bad reviews.

#

song.url should be defined from the getinfo earlier, however it just gives me this error once in a while.

quartz kindle
#

getInfo might not have found anything

#

you always have to account for the possibility that whatever function you use finds no results or an invalid result for some reason

earnest phoenix
#

if(message.guild.channels.cache.find(m => m.name === `ticket-${message.author.username}`)) { return message.channel.send(`❌ Vous avez déjà un ticket ouvert.`) }
why this doesn’t work?

#

you tell us

#

also

#

use a database for tracking tickets

cinder dove
#

The issue is - it says ''starting playing X (video title) + (link)"

#

then it joins and gives me this error. (at a random time, not always)

earnest phoenix
#

as your user can change their username and discriminator anytime they want

#

uh yes thx

knotty steeple
#

or user id

earnest phoenix
#

still inconvenient since someone can change the channel name

quartz kindle
#

@cinder dove if you think it has the proper results, then check if you're not using global variables in a way that multiple commands start overriding each other

knotty steeple
#

true

#

store the channel id

hardy vector
#

so im trying to make a lavalink musc bot and i followed along with the menudocs video this is my code(https://hastebin.com/wopuxacuxe.js) but whenever im in a vc and i try to say -play <song name> it says you need to be in a voice channel any idea why?

sudden geyser
#

What version of Discord.js are you using.

hardy vector
#

v12

#

and i have the correct build of lavalink for mac

#

i already set that up

cinder dove
#

Pretty sure it's guild (map based), however it could be part of the issue. Will take this into further tests.

sudden geyser
#

You're using a bunch of properties/methods from v11 that are no longer present/have changed in v12.

earnest phoenix
#

that's the reason why you don't follow youtube "tutorials"

#

follow official docs and samples and build your code from there

hardy vector
#

oh

#

what are they

#

could ya tell me

earnest phoenix
#

i don't know which library you're using for interacting with LL

hardy vector
#

discord.js

#

oh erela.js

cinder dove
#

https://prnt.sc/sg1la8

Here we go.
used:

if(!song || !song.url) return
console.log(song.url) // This got logged
var stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });

First time i got the string error. Second time it worked (same thing was logged in the console). @quartz kindle

Lightshot

Captured with Lightshot

earnest phoenix
sudden geyser
earnest phoenix
#

alr i got the deleted thing

#

, delete_after = 5

#

thats all it was

#

await ctx.send ('Message', delete_after = 5)

hardy vector
#

(node:5124) UnhandledPromiseRejectionWarning: TypeError: voice.permissionsFor is not a function
wha
menudocs lied to me
was that even a v11 function
cos im searching rn and its not
i cant find

earnest phoenix
#

what keyboard are you ok

#

when someone is missing permissions to execute a command as if i type command '+nuke' it will trigger but if someone sends '+nuke' it says absolutely nothing. how do i make it say sorry you are missing permissions or wtv

#

?

slender thistle
#

If you are using the commands extension, you can use built-in permission checks

earnest phoenix
#

wdym commands

hardy vector
#

oh

#

ok

earnest phoenix
#

@client.command

#

is what i use

hardy vector
#
const permissions = voice.permissionsFor(client.user);``` this is wrong?
earnest phoenix
#

you're getting an error for the voice variable, not the permissions one

hardy vector
#

this is full error js (node:5124) UnhandledPromiseRejectionWarning: TypeError: voice.permissionsFor is not a function at Object.execute (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/commands/play.js:10:35) at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/bot.js:51:31) at Client.emit (events.js:311:20) at MessageCreateAction.handle (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31) at WebSocketShard.onPacket (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22) at WebSocketShard.onMessage (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10) at WebSocket.onMessage (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/ws/lib/event-target.js:125:16) at WebSocket.emit (events.js:311:20) (node:5124) 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:5124) [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.

#

play.js line 10 is this

#

const permissions = voice.permissionsFor(client.user);

earnest phoenix
#

yeah... but i already told you what's your issue

grizzled raven
#

any tips on preventing memory leaks

#

or are these even memory leaks

earnest phoenix
#

memory leak this di-

#

jk

#

idek wat memory leaks r

zenith terrace
#
voice.permissionsFor is not a function```
#

I think I found ur error

earnest phoenix
#

L

#

pogey you gotta work for Google @zenith terrace

#

@hardy vector

#

your error has been found

#

in plain sight

#

lol

zenith terrace
#

@earnest phoenix I should pogey

hardy vector
#

ik lol

#

i fixde

earnest phoenix
#

client.channels.cache.find(m => m.name === `ticket-${message.author.username}-${message.author.discriminator}`).send(`<@${message.author.id}>`, embed)
and this why doesn’t work..?

#

Any error?

zenith terrace
#

and this why no error?

earnest phoenix
#

cannot ready proprety send

#

but the channel exists...

#

ah the name it’s good

#

then theres ur error

#

VinxVinxToday at 11:18 AM
cannot ready proprety send

indigo cloud
earnest phoenix
#

@earnest phoenix send the whole log

mossy vine
#

@indigo cloud youre using a very outdated tutorial

earnest phoenix
#

replace sendMessage by send

#

@indigo cloud read your error

indigo cloud
#

alright

mossy vine
#

@earnest phoenix thats not very helpful lol

zenith terrace
#

lol

#

it kinda is

earnest phoenix
#

One Google search would say that you're using an outdated version

#

@earnest phoenix can you send the whole error?

#

ye

#
1|main     |     at Object.exports.run (/pala/commands/new.js:36:112)
1|main     |     at Client.<anonymous> (/pala/main.js:34:29)
1|main     |     at Client.emit (events.js:315:20)
1|main     |     at MessageCreateAction.handle (/pala/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
1|main     |     at Object.module.exports [as MESSAGE_CREATE] (/pala/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
1|main     |     at WebSocketManager.handlePacket (/pala/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
1|main     |     at WebSocketShard.onPacket (/pala/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
1|main     |     at WebSocketShard.onMessage (/pala/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)1|main     |     at WebSocket.onMessage (/pala/node_modules/ws/lib/event-target.js:125:16)
1|main     |     at WebSocket.emit (events.js:315:20)```
#

Can you send the line where the error occurs?

#

new.js at 36:112

#

client.channels.cache.find(m => m.name === `ticket-${message.author.username}-${message.author.discriminator}`).send(`<@${message.author.id}>`, embed)

#

uh no is }

#

sorry, is }

#

but

#

wait

#

you're trying to send a message to the discriminator of the author

#

no, imao is not } xd is client.channels....

#

If I understand correctly

#

no i trying to send a message in the channel name

#

type :

@mention
[there is embed here]
#

spean french @earnest phoenix

#

?

#

speak

#

french

#

francais

#

osti

#

why?

#

ftp

#

pcq

#

a tu peur?

#

i don’t have permission for speak french in this channel

#

moi jparle francais

#

non

#

ta peur

#

no

#

@earnest phoenix

#

No

#

English only

#

non

#

francais

#

i just don’t have permissions

#

compris?

#

stop please

#

lol

#

ok

#

ignore me

sinful belfry
earnest phoenix
#

was spanish

#

not french

#

wth

#

thx ^^

#

Still

sinful belfry
#

either way, all languages which are not english should be kept in #memes-and-media

earnest phoenix
#

racism wow

sinful belfry
#

smh

earnest phoenix
#

Calls that racism lol

#

imao

#

no i trying to send a message in the channel name

#

type :

@mention
[there is embed here]
sinful belfry
#

what lib do you use?

#

discord.js?

earnest phoenix
#

discordjs v12.2

sinful belfry
#

ah cool

earnest phoenix
#

ueah

sinful belfry
#

just do channel.send("<@" + user.id + ">", { embed });

#

you can mention the user with just the user if u want

earnest phoenix
#

client.channels.cache.find(m => m.name === `ticket-${message.author.username}-${message.author.discriminator}`).send(`<@${message.author.id}>`, embed)
and this why doesn’t work..?
@earnest phoenix this is entirely the opposite of what i told you to do

#

ok

#

why cry

#

your user can change their username and discriminator anytime they want

#

messing up your ticketing system

#

uh yeah

proven shuttle
#

ok

earnest phoenix
#

i put the channel id in my database and i get after the channel id?

#

yup

#

and i send the message so?

#

okk

#

correct

#

thx u

proven shuttle
indigo cloud
hasty sparrow
#

OR?

indigo cloud
#

can u send me the symbol

topaz fjord
#

it's just two |

hasty sparrow
#

||

topaz fjord
#

next to each other

indigo cloud
#

thx

sick cloud
#

@mossy vine show how you form the gateway url

#

and what you're logging that returns undefined

earnest phoenix
#

guys help

mossy vine
#

no thats not the problem

#

the problem is jsdoc

#

i had to rewrite my exports as

// define variable x in a cool way

module.exports.x = x```
earnest phoenix
#

Why is music coming off in windows? laggy..

mossy vine
#

and i cant do const { x } = require('./x.js') anymore

sick cloud
#

err ok

mossy vine
#

i have to do const { x } = require('./x.js').x

sick cloud
#

exports.x doesn't work?

earnest phoenix
#

Is there an article that I can fix

mossy vine
#

the problem is jsdoc shits itself if i dont export it like this

sick cloud
#

weird

earnest phoenix
#

hey

sick cloud
#

i export normally and jsdoc is fine with me

earnest phoenix
#

answer me too

sick cloud
#

not sure what's going on cyber

earnest phoenix
#

hello starman

mossy vine
#

nvm its just lowkey broken

#

says shit aint a constructor

#

aaaaa

sick cloud
#

honestly

earnest phoenix
#

Why is music coming off in windows? laggy..
@earnest phoenix

sick cloud
#

jsdoc is weird

#

just ignore it

quartz kindle
#

shit is not a constructor

#

shit is shit

fallow quiver
#

I am trying to limit my bot usage in general, for some reason the bot sends me the DM, but runs the command anyway, is there an oversight that I am making

if(cmd_f) {
        if(cmd_f.help.genlocked == true && config[message.guild.id].genlocked > 0 && message.channel.name.startsWith("general")) {
            message.channel.messages.fetch({ limit: 2 }).then(messages => {
                messages.forEach(m => {
                    m2 = m.createdTimestamp;
                })
                console.log(m2, message.createdTimestamp, m2 + config[message.guild.id].genlocked)
                if(m2 + config[message.guild.id].genlocked > message.createdTimestamp) {
                    message.author.send("This server has been gen-locked, you aren't able to use commands when chat has seen activity");
                    locked = true;
                }
            })
        }
        if(!locked) {cmd_f.run(client, message, args);}
    }
mossy vine
#

thanks for your input tim

quartz kindle
#

yw :^)

mossy vine
#

ok no i figured it out

#

but its ugly

quartz kindle
#

@fallow quiver async functions do not interrupt the code flow if you dont use the await keyword

topaz fjord
#

you could just use export but I have a feeling that it'll bitch at you

quartz kindle
#

the async part is carried on independently, everything outside the async function is independent and continues running normally

sinful belfry
#

@earnest phoenix i would make it so that when the vote webhook is received, it will store the id of the user as well as a timestamp. then i would use a set interval (of maybe 30 minutes) to check if 12 hours has passed since the timestamp for each user in the database and remove the entry for that user if the 12 hours has passed. there are probably better ways to do this though. /shrug

earnest phoenix
#

um

#

anyone have another idea?

fallow quiver
#

@quartz kindle but the async isn't called until after the if statement, right?

quartz kindle
#

yes, but the if(!locked) is executed right after

#

before the async finishes

fallow quiver
#

Oh, ok

#

So I await the call of the run()

quartz kindle
#

no

#

you either await messages.fetch(), or you put the locked logic inside the .fetch() together with everything else

fallow quiver
#

Oh, ok

#

thanks

limber flume
#

i just made error message for about every command 😭

earnest phoenix
#

how i can do this?

@earnest phoenix i would make it so that when the vote webhook is received, it will store the id of the user as well as a timestamp. then i would use a set interval (of maybe 30 minutes) to check if 12 hours has passed since the timestamp for each user in the database and remove the entry for that user if the 12 hours has passed. there are probably better ways to do this though. /shrug

grizzled raven
#

is djsv11's ```js
Error: Client network socket disconnected before secure TLS connection was established

the same as djsv12's
```js
AbortError: The user aborted a request.
sick cloud
#
    const matches = mention.match(/^<@!?(\d+)>$/);
    if (!matches) return null;
    return client.users.cache.get(matches[1]);

there's my meme regex

#

to get a user from a mention

#

but i want to modify the function to return an array of all mentions it finds

queen violet
#

yeah youre only getting the very first match

sick cloud
#

so i'll pass all the args

#

yeah

low wasp
#

You need to have /g at the end

#

/regexhere/g

lyric yacht
#

if (I ask for banana) return banana

sick cloud
#

but if i pass it an entire string

queen violet
#

matches.filter(it => matches.indexOf(it) % 3 == 1).map(it => client.users.cache.get(it))

sick cloud
#

will it return an array of them all

low wasp
#

Yes

sick cloud
#

what the hell is that math in there

#

% 3 == 1

queen violet
#

gets every 2nd argument

low wasp
#

(/regex/g).match(string) returns an array of matches

queen violet
#

<@id> <@id>

sick cloud
#

oh ok

queen violet
#

i think thats right, ill need an array of what the matcher outputs

earnest phoenix
#

im glad javacord has its own function to get mentioned users

sick cloud
#
const matches = content.match(/^<@!?(\d+)>$/g);
if (!matches) return null;
return matches.filter((i) => matches.indexOf(i) % 3 === 1).map((i) => client.users.cache.get(i));

so literally that should work

queen violet
#

im not sure

#

matches needs to have an id every 2nd value

#

but i think its right

sick cloud
#

and then i get an array of users

#

they should be in order right

#

like if i send @thattonybo @user2 @user3 itll return ['thattonybo', 'user1', 'user2']
(obv being full users though)

glad charm
#

Why don't you use message.mentions.members instead of trying to regex it?

queen violet
#

also remove the ^ from the regex

#

thats the beginning of a string

#

@glad charm hes making his own lib iirc

glad charm
#

Oh.

queen violet
#

and the $

#

thats the end of a string

sick cloud
#

yeah good luck finding mentions.members on mine

#

also, they're out of order even on other libs

#

hm

#

that returns a []

onyx hare
#

Quick question I had to make 2 lines for my ggping so it’ll say “my ping is”
“Numbersms”
I can’t figure out how to get it on one line without erroring

nocturne grove
#

Hey, I asked here yesterday how to stop a file from executing if in another file, that gets executed from the first file, an error occurs. Is that possible in a nice way? (I can link to an old message if you want to answer)

low wasp
#

@sick cloud isnt it (/regexhere/g).match(string)

#

Nvm I'm dumb

sick cloud
#

it wont work anyways

earnest phoenix
low wasp
#

@sick cloud ur regex should be /<@(!)?(\d+)>/g

#

^ $ indicate the start/end of the string...

sick cloud
#

i got told to remove it

low wasp
grizzled raven
#

it returns the match if it matches one

low wasp
#

Also you should require the numbers to be the length of mentions to be safe so it doesn't find @zinc aurora

grizzled raven
#

say if there were no matches, it will return null

#

thats what i was gonna say

#

😤

sick cloud
#

it doesn't remove the <@ >

grizzled raven
#

because its what it matched

low wasp
#

Yeah

grizzled raven
#

why learn to starboard when you can use a starboard bot on top.gg wink

#

to get the ids just replace the <@ and >

#

or substring

nocturne grove
#

don't forget the !

grizzled raven
#

¯_(ツ)_/¯

#

or you could

nocturne grove
#

anyone knows what's a nice way to make some utility commands so I can use them multiple times easily? I thought about client.utility as a collection. Are there nicer ways?

sudden geyser
#

Just make a utility class of a lot of static methods.

#

Or are you talking about commands that are utility commands?

nocturne grove
#

no, no commands

#

I have to google class, will see if that's what I mean

grizzled raven
#

its time for another episode of bad code by TheNoob27:

let mentions = []
string.replace(/<@(!)?(1|\d+{16,20})>/g, (s, _, id) => {
  mentions.push(id)
  return s
})
nocturne grove
#

or do you have a quick simple example?

sudden geyser
#

Nah but google does. What language are you using

nocturne grove
#

okay. JS

grizzled raven
#

@low wasp rate my code

#

from a level of stink to not stink

low wasp
#

Why tho...

#

That's wearybread