#development

1 messages · Page 1210 of 1

earnest phoenix
#

discord.js?

quartz kindle
#

so the user object is how discord.js represents a user

#

the object contains properties such as name, avatar, etc, and contain instructions for how to send them a message

#

in order to obtain a user object you can

  1. get it from the user cache if it exists: client.users.cache.get(user id here)
  2. fetch it from discord: await client.users.fetch(user id here)
earnest phoenix
#

i thought this would be easy, but now im 2nd guessing

sudden geyser
#

When you know classes you'll know objects

earnest phoenix
#

the 2nd step i dont understand

#

so is that it?

quartz kindle
#

how do you know which user to want to send the message to?

#

do you have their id?

earnest phoenix
#

yes

quartz kindle
#

so in your code, you need to use let user = await client.users.fetch(id here)

earnest phoenix
#

its like i stole their ID card irl, i feel like a villain

#

so is that making the thing go through for the command?

quartz kindle
#

hmm?

earnest phoenix
#

idk-

#

Do i put these in the same lines, and just add ('message')

#

Do i put these in the same lines, and just add ('message')
CMON

quartz kindle
#

how about you show some code

earnest phoenix
#

Tim, can you help me?

quartz kindle
#

try running enable-pnpm

earnest phoenix
#

Not working

quartz kindle
#

then idk

#

ask in the glitch forums

lethal pine
#

[Union[Role, Member], PermissionOverwrite] please help how to use it

earnest phoenix
#

in order to obtain a user object you can

  1. get it from the user cache if it exists: client.users.cache.get(user id here)
  2. fetch it from discord: await client.users.fetch(user id here)
    I did all of this with user id, what do i do now, and how do i send a message
slender thistle
#

Use type annotations..?

#

Those literally just point at what an argument/variable is supposed to be

#

"Union" is "either"

lethal pine
#

hm

slender thistle
#

Aka Role or Member

lethal pine
#

so should i type role id or role name

slender thistle
#

Not sure why there's a list of that and PermissionOverwrite

#

What are you trying to do?

lethal pine
#

lock and unlock the channel

quartz kindle
#

@earnest phoenix those were either one or the other, not both

slender thistle
#

....

#

A fucking dictionary

quartz kindle
#

eitherway you have to show your code, otherwise i have no idea what you're trying to do

lethal pine
#

yea

slender thistle
#

Eh...

earnest phoenix
#

Ah

slender thistle
#

You can technically go the fuck-all way and create a discord.Object with id=role_id

lethal pine
#

any solution @slender thistle

earnest phoenix
#

eitherway you have to show your code, otherwise i have no idea what you're trying to do
I'm trying to send a message to a user

#

from my bot

quartz kindle
#

then show your code

lethal pine
#

You can technically go the fuck-all way and create a discord.Object with id=role_id
@slender thistle RIP

slender thistle
#

or guild.get_role(role_id)

#

the target argument is a dictionary

lethal pine
#

ohk

slender thistle
#

Where the key is an object with .id property and the value is a PermissionOverwrite object

lethal pine
#

hm

#

thankx for your help man @slender thistle

slender thistle
#

aye np

earnest phoenix
#

Should I censor my friends user ID? I feel like i need to censor it

misty sigil
#

not really

earnest phoenix
quartz kindle
#

ids are strings, not numbers

earnest phoenix
#

thought u ment user ids ;-;

misty sigil
#

why get and fetch

#

user ID is a string?

quartz kindle
#

yes i meant user ids

#

ids are strings

#

not numbers

sweet kestrel
#

who is this dude?

earnest phoenix
#

When i copy a user ID it number

sweet kestrel
#

i thought he is a bot when i first joined this server

#

lol

misty sigil
#

"673273042399415137" is a string (more specifically a snowflake)
673273042399415137 is a number, one too big for JS to handle

earnest phoenix
#

Yeah, thats how i thought about it when he said it

quartz kindle
#

second, when do you want to send the message to this user?

earnest phoenix
#

So i'll add strings?

#

the "

quartz kindle
#

because your code right now makes no sense, you're trying to get a user when the bot didnt even login yet

misty sigil
#

that too

#

you cant do that

earnest phoenix
#

The user i logged in ;-;

misty sigil
#

it needs to be in a message event or a ready event

#

the client isnt logged in when you're fetching

slate oyster
earnest phoenix
#

So? uhh, what do i do

quartz kindle
#

you're trying to do things blindly, without understanding how it works. its gonna be very hard for you if you keep doing it that way

#

i'd suggest you learn some basic javascript

honest perch
#

@quartz kindle yknow lua

earnest phoenix
#

I did

#

console.log() and the other things including console.log, thats it from the place i learned'

honest perch
#

Its literally like python and js had a kid

quartz kindle
#

never used it

honest perch
#

Seriously

#

Wait

earnest phoenix
#

Lua is pretty underrated

acoustic bridge
#

I need some help on that

embed.add_field(name=f'Roles ({len(roles)})', value=" ".join([role.mention for role in roles]))

I want to list the Roles a member has in an embed message, although it looks like this

#

How can i make a filter for the everyone role? so it will only show the other 2 for example

honest perch
#

If statement?

slender thistle
#

Append if role == role.guild.default_role else role.name at the end of the list comp

grim mesa
#

I have 2 shards, the number of servers on the site seems to be missing

#

how to fix it?

honest perch
#

Are you using the api.

grim mesa
#

yes

tidal marlin
#

So basically, my bot bypassed the bot check twice by now and I still don't know how or why. I use - if(message.author.bot) return as bot check, maybe I've done it wrong?

ionic dawn
#

Yayyy
@slate oyster enjoy the +50d queue of verification

charred geyser
#

Can anyone help me with something i am trying to figure out, im writing a discord js bot and i have set up a server join message so whenever it joins a server it will send a helpful embed but im not sure how to determine which channel to send the embed into. Right now it just finds the first channel it has permission to send messages in but i feel like that is not the best way to do it

ionic dawn
slate oyster
#

@ionic dawn Will do

charred geyser
#
client.on("guildCreate", guild => {
    let defaultChannel = "";
    guild.channels.forEach((channel) => {
        if(channel.type == "text" && defaultChannel == "") {
            if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
                defaultChannel = channel;
            }
        }
    })
    defaultChannel.send(BotJoinMessage)
});
#

this is how i am doing it atm

slate oyster
#

@ionic dawn Anyways, those 50d aren't as bad as another thing I'm waiting out

misty sigil
#

So basically, my bot bypassed the bot check twice by now and I still don't know how or why. I use - if(message.author.bot) return as bot check, maybe I've done it wrong?
@tidal marlin no, that is generally the right way to do it.

solemn merlin
#

Hey, this is all the keys that the TEST webhoost post give me : _readableState,readable,_events,_eventsCount,_maxListeners,socket,connection,httpVersionMajor,httpVersionMinor,httpVersion,complete,headers,rawHeaders,trailers,rawTrailers,aborted,upgrade,url,method,statusCode,statusMessage,client,_cons. Where is the user value stored ?

wicked pivot
#
if(oldMember.user.bot) return;```

```UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'bot' of undefined
at module.exports (C:\Users\Utilisateur\Desktop\Détente [FR]\bot juzoo bot v12\events\voiceStateUpdate.js:7:21)```
ionic dawn
#

@slate oyster whats that

serene furnace
#
if(oldMember.user.bot) return;```

```UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'bot' of undefined
at module.exports (C:\Users\Utilisateur\Desktop\Détente [FR]\bot juzoo bot v12\events\voiceStateUpdate.js:7:21)```

@wicked pivot wat

slender thistle
#

Where the fuck is the property for body

tidal marlin
#

Hmm, maybe the order is somehow twisted when using the event. It firstly checks for bot not async then later I use async await to get PFX for certain server so that it would only check if person typed that and the bot appears to typed the PFX @misty sigil

#

but it really shouldn't happen cause it should be stopped before it reached that

solemn merlin
#

Idk @slender thistle x)

#

I press "Test" and I got this

slender thistle
#

What does your code look like

quartz kindle
#

@solemn merlin where did you get that from

solemn merlin
#

(First of all, I'm not node developper)


http.createServer(function(request, response) {
    if(request.headers['authorization']==process.env.apiKey){
      Do some noob shit things
}

}
#

Someone got an idea ?

drifting wedge
#

how can i get a random number between 2 numbers

#

using py

solemn merlin
#

int or float ?

#
from random import randint
randint(10,20)
drifting wedge
#

like a number from betweek 10-20

#

for example

solemn merlin
#

(this is not really random but u get it)

drifting wedge
#

yea

solemn merlin
#

random doesn't exist

drifting wedge
#

like a number from between 2 numbers

#

ik @solemn merlin

charred geyser
#

is it possible to make the automatically created role for the bot be at a specific position in the role list?

drifting wedge
#

but like a number from between 2 numbers

solemn merlin
#

I gave you the code

earnest phoenix
#

you're trying to do things blindly, without understanding how it works. its gonna be very hard for you if you keep doing it that way
Well teach me ;-;

misty sigil
#

learn base JS first

#

it'll make bot development much easier

drifting wedge
#

rxp = randint(10,20)
^
TabError: inconsistent use of tabs and spaces in indentation

#

wtf

faint prism
#

rxp reminds me of assembly

obtuse wind
#

is that... basic java

slender thistle
#

Exactly what the error says

drifting wedge
#

that\

#

thats the error

#

and im getting it a ton

slender thistle
#

You used tab or space which wasn't used in your code before to indent lines

drifting wedge
#

like for no f***ing reaosn

slender thistle
#

It matters which one you use in Python

quartz kindle
#

@solemn merlin the request that comes from httpServer is a readable stream

drifting wedge
#

ooooooooooooooh

quartz kindle
#

in order to read it you have to listen to the data event

#

like this

#
(request,response) => {
  let data = "";
  request.on("data", d => data += d.toString());
  request.on("end", () => console.log(data))
}
drifting wedge
#

wtf

#

its all good

#

but still \

solemn merlin
#
const server = http.createServer((req, res) => {
  let data=""
  req.on('data', chunk => {
  data+=chunk.toString();
  })
  req.on('end', () => {
  fs.appendFile('console.txt',data,function (err){if(err){throw err;}});
  })
  })
}).listen(8443);

``` like this @quartz kindle ?
#

(And ty)

earnest phoenix
#

learn base JS first
@misty sigil
Where

quartz kindle
#

should work, try it

solemn merlin
#

Okay, just (I'm a total noob in js, I just need to send a message to my Discord server on vote), how to I send an answer (like Hello World) using this system ?

slender gulch
#

@solemn merlin i'm sure there's a bot called DBL vote and it can do that

quartz kindle
#

you're not sending an answer back to dbl in this case

#

you want to redirect an answer to discord

#

so you just add your bot logic inside the end event

solemn merlin
#

yes but my I use it also for another things

quartz kindle
#

like client.users.fetch(data.user)

solemn merlin
#
  let data=""
  req.on('data', chunk => {
  data+=chunk.toString();
  })
  req.on('end', () => {
  fs.appendFile('console.txt',data,function (err){if(err){throw err;}});
    res.writeHead(200, {'Content-Type': 'text/html','connected':false});
      res.end("<p>Acces refuse</p>")    ;
  })
  })
}).listen(8443);```
quartz kindle
#

you probably need to json.parse it

solemn merlin
#

Yep, In fact I send it to a channel (using my website) then my bot reads this cannel

#

channel *

#

Yeeehh that's working !

#

Ty !

charred geyser
#

does anyone know if its possible to make the automatically created role for the bot be at a specific position in the role list?

viral spade
#

tim can you take a look at my problem?

steel tapir
#

does anyone know if its possible to make the automatically created role for the bot be at a specific position in the role list?
@charred geyser toggle this in server settings -> roles -> the role you want

quartz kindle
viral spade
#

oh. i have tried exactly that with .destroy() and .end(). but doesnt help

quartz kindle
#

then idk

#

try to create a minimum reproducible sample code

charred geyser
#

@charred geyser toggle this in server settings -> roles -> the role you want
@steel tapir what i mean is when my bot joins a server a role is created for the bot, as iis for any bot. But the role that is created is at the bottom of the role list and therefore lacks permissions over other roles.

acoustic bridge
#
async def purge(ctx, amount : int):
    await ctx.channel.purge(limit = amount)
    await ctx.send("Purged {amount} messages from this channel.)

Can I make it delete the "ctx.send" after a short time? I don't want it to be left permanently - just as a "response" for 5 seconds for example

sudden geyser
#

@acoustic bridge .send(...) has a delete_after parameter.

#

Give it a number in seconds.

earnest phoenix
#

Hello can you help me?

misty sigil
#

what

earnest phoenix
#

I am making a captcha system and wrote this:


module.exports = async (client, member) => {
    const db = require("quick.db");
    if (member.user.bot) return;

    let number = randomInteger(100000, 1000000);

   let verifyChannel = member.guild.channels.cache.find(ch => ch.id === "750651944237793330");

   await db.set(`verification.${member.user.id}`, number);

   const dm = new Discord.MessageEmbed()
   .setColor(0x7289DA)
   .setTitle(`Welcome to ${member.guild.name}!`)
   .setDescription("Hello! Before you get started, I just want you to verify yourself first.")
   .addField("Put your code into the channel.", `**This is your code:** ${code}`)
   await member.send(dm).catch(() => {
       verifyChannel.send(`<@!${member.user.id}> Hey, I guess your Dms are locked. How about unlock it first and type \`resend\` here.`)
       .then(i => i.delete({timeout: 10000}));
  })
}



function randomInteger(min, max) {
    min = Math.cell(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}```
#

And this:

    const db = require("quick.db");

    let codeExist = db.get(`verification.${member.user.id}`);
    if (codeExist) db.delete(`verification.${member.user.id}`);
}```
misty sigil
#

yes?

earnest phoenix
#

And this:

    if (message.content.startsWith("resend")) {
        let code = db.get(`verification.${message.author.id}`);
        await message.delete();
        const dm = new Discord.MessageEmbed()
        .setColor(0x7289DA)
        .setTitle(`Welcome to ${message.guild.name}!`)
        .setDescription("Hello! Before you get started, I just want you to verify yourself first.")
        .addField("Put your code into the channel.", `**This is your code:** ${code}`)
        await message.author.send(dm).catch(() => {
            return message.reply("Your DM is still locked! Unlock your DMs first.")
            .then(i => i.delete({timeout: 10000}));
        })

        return message.reply("Check your DM,").then(i => i.delete({timeout: 10000}));
    }

    if (!client.fonfig.owners.includes(message.author.id)) {{
        if (!message.author.bot) {
            let verify = parseInt(message.content)
            let code = db.get(`verification.${message.author.id}`);
            if (verify !== code) {
                message.delete()
                return message.reply("Are you sure that is the code that you typing it?").then(i => i.delete({timeout:10000}));
            }

            if (verify === code) {
                message.delete();
                db.delete(`verification.${message.author.id}`);
                message.reply("You are not a robot! Please wait, 5 seconds okay?").then(i => i.delete({timeout: 7500}));
                setTimeout(function() {
                    message.member.roles.add("750426065922424912")                    
                }, 5000)
            }
        }    }}
}```
in index.js
misty sigil
#

(please use a bin type service)

#

so what errors

earnest phoenix
#

I run it but this error pops up:

    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47```
#

How can I fix it?

misty sigil
#

make it an async function

earnest phoenix
#

How??

#

Lets move this to our Dms so we can solve that

misty sigil
cinder patio
#

why are you using async/await without knowing how it works

misty sigil
#

^ why are you making a bot without basic js knowledge

sweet ruin
#
for (const guild of client.guilds.cache) {
  if (guild.members.cache.get(newUser.id)) { inGuilds.push(guild.id) }```
#

I need some help

#

i dont understand why it isnt getting the members

#

client is defined correctly

lament rock
#

client.guilds.cache.values()

#

cache is a collection and iterating over a collection returns [key, value]

#

so you need to iterate over the Collection.values()

sweet ruin
#

oh okay

#

thank you

#

but now it cannot find the id values

#
client.on('userUpdate', async (oldUser, newUser) => {
    const inGuilds = [];
for (const guild of client.guilds.cache.values()) {
  if (guild.members.cache.get(newUser.id)) { inGuilds.push(guild.id) }
}
    const guild = await getGuild(client.guilds.cache.get(inGuilds));```
#

this is what i am doing.

#

trying to get the guild from a user object

#

(Not a member object a User Object)

earnest phoenix
#

a user does not have a guild

#

a member does

sweet ruin
#

i know

lament rock
#

Is the user cached within the guild?

sweet ruin
#

im trying to get an array of all the guilds that the member shares with Duke

#

the guild id's to be more specific

lament rock
#

If you're using gateway intents and don't have GUILD_PRESENCES then members will not be cached on load

#

only the ClientUser will appear in guilds

earnest phoenix
#

you need to either cache all members in all guilds (djs will heavily eat your ram) or check with fetch() if they exist in the guild (which is heavy on ratelimits)

#

so there's no reliable way to check for mutual guilds

#

the only reliable way i can think of is to go through oauth2 to get user's guilds and then see if your bot is in any of the guilds that the user is in

lament rock
#

that would work but oauth is a pain. Probably what could be less painful is to store related data in a persistent cache

sweet ruin
#

euhhh

#

ya'll have lost me :/

lament rock
#

do you supply gateway intents when you are constructing a new Client

sweet ruin
#

no

#

just partials

lament rock
#

I have never worked with discord.js partials so that's another can of worms I don't understand so idk.

How many guild members are in the guilds your client is in on load? > 1?

sweet ruin
#

i have 113 guilds right now

#

and the amount of members on them

#

half of them have over 100k members :/

lament rock
#

not the guild.memberCount
The guild.members.cache.size

sweet ruin
#

ill check it out

lament rock
#

oh wait. I think I see an issue with your code. inGuilds is an Array<string>
and you supply client.guilds.cache.get(inGuilds)
which only accepts a string

sweet ruin
#

oh

#

so what do i need to do?

lament rock
#

probably something like

await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id)))

then the return value of that Promise.all will be an Array<T>
Where T is the return value of getGuild

#

but you already get the guild from the client guild cache so I'm not sure what the getGuild function does

sweet ruin
#

euhhhh

#

getGuild gets it from the database

#

and what should i replace with await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id)))

#

(Sorry im not good at understanding stuff)

lament rock
#

const guild = ...
should be const guilds = ^

#

guilds would be the Array<T>

#

not literally ^ btw

sweet ruin
#

wait euhhh

#

i cant replace const guild = await getGuild()

#

that gets the guild from the ID and checks the database to see if something is enabled

#

but im trying to get the id's so i can check

#

if that makes sense

lament rock
#

It really does not. The point was to get all of the guilds the user is in, correct?

sweet ruin
#

correct

#

and then log them into an array

#
    const inGuilds = [];
for (const guilds of client.guilds.cache.values()) {
  if (guild.members.cache.get(newUser.id)) { inGuilds.push(guild.id) }
}```
#

this is the only part that needs help

lament rock
#

Your code, if it even worked, is getting a single Guild from the database. Which defeats the purpose of getting all of the guilds a user is in
replace
const guild = ... with const guilds = await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id)))

then you can for (const guild of guilds) {} and put your code that depends on individual guilds inside of that for of

sweet ruin
lament rock
#

yes

sweet ruin
#

im not doing that

#

because that wont change anything :/

lament rock
#

Then I cannot help you any further. I gave you a solution

sweet ruin
#

its my database thing not the actual guild getter

lament rock
#

I perfectly understood getGuild is getting data from the database

forest phoenix
#

hey so im pretty new to bot making and ive run into a problem with the jda builder... its deprecated

#

import net.dv8tion.jda.api.JDABuilder; <-- says this is deprecated

lament rock
#

it returns a Promise<T>

inGuilds.map(id => ...) uses your getGuild function and if the expected argument_0 in getGuild is a Guild then it passes getGuild a valid Guild and the return value of the inGuilds.map would be Array<Promise<T>>

Promise.all waits for all Promises to resolve and returns the values of the supplied Array of Promises
which would turn the return value into Array<T>

you can then for of that resolved Array of Guilds from the database and declare individual items of the array to be casted to const guild and put your guild dependent code inside of that for loop and it'll be like nothing changed

sudden tulip
#

does anyone know the d#+ lib for C# i need help with a command not doing what i want

full leaf
#

C# bot / Asp.net Webhook for voting

Controller: 
[HttpPost("~/runwebhook")]
        public ActionResult runwebhook([FromHeader]string Authorization, [FromBody]DBLVote vote)
        {

            var AuthKey = "";

            if (Authorization != AuthKey)
                return Forbid();

            _logger.LogInformation($"{Authorization} Authorization Header");

            _logger.LogInformation($"{vote.bot} {vote.user} {vote.type} {vote.isWeekend} {vote.query}");

            return Ok();
            
        }
DBLVote Object: 
    public class DBLVote
    {
        public string bot { get; set; }
        public string user { get; set; }
        public string type { get; set; }
        public bool isWeekend { get; set; }
        public string? query { get; set; }
    }

Sorry wanted to place this here incase someone else looks for info on webhook vote posts for C# discord bot

sweet ruin
#

?

#

i finally understood what you meant

lament rock
#

yes

#

then you can loop over each of those guilds

quartz kindle
#

do you have fetchAllMembers?

sweet ruin
#

loop over?

quartz kindle
#

that will only work with fetchAllMembers:true

sudden tulip
#

can somone help me with d#+

opal plank
#

you guys can deconstruct btw

cinder patio
#

@remote ivy remember how you told me to fix my problem with "Cannot send empty mesage"? I am getting the same error, except this time it's when I try to send an embed with a webhook:

return channel.send({embeds: [e]})

#

This worked fine before I updated to the latest version of discord.js ^

opal plank
#
let guilds = [...client.guilds.cache.values()];
lament rock
#

for (const guild of guilds) {
// put your code here
}

#

That is not related, Erwin

#

de structuring Collection.values() is useless since the return value already is an Array<V>

sudden tulip
#

SRSLY

cinder patio
#

collection.values() returns an iterator, not an array

sudden tulip
#

does anyone know c#

cinder patio
#

you can loop through it, ye, but a lot of methods are missing

lament rock
#

ok. Iterable<T> is close enough and for of statements treat it as ArrayLike

but thank you for clarification

full leaf
#

what do you need to know about C#?

forest phoenix
#

hey so im pretty new to bot making and ive run into a problem with the jda builder... its deprecated in 4.2.0 and i dont know how to fix this

sudden tulip
#

@full leaf may i dm u

#

i dont wanna give my code

full leaf
#

go for it

opal plank
#

not an array though

sweet ruin
lament rock
#

Google clarified that so that's a mistake on my part but in Creepa's case, destructuring values would have been useless since it's used in a for of

sweet ruin
#

it gives no errors, but euhm, it doesnt recognize when a user update happens in an allowed guild now :/

opal plank
#

i see

cinder patio
#

You can also do for (let [key, value] of map) to iterate thorugh a map

lament rock
#

is that all of your code, Creepa?

#

true, google

sweet ruin
#

that is the whole userUpdate event @lament rock

charred geyser
#

can anyone give me some help with my discord js bot?

sweet ruin
#

be more descriptive @charred geyser

forest phoenix
#

so im running into a problem where the JDA builder is deprecated, im extremelly new to this so any help is appreciated

charred geyser
#

well i dont have an issue as such, what i want to do is create some commands that configure things like autorole and join/leave channel

#

but i'm not sure how to do that when dealing with multiple servers

lament rock
#

ok so you completely removed the Promise.all I told you to add in.

underneath the first for of, you'd put that const guilds = await Promise.all(...
then right underneath that, do
for (const guild of guilds) {

}

and put the code like if (guilds.logging)

inside of the second for of statement and replace guilds to guild
since guilds is an Array

sweet ruin
#

the thing im stupid of rn

#

is what to put in the promise all :/

lament rock
#

I already gave you what should be in the Promise.all

#

I literally wrote code for you

charred geyser
#

@sweet ruin i pretty need to make commands that configure things specifically to one server rather than globally across the whole bots config

sweet ruin
#

i did put the promise.all in?

forest phoenix
#

when was JDA 4.2 released?

lament rock
#

that's not the proper place to put it. That first for loop should be

for (const guild of client.guilds.cache.values()) {...

#

then const guilds needs to be underneath the first for statement

sweet ruin
#

@charred geyser easiest way to do that is ```js
if (message.guild.id === ( "ID OF THE GUILD YOU WANT HERE" )) { YOUR CODE HERE } else {}

#

so like this?

quartz kindle
#

something about that looks wrong

lament rock
#

no lol

quartz kindle
#

very wrong

lament rock
#

it needs to be below the for of

#

way to slam your DB if you used that code

charred geyser
#

@charred geyser easiest way to do that is ```js
if (message.guild.id === ( "ID OF THE GUILD YOU WANT HERE" )) { YOUR CODE HERE } else {}

@sweet ruin but how would i get the bot to store information that is configured using commands, like how MEE6 can be configured to give a specific role when joining. Where would this info be stored?

sweet ruin
#

well if you are putting it for one server itself

#

just grab the role id

#

if it is custom

#

then you need a database

charred geyser
#

do you know anyone that can help me set up a database and wallk me through shit/ help me when i get stuck?

#

@sweet ruin

lament rock
#

No XD. One sec

forest phoenix
#

wheres the best place to ask like really beginner questions? i just wanted to make a bot out of boredom and could use the help

quartz kindle
#

you can ask here, but if you're really really beginner, we usually advise to learn some basic coding first

forest phoenix
#

oh i know java and stuff, just setting up a bot

charred geyser
#

wheres the best place to ask like really beginner questions? i just wanted to make a bot out of boredom and could use the help
@forest phoenix stackoverflow/youtube

#

youtube guides are pretty helpful for basic command handlers and stuff

quartz kindle
#

except when they're wrong or outdated lul

forest phoenix
#

yeah ive been doing youtube videos up until i ran into problems with deprecated stuff

charred geyser
#

yeah

forest phoenix
#

mostly problems with the JDABuilder

lament rock
#
for (const guild of client.guilds.cache.values()) {
   if (guild.members.cache.get(newUser.id) inGuilds.push(guild.id)
}

const guilds = await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id))))

for (const guild of guilds) {
   if (guild.logging) ...
}
charred geyser
#

can anyone help me set up a database for my bot

quartz kindle
#

what kind of database

sweet ruin
#

a simple mongo one would do fine for you

quartz kindle
#

first you need to chose a database, there are dozens of them out there

#

popular ones include sqlite, mysql, postgresql, mongodb, rethinkdb, and many more

charred geyser
#

what should i look for when choosing?

sweet ruin
#

fixed it

lament rock
#

They all are good at different things. Databases like Redis are super powerful for temporary storage for key value pairs but is not good for persistent data

sweet ruin
#

im not stupid lol

sudden tulip
#

anyone willing to help me with a d#+ command that i'm struggling with

sweet ruin
quartz kindle
#

@charred geyser any of those databases will work, the differences between them is what style they operate under. for example, sqlite and mysql are relational databases that use SQL to interact with it, which is like a whole new language for you to learn, but very powerful, flexible and works in many databases.
On the other hand, a database like Mongodb uses a document model that is not SQL based, so it has a different way of using

earnest phoenix
#

alg br ?

charred geyser
#

well considering im new to databases would Mongodb be best?

earnest phoenix
#

alguem brasileiro ?

#

i am from is brazilian

quartz kindle
#

another difference is that most of these databases are fully featured servers as well, which run in a separate process and can be installed in any computer, except SQLite, which is unique because its the only one that is embedded inside your program

lament rock
#

yes @sweet ruin

quartz kindle
#

personally i like SQLite better because its simpler to use, requires very little resources and is more than good enough for discord bots

#

but many people here use and prefer mongodb, mysql or even postgre

sweet ruin
#

i use mongo tbh

quartz kindle
#

another thing is that each of those databases require a library to use them in your code

#

and sometimes this library does much more than only interact with the database

#

for example, sequelize and mongoose are not only drivers, they are ORMs which create another layer on top of the database in way that you dont even feel like you're using the database directly

lament rock
#

if you plan to shard, you cannot use sqlite unless you have a database worker your shards connect to to query from.

So, using MySQL or MariaDB or some other DB which implements SQL or other NoSQL solutions are good

quartz kindle
#

even quick.db does this

#

you can shard with sqlite

charred geyser
#

shard?

lament rock
#

I thought sqlite imposes file locks.

quartz kindle
#

only for writing

#

not for reading

lament rock
#

So what happens when you write from multiple shards

quartz kindle
#

your writes will be queued

#

but if you write that much, go for a time series db

lament rock
#

learn something new every day

charred geyser
#

so which would be simplest

#

i dont think my bot is gonna be huge

#

i think im going for simplicity

quartz kindle
#

if you're an absolute beginner, and dont feel like learning how to use a database directly, you can use an orm/framework

sweet ruin
#

thank you for dealing with my stupidness @lament rock

quartz kindle
#

for example, enmap or quick.db

#

quick.db is a simple framework built on top of sqlite which makes it as easy to use as a Map object in js, and it does all the database code for you behind the scenes

nimble kiln
#

i dont think my bot is gonna be huge
@charred geyser That's what I thought aswell, and now I'm at ~650 servers - You'll be surprised

charred geyser
#

i know who you are 😄

nimble kiln
#

👀

charred geyser
#

you're very famous where i come from

#

hehe

nimble kiln
#

god damn, 2b2t players everywhere - but too much offtopic we should stop 😛

charred geyser
#

lmao

obtuse wind
charred geyser
#

yeah

#

i think

quartz kindle
#

no

nimble kiln
#

Not for name

charred geyser
#

oh

#

:(((

obtuse wind
#

kk thx people

charred geyser
#

i am big stupid bury me in the sand

#

okay so

nimble kiln
#

You'll learn it

charred geyser
#

quick.db

#

this means i can store data specific to a server

nimble kiln
#

yes, you can store any data in that

charred geyser
#

so for example

#

if i were to make a command that when i say %door #channel it will set the channel to send join/leave messages to #channel

#

how would i store that

sweet ruin
#

euh @lament rock.. it dont work. it again doesnt submit an error but it doesnt send an msg to the channel I specified when I change anything about my user :/

charred geyser
#

if my bot is in lots of servers

lament rock
#

show code

charred geyser
#

it needs like a seperate configuration for each server

quartz kindle
#

you create a configuration object for each guild

#

and store it using the guild id as the key

earnest phoenix
#

Could someone tell me how to make the bot command show on how many servers it is currently on?

charred geyser
#

ok that makes sense

quartz kindle
#

the simplest form of storage is called a "key value" database, which is essentially what objects and Maps are in js

sweet ruin
quartz kindle
#

something.set(key,value)

nimble kiln
#

@earnest phoenix What library are you using?

quartz kindle
#

quick.db uses sqlite in the background and offers a key value storage system on top of it, so basically you use it the same way

#

database.set(key, value) / database.get(key)

earnest phoenix
#

Eris @nimble kiln

lament rock
#

guilds.logging needs to be guild.logging

#

guilds is an Array

nimble kiln
#

👀 Ok sorry I'm out

charred geyser
#

lmao

#

also is there anything i can do to make my bot more likely to be verified?

#

apart from wait

sweet ruin
#

still nothing @lament rock

lament rock
#

Just don't do anything absurd with your user's data

pale vessel
#

Could someone tell me how to make the bot command show on how many servers it is currently on?
@earnest phoenix client#guilds#size

nimble kiln
#

oh, flazepe wrote it 😄

charred geyser
#

i accidentally got temp banned from using the discord api the other day

sweet ruin
#

it is supposed to be an array i thought

lament rock
#

try using console.log to see where things break

charred geyser
#

cause i went over the rate limi

#

t

#

i didn't even know what i was doing lol

lament rock
#

idk if they check that

#

just don't do that, then

#

There is usually a client event to tell you when you're being rate limited and what bucket you're being rate limited in

sweet ruin
#

so guilds gets the database file for the guild

lament rock
#

just console.log everything

sweet ruin
#

and so does guild

lament rock
#

easy way to debug

sweet ruin
#

they get the same thing

#

guild and guilds = the same thing exactly

charred geyser
#

so i have to create a dir for my database to run from

#

does that have to be linked to the bot at all or can that just be separately on my pc

quartz kindle
#

which database?

#

quick.db?

charred geyser
#

MongoDB

quartz kindle
#

ah

charred geyser
#

ah shit should i do quick.db?

sweet ruin
#

but all i need inside of the get guild is all of the IDs of the guilds that Duke and the member Share

#

@lament rock

quartz kindle
#

are you installing mongodb as a selfhosted, or using atlas?

charred geyser
#

ill do quick.db

quartz kindle
#

mongodb has an online service called "atlas" which basically they give you something like 500mb of storage for free that you can connect to, without having to install it

charred geyser
#

yeah i saw that

lament rock
#

getGuild accepts an Array of IDs?

charred geyser
#

but you dont need that with quick.db right?

quartz kindle
#

no, quick.db uses sqlite

indigo flax
#

what is the eval for discord.js to delete a message with the messageID

sweet ruin
#

i have no clue @lament rock

lament rock
#

Well. It's your code so

charred geyser
#

i should probably go with quick.db

indigo flax
#

or use a paid database like me

charred geyser
#

lol

#

im not quite there yet

indigo flax
#

what is the eval for discord.js to delete a message with the messageID
@indigo flax

lament rock
#

You should probably try to grasp an idea of Object types and what types mean. TypeScript is a good way to figure that all out. TS is js compatible as well :)

charred geyser
#

ok

#

oh so quick.db is really different

#

i kinda understand now

#

i think ill use mongodb

forest phoenix
#

so ive been working at this thing for like an hour and i cant find a fix for this deprecated JDABuilder. all im trying to do is launch the bot, and this is the only thing messing me up

charred geyser
#

@quartz kindle if i am using atlas do i create a cluster?

forest phoenix
#

so far everything ive found online is outdated from 3.8 and import net.dv8tion.jda.api.JDABuilder; is deprecated. what was this replaced by in 4.2.0?

pure lion
#

sexy Tim man UwU if i am using atlas do i create a cluster?
@charred geyser yes, or download mongodb community server to host on your machine

charred geyser
#

i created a cluster

#

and im just doing the stuff they tell me to

#

trying to connect to it

#

bruh

#

i think i have a database

#

yay

earnest phoenix
#

leave them

#

don't touch them

karmic compass
#

how do you get a certain role to be assigned to a constant with its id?
example:

const verifiedRole = client.roles.cache.get('ID')
``` would this work?
#

how do i also check if a member has a role?

indigo flax
#

whenever someone uses the ;stock command it doesnt reply and it says this in console (node:24) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body embed.fields[0].value: Must be 1024 or fewer in length. at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:24) 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: 105)

the command works in other servers tho

#

it also has worked before

void nest
#

your embed exceeds the allowed character limit

indigo flax
#

OH

void nest
#

try to add a field or even create a 2nd embed

charred geyser
#

lol

indigo flax
#

@void nest yeah ill do that

#

if it exceeds

#

it sends another embed

void nest
#

It's not your embed sticking out. But the field ( .addField () )

indigo flax
#

i easily fixed it by doing ;eval storage['750470743556620359'] = { nils: [] } in that server

sick cloud
#

i have this iframe here set to height: 100%. but how do i get it to work

#

because from the borders there, it ain't 100% high

lament meteor
#

maybe use min-height with 100vh? or lower

drifting wedge
#

for xp in exp:
UnboundLocalError: local variable 'exp' referenced before assignment

#

i keep getting this error

#
    guild_id = ctx.guild.id

    author = ctx.author

    user_id = {"_id": author_id}

    if ctx.author == client.user:
        return

        if ctx.author.bot:
            return

            if(collection.count_documents({}) == 0):
                user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
                collection.insert_one(user_info)

                if(collection.count_documents(user_id) == 0):
                    user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
                    collection.insert_one(user_info)

                    exp = collection.find(user_id)
    for xp in exp:
        cur_xp = xp["XP"]

        new_xp = cur_xp + 1

        collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)

    #await ctx.channel.send("1 xp up")

    lvl = collection.find(user_id)
    for levl in lvl:
        lvl_start = levl["Level"]

        new_level = lvl_start + 1

        if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
            collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
            await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")```
#

and its the mongo db stuff

earnest phoenix
#

sql.get(`SELECT * FROM blacklisted WHERE id = ? AND word = ?`, [MessageGuildId, MessageContent]).then(row => { if (MessageContent.toLowerCase().includes(row.word)) message.delete() })

This works but only if you say JUST the word. Let's say a blacklisted word is "test" and you type "testt", it won't do anything. But if you type the blacklisted word, it'll delete it. Anyone know what I can do?

This is for Discord.js.

sick cloud
#

@lament meteor yeah but i want it to be the height of the container it has, doing that works but it goes off page

lament meteor
#

hmm

#

does the container itself hv the entire bottom section?

sick cloud
#

idk

#

doesnt look like it

lament meteor
#

ah

sick cloud
#

setting it to 100% works but does the same off the page thing

lament meteor
#

i see

#

a shit fix would be to use js but tbf css is stinky

sick cloud
#

idk

#

i just need the iframe to take up whatever space is left in the container

lament meteor
#

lemme do some testing real quick

#

it uses a flexbox

earnest phoenix
#

How can I do if someone mentions my bot, then he says something xDD

lament meteor
#

@earnest phoenix either regex or hard coded mention detector

earnest phoenix
#

ty

#

Consegui

drifting wedge
#

boa @earnest phoenix

#

How can I do if someone mentions my bot, then he says something xDD
@earnest phoenix on mention?

earnest phoenix
#

Yep

drifting wedge
#

on_mention
await send('YO SIMP')

earnest phoenix
#

@drifting wedge oxi tu é brasileiro

sick cloud
#

@lament meteor doesn't work

lament meteor
sick cloud
#

i did it like that basically

#

but nothing worked

#
    <div class="container">
        <div class="area">
            <div class="toolbar mt-4">
                content buttons
            </div>
    
            <hr />
    
            <div class="mb-4">
                <iframe id="pdf"></iframe>
            </div>
        </div>
    </div>
        body, html {
            width: 100%;
            height: 100%;
        }

        .area {
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        #pdf {
            width: 100%;
            flex: 1;
            border: 1px solid #c0c0c0;
        }
ionic dawn
#

Hi, whats your error or what are you trying to do?

carmine summit
#
var numb = numb.toUpperCase
if (numb.includes('K' || 'M' || 'B')){
numb = numb.replace("K", "000");
numb = numb.replace("M", "000000");
numb = numb.replace("B", "000000000");
}
return numb
}```
err: numb.includes is not a function
#

help help help

crimson vapor
#

at the top you defined numb to a function you should instead call the function with numb.toUpperCase()

topaz fjord
#

@sick cloud -webkit-fill-available afaik

#

for height

#

I think the normal css value is fill-available

ionic dawn
#

funtion lengthen(numb)

sick cloud
#

um ok

earnest phoenix
#

that also isn't correct

#

the entire function is prone to breaking

charred geyser
#
      throw new _mongoose.Error.OverwriteModelError(name);
      ^

OverwriteModelError: Cannot overwrite `Guild` model once compiled.
#

anyone help me with this

#

im setting up a MongoDB database and this is the guild schema

#
const mongoose = require('mongoose');

const guildSchema = mongoose.Schema({
    _id: mongoose.Schema.Types.ObjectId,
    guildID: String,
    guildName: String,
    prefix: String
});

module.exports = mongoose.model('Guild', guildSchema, 'guilds');
digital ibex
#

guild collection already exists probably

charred geyser
#

im pretty certain it doesn't

digital ibex
#

whats the full error?

#

@charred geyser

charred geyser
#

oop

digital ibex
#

?

charred geyser
#

ill make that nicer to read hold on

digital ibex
#

just the first few lines

charred geyser
#
/Users/--/Documents/GitHub/MEE69-Development/node_modules/mongoose/lib/index.js:536
      throw new _mongoose.Error.OverwriteModelError(name);
      ^

OverwriteModelError: Cannot overwrite `Guild` model once compiled.
    at Mongoose.model (/Users/--/Documents/GitHub/MEE69-Development/node_modules/mongoose/lib/index.js:536:13)
    at Object.<anonymous> (/Users/--/Documents/GitHub/MEE69-Development/models/guild.js:10:27)
    at Module._compile (internal/modules/cjs/loader.js:1075:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)
    at Function.Module._load (internal/modules/cjs/loader.js:781:14)
    at Module.require (internal/modules/cjs/loader.js:964:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/--/Documents/GitHub/MEE69-Development/events/guildCreate.js:2:15)
    at Module._compile (internal/modules/cjs/loader.js:1075:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)
    at Function.Module._load (internal/modules/cjs/loader.js:781:14)
    at Module.require (internal/modules/cjs/loader.js:964:19)
    at require (internal/modules/cjs/helpers.js:88:18)
#

oh

#

welp

#

thats what i get after running node bot.js

digital ibex
#

show line 10 of models/guild.js

charred geyser
#
const mongoose = require('mongoose');

const guildSchema = mongoose.Schema ({
    _id: mongoose.Schema.Types.ObjectId(),
    guildId: String,
    GuildName: String,
    prefix: {
        default: '%',
        type: String
    }
})

module.exports = model('Guild', guildSchema, 'guilds');

this is the whole thing

digital ibex
#

how many collections do u have

#

and what r they called

charred geyser
#

where?

digital ibex
#

in ur database?

charred geyser
#

none

#

i haven't logged anything into my data base

#

i just set it up

digital ibex
#

its already been compiled before, you’ve obviously done something

charred geyser
#

oh shit hold on

#

nope

#

idk 🤷‍♂️

#

nothing in my database

digital ibex
#

you’ve got collections in ur db

charred geyser
#

oh right

#

so when i made the database i had to create a collection

#

i need to name it something else

digital ibex
charred geyser
#

yeah i saw that

#

ill keep trying ig

digital ibex
#

wtf

#

ur text editor it prob being stupid

charred geyser
#

yeah it was

#

i restarted and it was fine

#

still getting the OverwriteModelError: Cannot overwrite `Guild` model once compiled. thing

digital ibex
#

and u need to use the new keyword

#

new mongoose.Schema...

#

instead of

#

mongoose.Schema...

#

since its a class

charred geyser
digital ibex
#

yeah

charred geyser
#

still getting the same thing

earnest phoenix
#

If I declare const Guild = message.guild.id and use the declared statement, I get an error. But if I just use message.guild.id, I don't. Anyone know what might be causing it?

stark abyss
#

const backwards = msg.createReactionCollector(backwardFilter, {setTimeout: 1000 });

#

why doesn't the time out work

#

i set it for 1 sec to try it

#

help

drifting wedge
#

how do i make the client.command thing

#

in cogs?

clever vector
#

how to install canvacord

earnest phoenix
#
this.client.guilds.cache.filter(x=>x.id != "264445053596991498").sort(function(a, b){return b.memberCount ? b.memberCount : 0 - a.memberCount ? a.memberCount : 0}).map(x=>`${x.name} - ${x.memberCount} Members`).slice(0, 10).join("\n")```
Anyone knows an alternative to sort guilds from ascending to descending?
sudden geyser
#

If b.memberCount ? b.memberCount : 0 - a.memberCount ? a.memberCount : 0 is supposed to sort the guilds by their member count, I recommend you replace that with b.memberCount - a.memberCount. You can then flip the order to switch between ascending and descending (a.memberCount - b.memberCount). The reason I recommend it is because it would do the same thing but be more concise and easy to read.

earnest phoenix
#

oh well i added ternary because of unavailable guilds

#

ill remove it

#

that was during v11

clever vector
#

how to install canvacord

sudden geyser
#

Apollo I'd consider either filtering out unavailable guilds in the .filter() method, or checking for unavailable guilds and returning -1 instead.

#

To put that in a statement

earnest phoenix
#

npm i --save canvacord @clever vector

clever vector
#

npm install canvacord no work??

earnest phoenix
#

npm i --save canvacord @clever vector

#

you can always find the command to install on the npm page

sudden geyser
#
<Collection>.sort((a, b) => {
  if (b.available) {
    return b.memberCount - a.memberCount; // ascending
  }

  return -1; // Indicates it was not found.
});```
You can read more on how they like to sort stuff in JS here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
earnest phoenix
#

@coral trellis

stark abyss
#

lol

#

does the other stuff fine

clever vector
#

yey installed

coral trellis
#

@heady fable Don't advertise please

stark abyss
heady fable
#

oh, woops sorry,

stark abyss
#

~~bruh it's common sense ~~

earnest phoenix
sudden geyser
#

@stark abyss is the other stuff working, such as reacting and it editing the original message.

stark abyss
#

yes

#

everything else is working

sudden geyser
#

It's not removing reactions because you never tell it to. The only time you tell it to is in your end event, which is not working because it's nested in another event emitter

stark abyss
#

oh

sudden geyser
#

So you should move your end event outside the forward event function block.

#

Also do you mind if I give feedback about some of your code

fringe seal
stark abyss
#

go ahead

#

i would love to hear it

sudden geyser
#

\1️⃣

#

aight

fringe seal
#

does someone know how to get the base emojis for those

sudden geyser
#
  1. There's no need to re-create the client at the top of your file. It wouldn't be the same instance, so it wouldn't be useful in the first place. If you need the client, you could use message.client to get it (which is the actual client).
  2. Are you sure you need to re-define args? What are you doing with the current args parameter? What does that contain?
  3. You don't need to create three separate reaction event collectors. You can have one, check if the emote is the specified emote of the three and the user ID is the same as the message author.
  4. Line 29 and 30 are not guaranteed to be run first, if you know async/await. If not, I recommend you search it up.
stark abyss
#

oh

earnest phoenix
#

@fringe seal number emojis are actually two different characters so they don't escape properly

stark abyss
#

tbh i have no clue what i am doing

fringe seal
#

oh

stark abyss
#

i am learning slowly

#

@sudden geyser still gives me TypeError: msg.removeAll is not a function

earnest phoenix
stark abyss
sudden geyser
#

msg is a Message instance and has no removeAll method.

fringe seal
#

thanks

stark abyss
#

oh

sudden geyser
#

What you're looking to do is use .reactions, then the method call.

stark abyss
#

ok

#

ah yes it worked yay thank you lite

sudden geyser
#

no problem

charred geyser
#
(node:26780) UnhandledPromiseRejectionWarning: TypeError: client.guilds.forEach is not a function
#
    console.log("SERVERS:");
    client.guilds.forEach((guild) => {
        console.log(('-') + guild.name);
    });
#

getting this error for this function

#

oh cache maybe

#

yeah

#

i forgot i updated to v12

earnest phoenix
#

If I declare const Guild = message.guild.id and use the declared statement, I get an error. But if I just use message.guild.id, I don't. Anyone know what might be causing it?

earnest phoenix
#

how can i get the bot api key

#

🤔

forest fog
#

can anybody tell me how do i make a website for my bot

charred geyser
#
const user = message.mentions.users.first() || message.author;
    if (!user) return message.channel.send("Please specify a user!")
    const avatarEmbed = new Discord.MessageEmbed()
            .setColor(0x333333)
            .setAuthor(user.username)
            .setImage(user.avatarURL);
    message.channel.send(avatarEmbed);
#

supposed to return the mentioned users username + avatar

ionic dawn
#

Well

#

avatarURL is a function

#

it should be .avatarURL()

forest fog
#

can anybody tell me how do i make a website for my bot

#

pls

ionic dawn
#

But use .displayAvatarURL() instead to support non-avatar users

earnest phoenix
#

html css and js trickery

ionic dawn
#

@charred geyser

earnest phoenix
#

boom you got a website

forest fog
#

how

ionic dawn
#

Learning the basics of html and css

forest fog
#

html css and js trickery
@earnest phoenix what the hell is this

#

Learning the basics of html and css
@ionic dawn i know html

#

i dont know css

ionic dawn
#

Also CSS

#

Then you know what to do now

forest fog
#

ok

#

i will learn css

#

thanks

earnest phoenix
#

if you want to do oauth logins or displaying bot stats, you're going to need a fuck ton more

ionic dawn
#

Also check bootstrap

#

it will make it easier for you

#

Bots stats with js is enough

forest fog
#

ok

earnest phoenix
#

you can't have bot stats without backend

#

which is very likely out of their scope

ionic dawn
#

I supposed he have a bot

forest fog
#

i have a bot

ionic dawn
#

So he know node

forest fog
#

So he know node
@ionic dawn yep

ionic dawn
#

Theres your backend

forest fog
#

i use vs code

ionic dawn
#

No.. I mean

forest fog
#

visual studio code

ionic dawn
#

You need node to get bot info

forest fog
#

No.. I mean
@ionic dawn i know what you mean

#

You need node to get bot info
@ionic dawn yes i know

earnest phoenix
ionic dawn
#

Running on the back of the websitep

forest fog
#

ok

#

thanks for your all help

charred geyser
#

thanks @ionic dawn 🥰

ionic dawn
charred geyser
#

im upgrading my bot from v11 to v12 and a few things are annoying but its ok

ionic dawn
#

You can define the avatar format

#

I think if you dont define it is the base one, but you can specify to be png or jpg, useful if you doing anything with canvas

charred geyser
#

its ok

#

im working on the more important commands of my bot lol

#

if there is an issue in the future with that i will address it but i dont wanna spend too much time on it

cinder birch
karmic compass
#

Does anyone know what dependabot does, got an email from GitHub about it

pseudo silo
#

P

golden condor
#

Does anyone know what dependabot does, got an email from GitHub about it
@karmic compass it checks your dependencies for vunerabilities and tells you what you need to update and stuff

pseudo silo
#

. P yummy

delicate shore
#

i am getting pissed now

#

I have been getting this error since last 4 days

topaz fjord
#

internal server error

#

aka

#

discord broke

#

or you're doing smth wrong

#

idk

#

one of the two

#

I bet on discord breaking

weak rain
#

u r Naman? @delicate shore

delicate shore
#

yes

#

u r Naman? @delicate shore
@weak rain how do you know

weak rain
#

oh u r indian

#

nice

#

right?

#

btw i m a Hacker xD @delicate shore

slender thistle
#

Cut the casual chatter. Leave it in #general

weak rain
#

@slender thistle oh k

earnest phoenix
#

what happens if I JSON.stringify a string?
like: JSON.stringify("wait this ain't a valid object");

#

Does anyone know what dependabot does, got an email from GitHub about it
@karmic compass heard about build a bot never heard about dependabot

slender thistle
earnest phoenix
#

uhhh

slender thistle
#

Really?

#

-notr

gilded plankBOT
#

İngilizceden başka dillerde sohbet etmek için #memes-and-media kanalını, top.gg hakkında (Türkçe olarak da) destek almak için #support kanalını kullanın.
Bu kanalda Türkçe konuşmayın.

earnest phoenix
#

raid

slender thistle
#

Stop spamming

earnest phoenix
#

gawd

slender thistle
#

okay

earnest phoenix
#

moot

#

@earnest phoenix lan yapma sana banlarlar

slender thistle
#

Fuck it

earnest phoenix
#

@sage ermine olm turkiye başımızda ama olmaz

#

what flag is that

#

Turkish

#

oh

#

turkey turkey

#

I was tryna explain we respect turkish flag but ull get banned

#

So :/

#

Turks rlly respect their country and i like that

#

he definitely a patriot

#

😂

#

Dont know what he was doing

#

lol

#

I am having trouble running my bot after switching to discord.js v12.

16|alpha  |     at require (internal/module.js:11:18)
16|alpha  | /root/ProjectAlpha/node_modules/discord.js/src/client/voice/util/Secretbox.js:30
16|alpha  |     } catch {} // eslint-disable-line no-empty
16|alpha  |             ^
16|alpha  | SyntaxError: Unexpected token {
16|alpha  |     at createScript (vm.js:80:10)
16|alpha  |     at Object.runInThisContext (vm.js:139:10)
16|alpha  |     at Module._compile (module.js:616:28)
16|alpha  |     at Object.Module._extensions..js (module.js:663:10)
16|alpha  |     at Module.load (module.js:565:32)
16|alpha  |     at tryModuleLoad (module.js:505:12)
16|alpha  |     at Function.Module._load (module.js:497:3)
16|alpha  |     at Module.require (module.js:596:17)
16|alpha  |     at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)```
#

There was also another problem that occurred but I fixed it, but I assume this will come up after refreshing node_modules

#
15|alpha   | /root/ProjectAlpha/node_modules/discord.js/src/client/Client.js:41
15|alpha   |     } catch {
15|alpha   |             ^
15|alpha   |
15|alpha   | SyntaxError: Unexpected token {
15|alpha   |     at createScript (vm.js:80:10)
15|alpha   |     at Object.runInThisContext (vm.js:139:10)
15|alpha   |     at Module._compile (module.js:616:28)
15|alpha   |     at Object.Module._extensions..js (module.js:663:10)
15|alpha   |     at Module.load (module.js:565:32)
15|alpha   |     at tryModuleLoad (module.js:505:12)
15|alpha   |     at Function.Module._load (module.js:497:3)
15|alpha   |     at Module.require (module.js:596:17)
15|alpha   |     at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
15|alpha   |     at require (internal/module.js:11:18)```
#

nodejs and npm is up to date.

zenith terrace
#

Did you just update it directly from where you coded your bot

earnest phoenix
#

the host or the bots directory?

#

@earnest phoenix run node -v

zenith terrace
#

Directory I think

earnest phoenix
#

v8.10.0

#

And thats up to date...?

#

You need atleast v12

#

hmm

#
root@infernobot:~# sudo apt-get install nodejs
sudo: unable to resolve host infernobot
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (8.10.0~dfsg-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 100 not upgraded.```
#

is there a problem?

zenith terrace
#

iirc, that } catch { error occurs if you update your bot straight to v12 from where you coded it. I only ever heard of people either making a new project or rewriting their commands to fix it

earnest phoenix
#

well, it only occurs in my VPS not locally.

#
  • thats inside the discord.js package
#

so this is how it works

#

a mention when taken in a string or converted into a string

#

wdym

ionic dawn
#

testing lol

earnest phoenix
#
root@infernobot:~/ProjectAlpha# node -v
v12.18.3```
Updated node to v12 but its still having problems with the try catch
#

i mean

#

when a user mention or channel mention

#

is taken in form of a string

zenith terrace
#

That has always happened when it gets updated from v11 to v12 @earnest phoenix

earnest phoenix
#

like this

#

@steep quail

#

@zenith terrace How would I go about fixing it?

zenith terrace
#

The only ever solution I have found was to make a new project, install v12 version there and copy over the commands

#

Idk if there is any other way

#

Maybe someone else knows a way to fix it without making a new project

earnest phoenix
#

project by new file? or project by recode everything.

#

i already rm -rfed the project file and copied everything over

#

BUT node_modules

#

ran npm i and tried

#

still threw me errors

twilit rapids
#

You missed a variable (error) after catch. This is basic JS shake my head...

zenith terrace
#

Project as in recode everything. But I feel like there are other ways to fix it instead of recoding

twilit rapids
#
} catch (e) {}
earnest phoenix
#

Timo

#

this is inside the discord.js package

zenith terrace
#

That aint the problem Timo

twilit rapids
#

Interesting

zenith terrace
#

This happened to everyone when they updated discord.js to v12

sick cloud
#

i'm sort of dumb rn but if i store when i added something to db how do i filter by that date to only return ones where that date (item) has been there for say a minute
js

#

i can't work the logic out

earnest phoenix
#

use date now?

#

or new date

#

what is the db? an array or an object

sick cloud
#

object, i have a field cachedAt which is new Date() when added

weak rain
#
  throw err;
  ^

Error: Cannot find module 'C:\Users\Pujya Kumar\Desktop\Tansen'
    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: []
}
#

whats this

sick cloud
#

i want to filter so i only have items that have been in there for a minute or longer

#

to delete them

earnest phoenix
twilit rapids
#

If it's a known issue shouldn't djs made at least a post about it in their server

#

I didn't have it when I upgraded though

earnest phoenix
#

idk what your object looks like, but i would object use either keys, values, entries and check if ((newDate - oldDate) > 60000) { // deleteus }

sick cloud
#

my brain just can't figure out the logic today

#

so ty

#

i'm building a cache and want to delete items that have been there for a minute or more

earnest phoenix
#

np

weak rain
earnest phoenix
#

@weak rain what are you trying to do

weak rain
#

i want to start my bot

earnest phoenix
#

so you're running node . or node [file.js]

weak rain
#

Yeah

#

node .

earnest phoenix
#

can i see your package.json

twilit rapids
#

The path you specified doesn't lead to an existing file

earnest phoenix
#

^ its in your package.json

weak rain
#
  "//1": "describes your app and its dependencies",
  "//2": "https://docs.npmjs.com/files/package.json",
  "//3": "updating this file will download and update your packages",
  "name": "hello-express",
  "version": "0.0.1",
  "description": "A simple Node app built on Express, instantly up and running.",
  "main": "server.js",
  "scripts": {
    "start": "node ."
  },
  "dependencies": {
    "express": "^4.17.1",
    "discord.js": "^12.2.0",
    "fs": "^0.0.2",
    "path": "^0.12.7",
    "simple-youtube-api": "^5.2.1",
    "ytdl-core": "^3.1.2",
    "ytdl-core-discord": "https://github.com/CTK-WARRIOR/ytdl-core-discord",
    "@discordjs/opus": "^0.3.2",
    "genius-lyrics": "^3.0.0",
    "moment": "^2.27.0",
    "ms": "^2.1.2"
  },
  "engines": {
    "node": "12.x"
  },
  "repository": {    "url": "https://glitch.com/edit/#!/hello-express"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}```
ionic dawn
#

WOW WOW, i really need help rn

earnest phoenix
#

start server.js

ionic dawn
#

I listed all the servers id where my bot is in

#

and one shows undefined

#

how is that possible?

earnest phoenix
#

"scripts": {
"start": "node server.js"
}

sick cloud
#

lib being dumb dumb

earnest phoenix
#

^

sick cloud
#

happens sometimes

ionic dawn
sick cloud
#

my lib done it too

earnest phoenix
#

pog moment

ionic dawn
#

lol

earnest phoenix
#

honestly server outage?

sick cloud
#

its api sometimes also

earnest phoenix
#

filter it out, fuck that guild

sick cloud
#

no in an outage it shows available: false usually

#

check available if ur on djs

earnest phoenix
#

oh yeah a server outage fucked my bot on v11

#

thats why i moved to v12 today

#

and now i am stuck

#

with this stupid try catch issue

sick cloud
#

i don't need to worry bout djs

#

i'm on eris

#

😎

earnest phoenix
#

😐

twilit rapids
#

Could be that the server is unavailable

earnest phoenix
#

ight imma just host the bot in my pc

#

since it works there

ionic dawn
#

so libs are going brrrr?

twilit rapids
#

Not really lib

#

Could be caching etc

#

Try to fetch it and see if that works

ionic dawn
#

votes also showd incorrectly

#

It was working until right now

twilit rapids
#

Could be small api hiccup, nothing to worry about

balmy knoll
#

For a few days now, my bot has been pinging higher than usual. I use Heroku for the host and MongoDB Atlas as a database. By the way, are any of you having this problem too?

twilit rapids
#

If any my ping has been lower the last weeks, how high is your ping?

balmy knoll
#

My bot has about 3000 ping on average, usually has always had 150/200 on average

gaunt geyser
#

How do I make my own bot?

twilit rapids
#

Is this just during start up or even when it's been running for some hours

balmy knoll
#

I also changed the database server, but apparently that's not the problem

gaunt geyser
#

Thanks

twilit rapids
#

yw

balmy knoll
#

It always has the highest ping during start-up. But for a few days now, the ping is always so high without ever coming down

twilit rapids
#

Hm weird

#

I mean I would give the argument that you're using a free host but eh

balmy knoll
#

Yes it is true the host is free, but I have never complained about the 200ms ping average as it is more than acceptable for a free thing. I don't understand why the bot now reaches such high pings

mental furnace
#

So I have a bot (still awaiting review) but it has a feature to make a captcha, how long did you think a friend of my took to make a program to decipher it?

balmy knoll
#

Do any of you know how to change region on Heroku?

mental furnace
sick cloud
#

are there any random modules on npm that pick out the primary/dominant/main colour in an image

mental furnace
#

The Colorado is completely random tho

#

Well except that it needs to be above 55 green for the captcha itself

earnest phoenix
#

can the bot track dbl votes

#

using webhook

#

i mean can i put the webhook code in the bot code

mental furnace
#

?

#

Yes? I think

earnest phoenix
#

will it work

mental furnace
#

Tbh I have no clue what you are talking about

#

cause idk what DBL votes are

sick cloud
#

ask there

#

but yes of course

weak rain
#
const fetch = require("node-fetch");


 module.exports = {
  name: "phub",
  category: "image",
  description: "PornHub Quote",
  run: async (bot, message, args) => {

    let user = await message.mentions.members.first()
    let text = args.slice(1).join(" ")

    if(user){
        text = args.slice(1).join(" ");
    } else {
        user = message.author;
    }

    if(!text){
        return message.channel.send("**Enter Text!**");
    }

    let m = await message.channel.send("**Please Wait...**");
    try {
        let res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=phcomment&username=${user.username}&image=${user.displayAvatarURL({ format: "png", size: 512 })}&text=${text}`));
        let json = await res.json();
        let attachment = new Discord.MessageAttachment(json.message, "phcomment.png");
        message.channel.send(attachment);
        m.delete({ timeout: 5000 });
    } catch(e){
        m.edit("Error, Try Again! Mention Someone");
    }
}
};
#

Whats the cause?

summer acorn
#
        } else if (isEmbed === true) {
            this.client.shard.broadcastEval('if (this.guilds.cache.get("724602779053719693")) this.guilds.cache.get("724602779053719693").channels.cache.get("'+channelid+'").send('+message+')').catch(err => console.error(err));
        }

I am unable to send a embed through this. I've tried multiple things, but I couldn't figure out how to send an embed already defined through a shard eval. This is the only error I get

sick cloud
#

not great with embeds tbh

weak rain
#

Use fields i guess @sick cloud

#

and set your hex to RANDOM

sick cloud
#

a. already using fields
b. why would having random rainbow colours help

#

not even sure if 'random' exists tbh

summer acorn
#

"RANDOM" exist

sick cloud
#

i mean on eris

#

not using djs

earnest phoenix
#

use random number generator

#

new Color(rand1, rand2, rand3)

delicate shore
#

Anyone getting the error of internal server

#

I found solution

ionic dawn
#

why is my canvas working on my local, but not on my vps

#

Error: /blablabla.../Release/canvas.node: invalid ELF header

#

y

#

Okay, my mistake is that I moved the bot etc and installed canvas

#

but missed the gyp dependencie

cinder patio
#

Uh, the error message is wrong

#

You might want to console log the error inide the catch block

#

to see the actual error

#

that error doesn't appear because you didn't mention someone

#

Also unneccessary await let user = await message.mentions.members.first()

delicate shore
#

Can I do ftp from. Mobile

#

And edit file also

#

From mobile ?

#

Any application?

tight plinth
lament meteor
#

but still doesnt answer the question "how does making it rainbow make it better"