#development

1 messages · Page 921 of 1

maiden mauve
#

^

#

There are nuances in updates but that is coding

#

if the engine updates you move with it

quartz kindle
#

no why cant i use windows xp

earnest phoenix
#

So, Tim, only iconURL should work ?

maiden mauve
#

it would be a fun experiment to boot up windows 95 and see what you can do

quartz kindle
#

@earnest phoenix the iconURL property of guild should work

maiden mauve
#

that's from v11

earnest phoenix
#

@quartz kindle it don't work

maiden mauve
#

as long as your guild object is real

earnest phoenix
#

guild is not defined

quartz kindle
#

its a nullable field, that means it can be empty if your guild doesnt have an icon

#

of course guild is not defined, you have to get it from somewhere

#

i didnt tell you to remove what you had, i just said it should work

#

what you had was correct all along

maiden mauve
#

@earnest phoenix go backwards in your object chain and make sure the root is defined

#

make sure the variable is the object you believe it to be, etc.

quartz kindle
#

when i said iconURL should work, i mean that the iconURL property of the guild object (that you are getting from member.guild) should work

#

everything is context and everything has to come from somewhere

earnest phoenix
#

member.guild.iconURL is not a function

cinder patio
#

Tim, we have a problem. Now if you close the page and then go back it forgets your socket ID

quartz kindle
#

its not a function in v11

wet iron
#

I just realized something

maiden mauve
#

Sabin what is member from your console log?

wet iron
#

Nobody gave us the source code for how our bodies work so we've basically spent centuries reverse engineering ourselves

earnest phoenix
#

member.guild.roles.find isn't a function anymore, does anything else work?

cinder patio
#

elon, if you are on v12 you should use guild.roles.cache.find

earnest phoenix
#

ok

quartz kindle
#
object.a // this is a property. do it like this in v11
object.a() // this is a function. do it like this in v12
earnest phoenix
#

Loaf, wdym ? I don't understand english very good 😅

quartz kindle
#

@earnest phoenix

earnest phoenix
#

?

#

ooooooooooooooooooooooh

#

it don't work because i have iconURL() ?

quartz kindle
#

yes

maiden mauve
#

@earnest phoenix if member.guild object is undefined, what is member object?

earnest phoenix
#

@quartz kindle you are the best man

quartz kindle
#

its not undefined

#

@cinder patio sessionStorage doesnt survive closing the page and returning

#

only reloading

cinder patio
#

yeah welp it's not that big of a deal

quartz kindle
#

if you have 2 tabs open, and you close them both, then reopen one of them, which tab should it reconnect to?

#

its better to simply create a new connection i guess

earnest phoenix
#

I solved all the errors but the bot still don't send any message

cinder patio
#

yeah but if the game has started then they won't be able to play

amber fractal
#

you can use localStorage though, no?

cinder patio
#

it's alright though that's good enough I doubt someone would close the page

quartz kindle
#

then you will need something persistent, but then it wont work with multi-tabbing

#

unless you do something like show a list of active sessions on this browser and let the user pick one

#

or you implement some user account system to resolve after the connection is established

#

doesnt even need to have a password, just make the user create a unique player name, and then if he inputs the same name in another tab/window, he can rejoin the session

cinder patio
#

hmm yeah that's a good idea

#

the game already uses only usernames so it'll be easy

quartz kindle
#

you'd probably also need to track their ip addresses to avoid some random person from the other side of the world join their session accidentally lol

earnest phoenix
#

Tim, the bot still don't send any message, but in logs i got the channel id, guild id, channel name etc.. Any idea? Should i give you the code?

quartz kindle
#

yes

cinder patio
#

yup, already doing that for alt detection! Thanks, without you I'd be probably banging my head right now

quartz kindle
#

lmao

earnest phoenix
hollow prawn
#

does try not respect the return of a if / else if chain?

sudden geyser
#

You need to await it.

hollow prawn
#

await what exactly?

#

oh wait thats probs not for me

sudden geyser
#

Well is it like if you did return message.channel.send(...) it would not work?

hollow prawn
#

ye

#

it doesnt even do the check

#

and instantly skips to the bottom one for administrator permission

quartz kindle
#

@earnest phoenix what does your console.log show?

hollow prawn
#

yeah i've got no idea why my code doesn't stop at the return

#

as if try doesn't respect the return in a if / else if chain

quartz kindle
#

which return are you expecting it to stop at?

hollow prawn
#

the one for cd.has

earnest phoenix
#

everything in console.log or only the channel thing ? ( i have the custom prefix too so is + 200 lines )

hollow prawn
#

as it is true

#

but like I log that too, even if its true, it gets skipped

#

like it starts from the bottom LOL

novel notch
#

hello im quite new to bot development but i know some C#. so my question is can you use C# to develop a discord bot?¿?

hollow prawn
#

probably yes

quartz kindle
#

if it gets skipped then its not true?

hollow prawn
#

but when I console log it

slender thistle
#

There's plenty of Discord libraries for C#

hollow prawn
#

it returns true

novel notch
#

There's plenty of Discord libraries for C#
@slender thistle ok thanks

earnest phoenix
#

@quartz kindle i got this

  type: 'text',
  deleted: false,
  id: '709122923293573120',
  name: 'welcome',
  position: 2,
  parentID: '707898970080280647',
  permissionOverwrites:
   Collection [Map] {
     '687996961298579494' => PermissionOverwrites {
       id: '687996961298579494',
       type: 'member',
       deny: 0,
       allow: 7168,
       denied: [Permissions],
       allowed: [Permissions] } }, 
and more other permissions
.
.
.
quartz kindle
#

does it log if you put a console.log inside that if?

earnest phoenix
#

are u talking to me ?

#

how i create a invite?

quartz kindle
#

@earnest phoenix looks correct, is it not throwing any error?

#

when a member joins?

hollow prawn
#

i have log inside that if, it doesnt log anything

earnest phoenix
#

UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body

#

only this

quartz kindle
#

"only this", thats the reason why its not working lol

hollow prawn
#

but logging the check in the else if returns true

earnest phoenix
#

=)))

#

And how to solve this error ?

quartz kindle
#

addField() is wrong

#

you cant do addField(a,b,c,d)

#

you have to do addField(a,b).addField(c,d)

earnest phoenix
#

Tyy

#

it worked

#

💪

quartz kindle
#

@hollow prawn what is your key supposed to look like?

#

for cd

shell raptor
#

hey

#

when my bot send an image there is an url how can i mask him ?

quartz kindle
#

wat

#

wdym mask him?

shell raptor
#

wdym ?

#

i dont understand

#

im not english :/

hollow prawn
#

cd is a new set()

quartz kindle
#

ah ok, then what is the item in the set supposed to look like?

#

is it supposed to look like this? "287987598345 + 7237498749223"

hollow prawn
#

yes

#

the values are variable tho

earnest phoenix
hollow prawn
#

each separate message author with each separate guild id

quartz kindle
#

@earnest phoenix it is correct

earnest phoenix
#

but in the welcome message it says undefined and there is no error

#

oh nvm, i solved it

hollow prawn
#

@quartz kindle an easy fix would be just removing the check for !message.member.hasPermission('ADMINISTRATOR')

#

and it wouldn't affect the code much, however later on I might need it and i'll have same issue I have rn xd

quartz kindle
#

its redundant, you can remove it

#

but it wont fix whatever problem you're having

hollow prawn
#

yes, and idk why it even skips it

quartz kindle
#

try console.log(cd.has(...)) before the entire if, or even before the try

sudden geyser
#

My question relates to JSDoc and WebStorm IDE.

I'm having issues referencing parts of my code in another file. In src/Rin.js, I exported an extended class of the Eris client (https://abal.moe/Eris/docs/Client): https://hatebin.com/hlppuzeezy

I'm using @type to declare each property added and your usual @param for methods/functions.

I'm able to use this.client.logger without any issues in a new command/event, but if I use it in the base class (such as src/structures/Command.js), it says it can't find the variable: https://hatebin.com/gpolgrklha (Unresolved variable logger)

I tried changing Client in only JSDoc to Rin to test it, and it makes methods show up, but not properties. Does anyone know what could be causing this?

hollow prawn
#

its a false

#

interesting why as the timeout is set to 50 seconds

quartz kindle
#

where are you defining cd btw?

hollow prawn
#

at the very top

#

before on message event

#

wait

#

holdup i did a opsie

earnest phoenix
#

how to code to put the user avatar to the right corner?

hollow prawn
#

.setThumbnail()

#

or something like that, check the docs for the exact usage if u use discord.js

#

yeah it still returns a false for the set

#

as if at the time of adding it it already clears it

#

so it has to do something with the timeout not having proper time

#

as once it gets added timeout runs instantly and it removes it

#

instead of waiting the time

quartz kindle
#

@sudden geyser is it just the IDE not resolving it, but the actual code still works when executed?

sudden geyser
#

Yeah the code works itself.

earnest phoenix
hollow prawn
#

ahhhhhhhh i got it, it was the ms( ) at set timeout, forgot that takes string and converts it to miliseconds

#

so it was not needed ,now the cooldown works properly

nocturne grove
#

Hey, I was making a seperate file to query my database. I use this:

module.exports = {
    query(queryContent) {
      await new Promise((resolve) => {
        const mysql = require('mysql');
        const con = mysql.createConnection({ ... });

        con.connect();

        con.query(queryContent, (err, result) => {
          if (err) return console.log(err);
          console.log(result); // working here
          return result;
        });

        con.end();
      });
  },
};```

```js
// this is async
const database = require('path');
const result = await database.query('SELECT * FROM table');
console.log(result); // returns undefined```
This is not working, I also tried it with `return new Promise( ... ` instead
sudden geyser
#

In your query callback, try resolve(result) instead. You still need to return the new promise I think.

#

Though I don't know about making a new connection to the database every time to query some stats.

#

Doesn't sound so good.

tight plinth
#

whats the eris equivalent of js message.channel.awaitMessages(...)?

mossy vine
#

there isnt afaik

tight plinth
#

fuc

sudden geyser
#

You need to make your own message collector.

mossy vine
earnest phoenix
#

i made a credits system and i don't know how to make it globally ( on all servers ) help, please?

magic jackal
#

What am I doing wrong wtf

digital ibex
#

globally what

#

@earnest phoenix

magic jackal
#

delete require.cache[require.resolve('./config.js')]

Is not a function, is there something I'm missing

nocturne grove
#

@sudden geyser thank you. Some people advised me to do so 🤷

sudden geyser
#

what

nocturne grove
#

to make a new connection every time

delicate zephyr
#

@magic jackal dms

magic jackal
#

ok

earnest phoenix
#

@digital ibex like I have 2000 credits on one guild to have on another

digital ibex
#

idk what credits is

#

can u like, explain

nocturne grove
#

yes it works now, Kinolite. Thank you

earnest phoenix
#

like coins

#

economy

digital ibex
#

ok

#

ur making no sense

earnest phoenix
#

wdym ?

digital ibex
#

u want ur 2000 credits on one server to get added onto a different one?

earnest phoenix
#

no man

digital ibex
#

then

#

explain

earnest phoenix
#

with my bot, on a server i have a sum of credits ok ?

#

but on other server i have another sum of credits with the same bot

blissful scaffold
#

Sounds to me like the coins/credits are saved per server

digital ibex
#

i don't know what language u r using and idek what db u r using

earnest phoenix
#

@blissful scaffold yes

#

@digital ibex Sorry, my english is bad

digital ibex
#

so

#

u want to add the credits to ur other server?

earnest phoenix
#

nvm man, i think i solved it

digital ibex
#

¯_(ツ)_/¯

#

ok

earnest phoenix
#

How many credits do I have on one server I want to have on another, now u understand ?

digital ibex
#

yes

#

i think so anyways

#

what language & database r u using

earnest phoenix
#

node.js, discord.js v11, quick.db

digital ibex
#

i've never used quick.db, can't help 🤷‍♂️

earnest phoenix
#

Ok, i found a way to solve it anyway

#

thanks to WhiteSpirit

rose warren
#

Just store in a "global" database that you call from. I do that with my bot. I have the credits amount in the user account table of my db and call from that. That way their credits aren't associated with a guild id, they're associated with a user id.

nocturne grove
#

https://discordapp.com/channels/264445053596991498/272764566411149314/709417238251307068 with something like this (it works now), is there an option to stop the execution in the file this function is used? Like in the second code block, stop that execution there if the query in the database.query() function gave an error. I could use like return null; with an error and if (result == null) message.reply('an error occured'), but is there an easier way too?

earnest phoenix
nocturne grove
#

@earnest phoenix please send it using pastebin/hastebin and say where the leaderboard code is

nocturne grove
#

thanks

earnest phoenix
#

is there a package to detect if a discord message is a link?
i dont wanna use http:// https:// because its not always a link

nocturne grove
#

@earnest phoenix I'm sorry idk, I'm not familiar with db

earnest phoenix
#

@nocturne grove uh, ok, ty

snow urchin
quartz kindle
#

m is never gonna be a number, so that typeof will never pass

grizzled raven
#
<--- JS stacktrace --->  ==== JS stack trace =========================================  0: ExitFrame [pc: 0x74a93fcfc5d] Security context: 0x2278e6f9d9f1 <JSObject> 1: set [0x2278e6f90e49](this=0x3761b559ca91 <Map map = 0x25fbd318f631>,0x0cb69decfb61 <String[18]: 641460083536166924>,0x213f149e8db1 <Base map = 0x25fbd31c9471>) 2: get emojis [0x11abef4390e9] [/home/thenoob27/Starboard/node_modules/discord.js/src/client/Client.js:~170] [pc=0x74a94a11eea](this=0x180e40782931 <EventEmitter map = 0x560032857c1>) 3:...
``` what the hell do these mean
sudden geyser
#

magic js stacktrace

#

is there more to it.

grizzled raven
#

how do i prevent it

quartz kindle
#

never seen a stack trace like that

grizzled raven
#

seems to be related to

#

the client emoji getter

#

maybe because my bot is a bot that deals with reaction emojis quite often? idk

#

reaction emoji is a getter which uses client.emojis

#

and then also other stuff

#

but how do i prevent it

quartz kindle
#

is there nothing else logged?

shell raptor
#

how i put

message.channel.send(waifu[Math.floor(Math.random() * waifu.length)]); 

in an embed pls ?

knotty steeple
#

embed description?

quartz kindle
knotty steeple
#

yes this

shell raptor
#

i try it

white anvil
#

@grizzled raven thats usually caused when u run out of memory

shell raptor
#

but there is 33 images and i want he send juste 1 randomly

white anvil
#

its a c++ thing

shell raptor
#

?

quartz kindle
#

you use the result of your math random with the embed functions from the link above

shell raptor
#

i try

const Embed = new Discord.MessageEmbed()
.setColor('RED')
.setMessage('message.channel.send(waifu[Math.floor(Math.random() * waifu.length)]);')

message.channel.send(Embed);
#

but its doesnt work

quartz kindle
#

there is no setMessage

shell raptor
#

beacause .setMessage doesnt exist

quartz kindle
#

read the guide

shell raptor
#

i know

quartz kindle
#

also, read about concatenation and string templating

knotty steeple
#

do more in ur js class

shell raptor
#

oh

#

i dont understant the guide

#

forget about it

quartz kindle
#
"result is 10 + 10" // "result is 10 + 10"
"result is 10" + "10" // "result is 1010"
"result is " + (10 + 10) // result is 20
`result is ${10 + 10}` // result is 20
tight plinth
grizzled raven
#

@white anvil definitly not caused due to lack of memory

#

i have like 16gb on my system and i use an average of 1.2gb

white anvil
#

yeah but the heap size won’t be that big

#

nodejs only has a certain amount of allocated memory

quartz kindle
#

is there nothing else logged?

#

usually an oom crash dump is way bigger than that

white anvil
#

nah those traces are about that size

#

the rest is just the report

#

i think?

quartz kindle
#

yeah thats what im saying

white anvil
#

maybe ur right

quartz kindle
#

the full log is way bigger than just that

white anvil
#

lol

quartz kindle
#

that part is pretty useless on its own

grizzled raven
#

i have an image of it from a while ago, i'll check

white anvil
#

it also says if its a memory problem

grizzled raven
#

ok so

white anvil
#

if u didnt get that then idk

grizzled raven
#

mine didnt

#

well

#

actually let me go back further

white anvil
#

were u just running something and this hapepend?

grizzled raven
#

yes

white anvil
#

weird

#

i dont see ur code causing this it must have come from one of the packages you were using

#

unless ur running very weird shit

quartz kindle
#

if its an out of memory crash, then its a memory leak

grizzled raven
#
// random logging stuff

<--- Last few GCs --->  [24530:0x31de0a0] 12709429 ms: Scavenge 1254.9 (1412.4) -> 1254.3 (1412.9) MB, 9.4 / 0.0 ms (average mu = 0.245, current mu = 0.205) allocation failure  [24530:0x31de0a0] 12709489 ms: Scavenge 1257.7 (1415.5) -> 1256.8 (1416.0) MB, 9.3 / 0.0 ms (average mu = 0.245, current mu = 0.205) allocation failure  [24530:0x31de0a0] 12709553 ms: Scavenge 1263.9 (1422.2) -> 1262.9 (1422.2) MB, 8.3 / 0.0 ms (average mu = 0.245, current mu = 0.205) allocation failure    <--- JS stacktrace --->  ==== JS stack trace =========================================  0: ExitFrame [pc: 0x74a93fcfc5d] Security context: 0x2278e6f9d9f1 <JSObject> 1: set [0x2278e6f90e49](this=0x3761b559ca91 <Map map = 0x25fbd318f631>,0x0cb69decfb61 <String[18]: 641460083536166924>,0x213f149e8db1 <Base map = 0x25fbd31c9471>) 2: get emojis [0x11abef4390e9] [/home/thenoob27/Starboard/node_modules/discord.js/src/client/Client.js:~170] [pc=0x74a94a11eea](this=0x180e40782931 <EventEmitter map = 0x560032857c1>) 3:...

// client has to log in again
white anvil
#

is that everything?

#

allocation failure

grizzled raven
#

everything that it shows

white anvil
#

that smells like an error thrown becuz u ran out of memory

grizzled raven
#

and it seems to be an allocation failure

#

why am i lagging

quartz kindle
#

it does look like an out of memory, but idk why it doesnt show the report after it

white anvil
#

yeah

grizzled raven
#

ok nvm

#

pretty sure it actually saves a report of it

#

.report-1212221112.json or aomething

white anvil
#

yeah it does

#

in the cwd

#

report.date.time.other shit.json

grizzled raven
#

report.20200508.174903.2751.0.001.json

#

but what couldve caused the memory leak

white anvil
#

what does the report say lol

grizzled raven
#

my only guess is iterating every guild for the client.emoji getter too often

#

i cant read it

#

actually wait

quartz kindle
#

what version of node are you on? is it 32 bit or 64 bit?

grizzled raven
#

think this is what you need - ```json
{
"header": {
"event": "Allocation failed - JavaScript heap out of memory",
"trigger": "FatalError",
"filename": "report.20200508.174903.2751.0.001.json",
"dumpEventTime": "2020-05-08T17:49:03Z",
"dumpEventTimeStamp": "1588952943749",
"processId": 2751,
"cwd": "/home/thenoob27/Starboard"
}
}

white anvil
#

the only meaningful line in that is the event

#

lol

#

memory leaks are an absolute pig to fix

#

must be pretty significant for the heap to run out of memory though

quartz kindle
#

also, it seems its crashing at around 1.5gb

#

could be related to node's max-old-size

#

try running node with --max_old_space_size=4096

#

to set it at 4gb

white anvil
#

is that rlly smart

grizzled raven
#

yeah its around 1.5, never seen total memory usage go past 1.4 lol

#

so should i do that?

earnest phoenix
quartz kindle
#

show your message event

unique nimbus
#

Is it more efficient to make a class in a separate script and request it if multiple scripts needs it

rare tangle
#

How can I post image with bot, not url. Only image?

#

from url that doesn't end with .png or any file format

unique nimbus
#

You want to post an image which doesn't have an image format?

rare tangle
#

link doesn't end with file format, the url displays image

#

yeah

quartz kindle
#

more efficient as opposed to what?

#

@rare tangle you mean generate an image inside the program and send it directly?

unique nimbus
#

having the same class in every script

quartz kindle
#

or use an url that doesnt end with a format?

unique nimbus
#

because I have big brain atm and need to make it more efficient

grizzled raven
#

oh yeah will --max_old_space_size=4096 work with pm2 and others?

quartz kindle
#

if you can reuse the class instance, declare is somewhere, initialize it and attach it to somewhere that you can access from all files

#

if you need multiple instances, then do the same but initialize it on each file where you use it

unique nimbus
#

yes

#

and it would be more efficient wouldn't it

#

as in does crap faster and uses less RAM?

#

because it ain't needing to load the same crap multiple times

quartz kindle
#

yes

#

@grizzled raven probably yes

#

pm2 has specific options to pass node arguments

#

you need to check their docs

grizzled raven
#

okay

quartz kindle
#

@rare tangle so you want to post it as an attachment

#

are you using discord.js?

rare tangle
#

yep

quartz kindle
#

.send({files:["url"]})

rare tangle
#

I've tried
message.channel.send("Whatever words you want here, can be nothing", {files: [file]});
but it worked on links ending with .file format which my url doesn't end

#

It gives a download url instead with no format

quartz kindle
#

try this then: .send({files:[{attachment:url,name:"image.png"}]})

rare tangle
#

It worked, thank you!

civic bloom
#

Hi

reef carbon
#

Does anyone know how long it takes for a bot to get approved?

gilded plankBOT
earnest phoenix
#

@earnest phoenix

autumn quarry
#

Question, how can I have the bot see what type of status i have? ex: online, idle, dnd
Discord.js (v11)
(if you can answer, please ping me)

mossy vine
digital ibex
#

hi

pale vessel
#

hi

digital ibex
#

with mongo, what can i do to update the guild in the db, what i have to do is delete it on compass and then use a command, then set the guilds config up and stuff, what can i do to not do that?

#

like, when i add something onto the model to add it to the guild and for it to actually work in the guild, i have to delete it on compass

lapis ocean
#

Hey, is this working?

digital ibex
#

is what working @lapis ocean

lapis ocean
#

Sorry, this server was having connection issues I think

limber flume
#

yes

#

i got kicked

placid hamlet
#

Hey guys, I have an error with my music bot, it throws an error when trying to place a song, the error marks me in these lines;

limber flume
#

ffmpeg

#

do u have

placid hamlet
#
async function buscar_video(args, message) {
    let respuesta = await doRequest("https://www.googleapis.com/youtube/v3/search?part=id&type=video&q=" + encodeURIComponent(args) + "&key=" + yt_api_key);
    let json = JSON.parse(respuesta);
    if (!json.items[0])
        message.reply("No se encontro ningúna canción.");
    else {
        let id = json.items[0].id.videoId;
        reproducirYoutube(id, message);
    }
}
limber flume
#

put this in your folder

#

maybie npm install ffmpeg

#

its noti senfing

earnest phoenix
#

Hi, I am getting such a mistake. Does anyone know the solution?

limber flume
#

npm install quick.db

earnest phoenix
#

I Know And I Don't Install It Gives An Error Again

quartz kindle
#

how did you install it?

#

show the install logs

placid hamlet
#

@limber flume
I still take into account the error, in what I mentioned before

(node:2067) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token u in JSON at position 0
at buscar_video (/app/server.js:263:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2067) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2067) [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.

limber flume
#

erm

#

hrm

#

idkk

quartz kindle
#

that happens if respuesta is not valid json

#

console.log(respuesta)

placid hamlet
#
let respuesta = await doRequest("https://www.googleapis.com/youtube/v3/search?part=id&type=video&q=" + encodeURIComponent(args) + "&key=" + yt_api_key);
    let json = JSON.parse(respuesta);

in this lines, set "respuesta"

quartz kindle
#

yes, console.log it before the json line

#

so see what it looks like

hardy vector
#

how do you git ignore a config.json file cos i want to put my bot code on github

#

is that even possible

quartz kindle
#

just add your config.json to your gitignore file

hardy vector
#

how do you do that

dusky marsh
#

google

hardy vector
#

k

quartz kindle
#

do you have a gitignore file?

hardy vector
#

no

quartz kindle
#

then create one

hardy vector
#

k

#

k done

quartz kindle
#

its text file that has to be named .gitignore

#

now open it, and write config.json

#

and save it

hardy vector
#

k

#

ok

#

done

quartz kindle
#

thats it

#

now everytime you push your repo to github, that file will be ignored

hardy vector
#

oh

#

kew

#

o

#

k

quartz kindle
#

do you use github desktop?

hardy vector
#

no

quartz kindle
#

you use the git command line?

hardy vector
#

ye

quartz kindle
#

can you make it preview which files will be pushed?

hardy vector
#

how do you do that

quartz kindle
#

idk, i use the desktop version, it does that for you automatically

hardy vector
#

oh

quartz kindle
#

but anyway, you can make a test

#

delete your important stuff from your config.json

#

and try pushing it

#

see if your config.json is properly ignored

#

if it works and your config.json is not sent to github, put your important stuff back in it

hardy vector
#

ok

royal laurel
#

very quickly

#

will this if statement in my code

#

if (message.member.roles.has(ownerRole) || (adminRole) || (adminBotRole))

#

ownerRole, adminRole and adminBotRole are all consts

earnest phoenix
#

false?

royal laurel
#

could you tell me why?

queen needle
#
 if (command === "blackjack") {
    let a = 11;
    let card = [2, 3, 4, 5, 6, 7, 8, 9, 10, a];
    let c1 = card[Math.floor(Math.random() * card.length)];
    let c2 = card[Math.floor(Math.random() * card.length)];
    let cardtotal = c1 + c2;
    let ct = cardtotal + c1;
 await   message.channel
      .send(
        "Your cards are a " +
          c1 +
          " and a " +
          c2 +
          ", with a total of " +
          cardtotal +
          ". Do you want to hit (:white_check_mark:) or stand (:x:)?"
      )
      .then(sentMessage => {
        sentMessage.react("✅");
        sentMessage.react("❌");
        const filter = (reaction, user) => {
          return (
            ["✅", "❌"].includes(reaction.emoji.name) &&
            user.id === message.author.id
          );
        };

        sentMessage
          .awaitReactions(filter, { max: 1, time: 10000, errors: ["time"] })
          .then(collected => {
            const reaction = collected.first();

            if (reaction.emoji.name === "✅") {
              message.reply("You decided to hit your new score is " + ct);
              
            } else if (reaction.emoji.name === "❌") {
              if(cardtotal > 21){
                message.reply("You decided to stand with a score of " + cardtotal + " you lost")
              }
              message.reply("You decided to stand with a score of " + cardtotal);
            }
          })
          .catch(collected => {
            message.reply("You didn't do anything, so now the game's over.");
          });
   
      });
  }```
#

how could i make it so they can hit again

#

because right now they hit and cant hit again

cloud heart
#

Which type of actions (for a bot) can require administrator permissions ?

royal laurel
#

in what context

slender thistle
#

None

royal laurel
#

like what permissions you will need?

#

because

#

shivaco is right

cloud heart
#

I just saw that admin perms are prohibited

royal laurel
#

you dont need any

#

i dont think

cloud heart
#

But a few bots are declined because they need admin perms

#

So

#

I ask to avoid mistakes

royal laurel
#

k

#

well

#

i mean

#

if a mod has come up to u and said that you dont need any perms

#

than hes prob right

vale escarp
#

Does anyone know if there's a way to dynamically subscribe to new messages in guilds? Parsing every single message in every guild is quite expensive

earnest phoenix
#

I see a lot of bots getting declined because they have certain web search function, which could be misused for nsfw. In my case I have made a bot in the queue with which you can add any number of wikis to an server. Is that any reason to be declined?

white anvil
#

wikis as in from wikipedia?

#

i think they have nsfw images in there for some specific wikis lol

#

or at least used to

earnest phoenix
white anvil
#

idk lol

#

depends if they accept wikis that contain a lot of nsfw content i guess

earnest phoenix
#

So yeah, I have no influence on which wikis people add

quartz kindle
#

can the wikis be directly searched by users with no setup? if yes, should be nsfw only
the wikis need to be explicitly enabled by admins before users are able to search them? if yes, should be fine

earnest phoenix
#

Yeah, only the owner of a server is able to add and remove wikis

white anvil
#

thats fine then

quartz kindle
#

then i dont see why not

#

should be fine

earnest phoenix
#

Okay 🙂

white anvil
#

i have a rlly edge case where my bot can screenshot websites

#

and it uses cf to clock nsfw content but ofc it isnt perfect

#

im yet to find a nsfw site that isnt blocked but it can happen someday

limber flume
#

@brave thorn How To Show How Many Servers The Bot Is In IN Python

pale vessel
#

Have You Tried Reading The Docs

royal laurel
#

could anyone help

pale vessel
#

Just Ask

royal laurel
#

ive got an error with my bot

rain mauve
#

hey guys , i reached 75 server
i sent a id cart but it didn't works

when i want to verify it again he says

royal laurel
#

rn im trying to make a role coammdn

#

how it will work

#

specified roles will be able to use the bot to grant role

#

obv not like admkns grant people owner

#

but

#

i keep getting an error

#

the error is

rain mauve
#

@pale vessel whats the problem

royal laurel
#

TypeError: Cannot read property 'first' of undefined

#

ive got my code here

#

then you will be able to see where the error points too

#
            if(args[2] == "admin")
            {
                if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminBotRole)))
                {
                    message.mentions.members.first().roles.add(adminRole)
                }
            }
            if(args[2] == "moderator")
            {    if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminRole) || (member.roles.cache.has(adminBotRole))))
                    {
                        message.mentions.members.first().roles.add(moderatorRole)
                    }
            }
            if(args[2] == "trial")
            {
                if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminRole) || (member.roles.cache.has(adminBotRole) || (member.roles.cache.has.add(moderatorRole)))))
                {
                    message.mentions.members.first().roles.add(trialModRole)
                }

            }
            if(args[2] == "tester")
            {
                if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminRole) || (member.roles.cache.has(adminBotRole) || (member.roles.cache.has.apply(moderatorRole) || (member.roles.cache.has(trialModRole))))))
                {
                    message.mentions.members.first().roles.add(testerRole)
                }
            }
#

any

#

anyone?

quartz kindle
#

mentions.member is not a thing

#

mentions.members*

royal laurel
#

ohhh

#

i see

#

its supposed to be message.mentions.members.first()

quartz kindle
#

yes

royal laurel
#

now the role comand doesnt output anything :\

#

lol

#

im tired af

#

ill fix tmrw

wind snow
#

if anyones intrested

slender thistle
maiden mauve
#

Epoch time continues to increase in numerical value right

#

so a statement like
if(time1 < 1588367795)
would accurately represent before/after?

#

assuming time1 is an epoch value as well

earnest phoenix
#

Hello, 14 hours my bot is closed, not working.

1 | shard | Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.

I get the error, anybody know about it?
14k servers - 900k users

wind snow
#

@slender thistle then what do you call it when you make a bot public

slender thistle
#

Listing it

quartz kindle
#

@wind snow to clarify a few points:
top.gg is not a hosting service, they do not host bots, they just list them. All bot owners need to provide their own hosting service or host it somewhere.
top.gg is a place for public bots, so if your bot is supposed to be used only in your server, not point for it being public.
and honestly, i dont think $5 would be enough, even for a simple job like that

#

sure some people might do it even for free, but a quality developer with some experience will likely charge more than that

maiden mauve
#

Even if they had a template to start something basic

#

I'd valuate a "custom bot" at $50 minimum assuming debugging and being asked to do this and that

#

More rewarding to spend a few weeks learning and be able to do whatever you want

quartz kindle
#

also there is an issue with the role logic

#

afaik the current role limit is 250

#

so with enough players having a unique number of wins, you would reach that limit eventually

slender thistle
#

Yep, the role limit is 250

maiden mauve
#

this is about to go down

#

😄

#

updates are exciting

quartz kindle
#

updates are scary when your shit breaks

mossy vine
#

are you completely resetting your bots db?

maiden mauve
#

lol I think I've poked the djs11/12 syntax enough

#

tired of 2 different schemas overwriting each other

#

Well, I'm gonna delete anyone inactive

#

give anyone thats played recently a new profile

#

I think of 1000ish players in the db maybe 32 are active?

quartz kindle
#

lel

mossy vine
#

honestly, a complete reset of progress would cause me to not invest further time and energy, because there is no guarantee of it not happening again

maiden mauve
#

Yeah its a morale dinger for some

#

but the "old version" of my game had way too much grinding attrition

#

of evrey server it went to, eventually only 2-3 people played

quartz kindle
#

i have almost 20k user-generated db entries, many of which have been abandoned for maybe 2 years lol

#

nope

maiden mauve
#

actually speaking of paying stuff

#

I found a number of useful artists on fiverr

#

paid a guy $20 for 20 discord emojis of respectable quality

#

that's about as cheap as I've ever seen labor

mossy vine
#

damn

maiden mauve
#

for "pixel art" anyhow 😉

#

no vector drawing nasa emojis

quartz kindle
#

damn thats cheap af

#

poor artist

mossy vine
#

tbh if i need pixel art i would do it myself

#

but discords compression is like hahahahahahahahahahahahahahahhagaahahahahahah fuck you

maiden mauve
#

I consider myself capable of doing pixel art but some people are much better at shading

mossy vine
#

discord just kills pixel art

maiden mauve
#

for example

#

that was the sketch of "red cape" he gave me

mossy vine
#

ye that looks nice

maiden mauve
#

to me that is worth $1

#

all day

quartz kindle
#

downscale it to 32x32 in photoshop before uploading to discord

#

then it will be 1:1 scale

mossy vine
#

i upscale 16x/32x to 512x lul

maiden mauve
#

I think that's the best part of pixels is that they always downscale well

quartz kindle
#

then discord downscales it back and screws it

#

xD

mossy vine
#

yes but 32x looks even shittier somehow

quartz kindle
#

idk, last time i uploaded a 32x32 emoji, it looked exactly like it did in photoshop

#

aka, nice and sharp

maiden mauve
#

a 32x32 png should be identical

mossy vine
#

aseprite > *

quartz kindle
#

run it through pngquant before uploading

#

to help lessen the load on discord's servers

#

:^)

mossy vine
#

wouldnt pngcrush work too?

quartz kindle
#

sure

#

i simply use FileOptimizer, which runs it through like 10+ compressors lmao

mossy vine
#

mm dank asset pipeline here
16x16 aseprite image -> upscaled to 32x32 -> pngcrush/pngquant -> dicksword

maiden mauve
#

on an unrelated topic

#

what are some popular ways to deal with command spam?

#

behind the curtain ignoring?

#

messages to tell them they have a CD?

#

I was doing this for awhile

astral yoke
#

so i have this error right

#
    at Server.setupListenHandle [as _listen2] (net.js:1270:14)
    at listenInCluster (net.js:1318:12)
    at Server.listen (net.js:1405:7)
    at Function.listen (/rbd/pnpm-volume/8026e4ea-29c1-4714-8479-5e7241f9946b/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/app/src/index.js:6:5)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 3000 }```
#

and this is where it's erroring

#
var app = express();
app.get("/", (request, response) => {
  response.sendStatus(200);
})
app.listen(process.env.PORT)```
#

so why is this happening and how do i fix it

maiden mauve
#

well quite literally it seems the port your using is in use?

#

has this worked before?

astral yoke
#

indeed it has worked before

maiden mauve
#

I'm not familiar with express syntax but all I can imagine is you have 2 instances of the bot open

#

or something else is using the port

astral yoke
#

ohhh

#

i think i see

#

yeah i see fs

#

ty

earnest phoenix
#

can anyone give me some cool idea about Dashboard

grizzled raven
#

excuse my horrible logging skills imcool

queen needle
#

so ^eval message.channel.send(client.emojis.cache.first(20)) would give me the first 20 emojis but is there anyway i could just get the 20th

amber fractal
#

turn it into an array then index it

sudden geyser
#

Two ways are turning it into an array and accessing the index 20 or using the find function and checking the index to be 20th.

blissful karma
#

Help?
{
“name”: “greeter-bot”,
“version”: “1.0.0”,
“description”: “proyect”,
“main”: “bot.js”,
“author”: “MejoreXs”,
“dependencies”: {}

pale vessel
#

just send the whole package.json

earnest phoenix
#

so... i have def. prefix defined in index and what so. but i need help making a command that when you ping it, it returns default (k/) if no prefix is set in a json.. so far i have it able to send it when it is changed but when its default is the issue.

smoky cedar
#

guild.members.cache.filter(member => member.user.presence.status === "online").size

Its not showing the correct numbers of online members.

earnest phoenix
#

what version of js? 12?

#

if its js

smoky cedar
#

v12

#

js

earnest phoenix
#

did you use message?

smoky cedar
#

yes

earnest phoenix
#

presuming you wish for a certain guild?

smoky cedar
#

ye

#

for the guild there is using the command

earnest phoenix
#

message.guild.members.cache.filter(member => member.user.presence.status === "online").size
?

smoky cedar
#

yes

earnest phoenix
#

what are you getting?

smoky cedar
#

its showing 31 when there is 120

earnest phoenix
#

ah..

#

how many are Dnd

#

since thats different

stable nimbus
#

So I am trying to create a /me command for my bot, and I am not sure exactly what to do, I did however get it to do what I want and take the message content and put it into an embed, but I want it to disregard the command prefix (which in this case is //me because discord already has a /me function and wouldn't work with my bot).

var embed = new RichEmbed()
.setTitle('In Game Action!')
.setColor('#a1ee33')
.setDescription(<@${message.author.id}> + ': ' + message.content)
message.delete()
message.channel.send(embed)
break;
This is my current code.

smoky cedar
#

@earnest phoenix Can you mix all there is not "offline" togehter?

earnest phoenix
#

uh....

smoky cedar
#

Like "online, dnd, idle" in one number

earnest phoenix
#

hmm i supose you could make.it hard and make it like a math... and add it if you dont want OFFLINE to show

smoky cedar
#

But i thinked it could count like discord does?

earnest phoenix
#

not sure..

smoky cedar
#

ONLINE--122

#

Like that

#

Taking that number of everyones not offline

earnest phoenix
#

what you can do

smoky cedar
#

?

earnest phoenix
#

one sec

#

message.guild.members.cache.size - message.guild.members.cache.filter(member => member.user.presence.status === "invisible").size

#

try that?

#

lemme recheck

#

should be accurate

smoky cedar
#

What should that do

earnest phoenix
#

it will get all members and subtract all invisible (offline) members

smoky cedar
#

Noo

#

Its 30 and when i type again its 300

#

and new numbe

#

and etc.

earnest phoenix
#

300?

smoky cedar
#

260

earnest phoenix
#

send the code line?

#

message.guild.members.cache.size-message.guild.members.cache.filter(member => member.user.presence.status === "offline").size

white anvil
#

@blissful karma ur using the wrong "s

earnest phoenix
#

try that above ^^@smoky cedar

smoky cedar
#

okay

#

Working thanks!

earnest phoenix
#

yw!

blissful karma
#

@blissful karma ur using the wrong "s
@white anvil which is the correct one?

white anvil
#

what device did u write this package on

blissful karma
#

txt

lyric mountain
#

@blissful karma I'd change ur name before it's too late

#

Also, download notepad++ at least

blissful karma
#

notepad++ it's the solution?

lyric mountain
#

No

#

But it'll save u some hassle later on

#

See if it gives u some error

#

That doesn't look like a normal "

abstract crow
#

When you guys use a DB and make a connection in JS, do you store it in like client.xyz?

lyric mountain
#

That's json

#

If you use a db you'll need queries

abstract crow
#

Because if I want to do that, such as

(async () => {
    try {
        const result = await mysql.createConnection({
            host: process.env.DB_IP,
            user: process.env.DB_USER,
            password: process.env.DB_PASS,
            database: process.env.DB_NAME,
        });
        client.con = result;
        // The rest of the index.js file inside of here
    } catch(e) {
        console.error("DB ERROR: " + e);
    };
console.log(client.con);

``` I need to put all of my code inside that try statement
lyric mountain
#

Unless it's an object db

#

That'll save your connection as con parameter of client

abstract crow
#

Right

lyric mountain
#

Afterwards u just need to retrieve it to create queries

abstract crow
#

I know what it does, but in order for client.con to save globally, I need all of my code inside the try statement

lyric mountain
#

No you don't

blissful karma
abstract crow
#

console.log(client.con); doesn't work

#

Because client.con is undefined

quartz kindle
#

its undefined because its an async function

#

and you're trying to access it from sync

lyric mountain
#

Because you're printing before it's set

white anvil
#

@blissful karma use these quotes " everywhere

#

the ones u use are weird fancy ones that json doesnt support

#

it needs to be the straight ones

abstract crow
#

So do I .then() of the async function?

lyric mountain
#

Yes

quartz kindle
#

just put the console.log inside it

#

and it will work lol

abstract crow
#

And put the rest of my index.js file inside of the .then?

quartz kindle
#

no

lyric mountain
#

Also, it'd be better if u run that code BEFORE you start your bot

#

Like, store the connection as a sole variable

abstract crow
#

That's my main index.js file

lyric mountain
#

You might run into issues later on if your bot starts before your db connects

abstract crow
#

I mean I put the connection before client.login

quartz kindle
#

the reason your console.log is returning undefined is that all code inside an async function has a bit of delay to complete, but this delay does not block the rest of your code, so your console.log is executed before the async function is finished

abstract crow
#

Ah gotcha

#

So then I thought I would put all my code inside the .then for it to work

lyric mountain
#

Just dont bro

abstract crow
#

Then how am I gonna wait on that to finish

lyric mountain
#

Put only the login inside .then

quartz kindle
#

you dont need to, because the discord client also takes a while to initialize, and by the time the client is ready, that async function already finished a long time ago

lyric mountain
#

Or that

abstract crow
#

Ooooooooh @lyric mountain

#

Honestly, I just want to do this the same way bigger developers do it

#

I want to learn the right way

#

So if that is to .login inside the .then so be it

lyric mountain
#

That's the right spirit

#

Actually, kudos to you for even trying db as first persistence method

quartz kindle
#

if you're gonna use .then, you dont need the async function lol

lyric mountain
#

Most just go to json as it's the easier path

#

@quartz kindle the connection is an async method afaik

abstract crow
#

Thanks. I mean I've done D.JS for about a year now and I'm working with someone and this came up

#

I always used promise-mysql, then put ALL my code inside the .then

#

Now I use mysql2

lyric mountain
#

You just need to pay attention to code flow

abstract crow
#

This is my first bot that is extremely organized so

#

Gotcha

lyric mountain
#

Also, one thing I HEAVILY recommend u is to make a global functions file

#

For example

#

Let's say you use doSomeMath() in a lot of places in your code

#

Instead of declaring it everywhere, you could put it inside a file, export it and call it in other places

abstract crow
#

Yeah I'm doing that with my dbqueries

lyric mountain
#

This way you'll have a more organized code, probably a lighter one and debugging will be a cake

abstract crow
#

I make a function for getting user's data, etc. Then this is also my first time I am actually storing mysql data in the client. For example, I will map everything I need to in the client. Then for things that change, such as a user's points, a guild's config, etc, I just have to updated both the map and the DB

low wasp
lyric mountain
#

Why bowsie lol

abstract crow
#

That way if all I am doing is checking a user's points, checking a config, etc, it doesn't query

#

lol bowser

low wasp
#

lol

abstract crow
#

Heres mine

#
  • indexFake. Last night bud and I were up until 2am trying to figure this shit out
lyric mountain
#

Nice

#

It's almost a MVC model

abstract crow
#

Would make sense haha

lyric mountain
#

I must say, you have a great future in development

abstract crow
#

Thank you!

lyric mountain
#

Consider yourself one of the top 30% bot devs

low wasp
lyric mountain
#

Bowsie, I'll still beat that doggo

abstract crow
#

I appreciate it! I'm 15 and hoping to get a career in the future that I'll enjoy

#

I'm probs gonna go with web dev

earnest phoenix
lyric mountain
#

So, the only thing i see there is you sending the stored prefix

earnest phoenix
#

right... but id like to send default if no stored prefox is there

lyric mountain
#

You could just do prefix === undefined ? "k/" : prefix

#

Or just do an if else clause

earnest phoenix
#

i did attempt an if else but always messup when i get an error:
cannot read prefixes of undefined

lyric mountain
#

You've checked it wrong then

#

Because prefixes IS undefined if the require failed

lapis ocean
#

@turbid bough hey, can you believe I made a bot myself already and it already generates a link with the query parameters when the user joins

stable nimbus
#

The Error

(node:12276) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
The Code
case 'me': {
if(!args.length) {
var emebd = new RichEmbed()
.setTitle('⚠️ Error in: User Arguments')
.setColor(0xFF0000)
.setDescription("You didn't provide any arguments, so I can't send the message you wanted me to, sorry!")
message.delete();
message.channel.send(embed)
} else {
var embed = new RichEmbed()
.setTitle('In Game Action!')
.setColor('#a1ee33')
.setDescription(<@${message.author.id}> + ': ' + \n ${args})
message.delete();
message.channel.send(embed)
}
break;
}
I don't know why its saying the message is empty however....

lyric mountain
#

@stable nimbus you've written emebd

#

Third line

stable nimbus
#

I want to put it in an embed is the deal. I don't want it outside of the embed.

lyric mountain
#

Third line dude

pale vessel
#

emebd

lyric mountain
#

You're sending embed, but declared emebd

stable nimbus
#

Oh.

#

My brain.

#

Thank you....

lyric mountain
#

Brain 404

stable nimbus
#

EXACTLY!

lyric mountain
#

Lol you're welcome

stable nimbus
#

It works now.... damnit.... The struggles of Coding, mess up on one thing and THERE GOES THE PROGRESS!

west spoke
stable nimbus
#

Now I just gotta figure the next problem out, how tf do I get rid of the commas? Because I followed a tutorial for this one and it didn't mention how to get rid of the commas for my user args.

lyric mountain
#

@stable nimbus I'd recommend intellij

#

But only ultimate edition has JS support

#

It does help u find a lot of hidden or overlooked issues

stable nimbus
#

I use VSC, and its nice. I need to send it as an array instead of a string though.

lyric mountain
#

Gl

high bough
magic jackal
#

Can anyone assist me with Samba on Ubuntu?

copper cradle
#

the only thing wrong in that image it the white theme

lapis ocean
#

I am a bit confused with "guildMember.roles.set([])", how do I use it if I have the username of the user?

#

I am reading documentation and it uses methods that depend on the user either being mentioned or sending a message

#

I just want to add a role from the username

copper cradle
#

you fetch the user

#

and get an user object from there

#

don't post dots for fucks sake

smoky spire
#

you use <guild>.members.cache.find, you can't fetch with a username

magic jackal
#

@bitter sundial Hey mate, can you join voice for a moment if you're here? I have a few samba questions.

viscid goblet
#
        global codes
        global role
        codes = []
        if message.content.find("$addcode ") != -1:
            if message.author == message.guild.owner:
                arg = message.content.split(' ')
                codes.append(arg[1])
                role = arg[2]
            else:
                await message.channel.send("You are not the owner")
        if message.content.find("$code ") != -1:
            arg = message.content.split(' ')
            if arg[1] in codes:
                codes.remove(arg[1])
                await message.author.add_roles(role)
                await message.channel.send("Code accepted!")
            else:
                await message.channel.send("Code does not exist")

that is part of the code for my join codes bot
i wanted new server members to be able to claim a few hours of ranks when they join but
$addcode works properly
$code keeps saying that the codes added with $addcode dont exist
to see if $addcode was the problem i added a print(codes) function after it adds the code

lapis ocean
#

@copper cradle @smoky spire any example code that I can see?

smoky spire
#

<guild>.members.cache.find(member => member.user.username === 'nameHere');

copper cradle
#

tbh ..username should be renamed to name

#

unless the user object has a name property already

#

other than that it's very redundant

smoky spire
#

but it's called a username

viscid goblet
#

are u trying to find a specific member by name?

copper cradle
#

yes

viscid goblet
#

if ur doing python i can help

smoky spire
#

but if you don't call ur user var "user" than that doesn't work

copper cradle
#

the dude asking the question was using js

smoky spire
#

Also just name could be confused between nickname and username for new devs

copper cradle
#

¯_(ツ)_/¯

lapis ocean
#

Sorry guys, maybe it's better I ask in the DiscordJS server

copper cradle
#

what did you try?

viscid goblet
#

i think it would be the same
put all members in list
loop through that list and check wether the name matches the one your looking for
in python:

members = message.guild.members
for x in members
    if x.name == name:
        do whatever
copper cradle
#

David show the code you have

viscid goblet
#

ik ur using JS but i cannot do loops in JS

copper cradle
#

and any the error log if you're getting one

lapis ocean
#

I don't have any code for this function @copper cradle

copper cradle
#

the logic is the same

#

what do you mean then

smoky spire
#

I gave you an example david

copper cradle
#

how come you don't have code

#

if keenser gave you pseudo code

viscid goblet
#

im not sure why u need the member name try finding by member object

copper cradle
#

huh

#

they're trying to find a member by its name

#

they could filter it tho

#

wait

smoky spire
#

filter returns more than one result

copper cradle
#

that's what I was gonna say

lapis ocean
#

@copper cradle I'm not even sure how to start implementing, I'm processing the info

#
#

But I didn't implement that yet

viscid goblet
#

i think it would be the same
put all members in list
loop through that list and check wether the name matches the one your looking for
in python:

members = message.guild.members
for x in members
if x.name == name:
do whatever

this is the python code
im sure its the same principle
create list with all member objects
loop through that list and check if name matches
lapis ocean
#

@viscid goblet are you talking about what I asked?

#

There's no way to just refer to the userid ?

#

I thought this would be easier

viscid goblet
#

yes there is

earnest phoenix
#

if you don't know where and how to implement that piece of code it's maybe a sign you should backtrack and learn a bit about programming and the language you're working with

lapis ocean
#

I have User#1234, this is not enough? I have to search for the user by creating some list? sorry guys a bit lost here

viscid goblet
#

the member object contains most info about member: name, tag, id and mention

#

dude this is code for creting list

members = message.guild.members
lapis ocean
#

Can you explain the logic to me step by step? So

pale vessel
#

do you need the author id? blind

lapis ocean
#

The way to do this is to create a list of all members right?

pale vessel
#

can you explain what you're trying to do?

lapis ocean
#

Give a role to a member from a command

#

For example, !member User#1234

pale vessel
#

find the member

viscid goblet
#

i gave u the list code then u need to use loop code

for x in members
    if x.name or x.id == name or id:
        do whatever
pale vessel
#

you don't really need that if you're looking for a specific member

lapis ocean
#

But you guys lose me completely when you say find the member

pale vessel
#

get the guild

#

and fetch the members from that guild

viscid goblet
#

do not use both use if x.name == name: or if x.id == id:

pale vessel
#

you can use methods such as .find or .get

lapis ocean
#

Again, I will ask because I am confused. The way to do this is create a list of members?

#

and then I have to find the member that has that user id right?

pale vessel
#

you might want to learn basic javascript and read discord.js documentation

viscid goblet
#

so u want to know how to add a role to message author?

lapis ocean
#

@north crane I think my challenge now is referencing a user from a userid

#

But ok, I will try some stuff now

viscid goblet
#

two options: A) use my bot verify (ive made this code before) B) message.author.add_roles(role)

lapis ocean
#

I don't want to get it from the author

#

I want to get it from a command!

#

!member User#1234

viscid goblet
#

ok so ur command is !member @ user

lapis ocean
#

Yes

#

It should give a Role to the user which is referred

viscid goblet
#

u will need to account for args so here help with that

if message.content.find("!member ") != -1:
    arg = message.content.split(' ')
lapis ocean
#

Let me start with that

viscid goblet
#

now do u think you know how to get the member from the first argument

lapis ocean
#

I think that's exactly the part I am most lost with

viscid goblet
#

dude thats the easiest part member = arg[1]

lapis ocean
#

You mean that..., that yeah I could figure out

viscid goblet
#

member is your user and it takes that from the first argument (arg[1])

lapis ocean
#

It creates a list right? So yeah.

viscid goblet
#

arg is your list

lapis ocean
#

Split on spaces, nice.

viscid goblet
#

arg is the list of arguments included with the command

#

however this means u can use a command inside a message

lapis ocean
#

Sounds good, not a problem

viscid goblet
#

like
hello im gonna do !member @ user

#

the command would still work

lapis ocean
#

I see, but not so worried about it.

viscid goblet
#

ok

lapis ocean
#

I could fine tune it later.

#

Really just wanted to get the bulk of it working.

viscid goblet
#

now u need to actually give the role
the function for this is add_roles(role)

lapis ocean
#

But just wait a second

#

Is this python?

viscid goblet
#

yes

lapis ocean
#

OH ok, I am using Discord JS lol

#

I am trippin hard here now

viscid goblet
#

i tried and failed making bots with JS so i switched to python cos ive used for 2 years

lapis ocean
#

My bot is almost finished

#

Just need this part

viscid goblet
#

yeah what role do u want to assign to the user (I assume the member role)

lapis ocean
#

Yes, I want to assing a role called Member

#

It's part of a whole workflow

#

People signup on a form, the form sends a webhook to discord, the bot should grab that webhook and assign a role to a member

#

I already did the whole thing

viscid goblet
#

if u didnt define the role earlier i REALLY hope i have some old Verify code on my system

lapis ocean
#

So registered users get the role automatically

viscid goblet
#

yeah i dont BRB

lapis ocean
#

I learned a bit of python in the past

#

So that's why your code was sounding very right

viscid goblet
#

ok i hope this works

roles = message.guild.roles
for x in roles
    if x.name == "Member" or "member":
        role = x
await member.add_roles(role)
lapis ocean
#

But this is python right?

viscid goblet
#

yes

lapis ocean
#

I understand it, not sure if I can translate it though

viscid goblet
#

in case u need, heres how u do post requests in python

import request
#add to top ^
a = request.post(url, content)
#

i have my own bot to fix

#

make that two bots a bunch of people have been DMing me about my free nitro generator not working for them but i tried and it worked perfecty

lapis ocean
#

Tough shit

lyric mountain
#

@lapis ocean why do you need to send 'n catch a webhook?

lapis ocean
#

Because I want to give people that signup on a form get a role automatically @lyric mountain

lyric mountain
#

Sure but, the bot that'll send a form is the same bot that'll give the role, right?

#

?

lapis ocean
#

What do you mean "send a form" ?

#

It's a webform

#

The bot gives a link to the form.

lyric mountain
#

So, why don't you just create a webserver and send the data there?

#

Then listen to requests made to it and give the role directly

lapis ocean
#

Because that sounds like I have to build a universe from scratch

lyric mountain
#

Using webhooks would be very iffy, since you can't detect which user is a wh and which is a real bot

#

No you don't

#

2 min setup with express

lapis ocean
#

I have everything working already, a website a form, everything integrated with each other

#

You telling me I would need a new form, maybe coded from scratch or something?

lyric mountain
#

No

#

Just install a webserver in ur bot

#

And send the data there

lapis ocean
#

AS a webhook?

#

My form system has webhooks working

lyric mountain
#

As a http request

lapis ocean
#

Yeah, I would have to build my own form system or use another solution that doesn't have the same integrations

lyric mountain
#

Oh my

#

Ok then, what's ur issue?

lapis ocean
#

Just not figuring out clearly how to give a role to a user

#

I'm using Discord JS

#

Diamond already gave me some hints using python

lyric mountain
#

Have you read the docs?

lapis ocean
#

I've skimmed :eyeroll:

lyric mountain
lapis ocean
#

I've read that @lyric mountain , but not sure how to implement due to low IQz or something

lyric mountain
#

guild.member.roles.set

#

Guild can be gotten from the message object

#

The message object is returned from onMessage event

lapis ocean
#

message object?

#

But what if the user doens't send a message?

#

I wanted to do a command like !member User#1234

lyric mountain
#

Aren't you getting user id on the form?

lapis ocean
#

Yes, actually I am getting user.tag

lyric mountain
#

No

#

User ID

#

Tag can be changed

lapis ocean
#

really?

lyric mountain
#

Never ever use it for checking

lapis ocean
#

But it's almost in real time

lyric mountain
#

The tag will change if you change ur name or number

#

Believe me

lapis ocean
#

I believe you

lyric mountain
#

If it can break, it WILL break

#

Users are dumb

#

More than u think

lapis ocean
#

Isn't that murphy's law or something?

#

LOL

#

The users are very removed from the process

lyric mountain
#

Like, just get the id from the mention

lapis ocean
#

Hence why I built it this way, my other solution relied on users typing in their own user IDs

lyric mountain
#

Then use it for user manipulation

#

The mention is a user object

#

You can get the id from it

lapis ocean
#

Which mention? The mention generated by the command?

lyric mountain
#

@lapis ocean <--- user object

lapis ocean
#

The problem is that if I asked for a Userid on the form I don't have a manual fall back

#

Where in case the bot doesn't work or isn't compatible with some feature at least the user could input their ID manually

#

User IDs are already complicated enough on Discord

lyric mountain
#

Well, that looks like a job for an oAuth2 login

#

They aren't

lapis ocean
#

Yeah, but that's more complicated, I just have a form really

lyric mountain
#

User ids are as simple as it can get

lapis ocean
#

They are not user friendly

#

That's what I mean.

lyric mountain
#

They are

#

How can it get more simple?

lapis ocean
#

Ok, I am not trying to argue with you.

lyric mountain
#

A number = a user

lapis ocean
#

Easy

#

ID = Email

lyric mountain
#

Email is complicated

lapis ocean
#

ID doesn't have any #09348

#

Everyone remembers their email, that's my point. That's what complicates this

#

On form submission the user submit their email anyway

#

But this is all beyond the point.

lyric mountain
#

You're trying to reinvent the wheel, the user doesn't need to know their ID

astral yoke
#

if i have this

lyric mountain
#

Just put a GET param on the form url

#

Simple

lapis ocean
#

Ok, I have realized the best way to do this is to not force the user to get to know his ID or even User Tag

lyric mountain
lapis ocean
#

That's what I do

#

What did you think I was doing?

lyric mountain
#

Then what's the issue?

#

You already have the id

lapis ocean
#

I mean, I do that except I do it with tags

#

Maybe I should do it with the userid

lyric mountain
#

Dude

#

Forget the tags

#

Mkay?

lapis ocean
#

Ok, it's bad right?

abstract crow
#

If I wanted to store DB rows in a variable should I use maps or is there another approach? I hate having to do .get("rowName");. I'd rather just do .rowName like a regular query