#development

1 messages · Page 1476 of 1

umbral zealot
#

like, related to code

earnest phoenix
#

Excuse me?

eternal osprey
earnest phoenix
#

Did anyone asked for your opinion?

odd stratus
#

Hey, say for every level I want it to double by 2, for example: Level 1 requires 50 XP, Level 2 requires 100 XP, Level 3 requires 200 XP. How would I do that?

Right now, it would just goes like this: Level 1: 50 XP, Level 2: 100 XP, Level 3: 150 XP

earnest phoenix
#

did someone?

eternal osprey
earnest phoenix
#

I Forgot To Laugh

umbral zealot
#

or exponent or soemthing

#

I dunno I'm super bad at math 😂

eternal osprey
#

so grab your middle finger, put your hand on its back and shove it up right up ya arse!

earnest phoenix
#

Get a better pfp, google pfp user

eternal osprey
#

and you call me childish

earnest phoenix
#

i never said that

eternal osprey
#

thousands of stolen accounts

#

childish

earnest phoenix
#

Arent You the guy who uses pic from google? "stolen"

lyric mountain
#

Dude, I know it's possible because I've already tried to do that

earnest phoenix
#

even your frickin pfp is from google

lyric mountain
#

But it's still illegal and against ToS

eternal osprey
lyric mountain
#

Ah, wait

#

Yeah, log scale

eternal osprey
#

sorry i actually changed my code

#
 collector.on('collect', (reaction, user) => {
                 message.channel.send("Okay, the cart is being cleared!")
                 console.log(filtered)
                var cleared =  allItems.splice(filtered, ' ')
                fs.appendFileSync("./cart.txt", cleared)
              });````
#

so it should indeed remove these from the allitems, but it's not.

lyric mountain
#

This would work

cinder patio
#

array.splice accepts an index at which to start deleting elements and the amount of elements to get deleted

#

both of your arguments should be numbers - but your first is an array and your second is a string

earnest phoenix
eternal osprey
#

as it changes for everyone.

#

for one, it might be 3, for someone else it might be 12

molten yarrow
eternal osprey
#

that would return me an amount?

molten yarrow
eternal osprey
#

Ah germany, love that country!

#

hmm okay

molten yarrow
#

and if you have the index you can use .splice() to remove the items

cinder patio
#

I suggest ditching the text database.

#

it's such a mess

sterile lantern
#

it's an array

misty star
#

Oiii

cinder patio
#

that is saved to a text file

sterile lantern
#

i mean, it's only a couple of values

eternal osprey
#

so i would have to do filtered.indexOf("what should be here"?)

sterile lantern
#

i don't see a need of making a different type of DB for it

molten yarrow
cinder patio
#

It's a couple of values right now...

eternal osprey
eternal osprey
sterile lantern
#

mhm but if it's like "James", "Test" it's fine

molten yarrow
eternal osprey
sterile lantern
#

o

#

really?

#

never knew that

#

well i use sqlite

molten yarrow
cinder patio
#

Honestly - there are better ways to learn about arrays than this, lmao

eternal osprey
#

just making it for myself.

#
const cleared =  allItems.indexOf(filtered)
                console.log(cleared)```` this btw returned -1.
opal plank
#

no

#

no var

eternal osprey
#

idk if that's supposed to happen

cinder patio
#

If it returns -1 then it doesn't exist

molten yarrow
#

-1 means it doesnt exist

eternal osprey
#

okay that's hot.

molten yarrow
#

what is filtered?

eternal osprey
#

this:

opal plank
#

a variable

misty sigil
#

{$add: {b: {w: 1}}} would this valid (mongodb updateOne)

eternal osprey
lusty quest
#

try and see if it works

eternal osprey
misty sigil
#

i was just gonna make sure before tryin it

#

but oh well lets just go ahead and bonk

lusty quest
#

well this is development in a nutshell

mellow kelp
#

yes

eternal osprey
opal plank
#

this is interesting

misty sigil
#

genshin dying

opal plank
#

i was not expecting it to dip this fast after the update came out

lusty quest
#

or servers with 50+ Bots are forced to remove some

#

meanwhile my bot stuck at 300. even with advertising

opal plank
#

i think you just cant add anymore, dont think you HAVE to remove some

#

it'd be dumb

eternal osprey
#

as they are clearly there.

opal plank
#

ucz its intended?

#

case insensitive?

#

use regex instead?

#

theres plenty of thing that could be happening

cinder patio
eternal osprey
#

yeah

cinder patio
#

Are you sure? Show me how you declare filtered

molten yarrow
#

.indexOf() needs a string, like the name you search in your array

cinder patio
#

it doesn't need a string

opal plank
molten yarrow
#

it does in his case

opal plank
#

regex can also be accepted

#

which is what i recommended, case insensitive is a better match

#

or toLowerCase() first then search

eternal osprey
opal plank
#

though i doubt that'd be the issue

eternal osprey
#
allItems = fs.readFileSync("./cart.txt", "utf8").split("\n").map(x => x.split(/ +/))
console.log(allItems)
let filtered = allItems.filter(x => x[0] === message.author.id)
let final = filtered.map(x => x[1]).join("\n")  ```all the variables used.
cinder patio
#

filtered isn't really in allItems.

#

See the image. When you store an array of arrays, you are basically storing the "references" to those arrays.

eternal osprey
#

owh okay i understand that

cinder patio
#

[1, 1] === [1, 1] is false.

#
arr === arr``` 
is true
#

This is why a text database is a mess, it's hard to write, it's hard to read, it's hard to update, it's hard to delete and it's prone to corruption. I don't know why you're torturing yourself, but imho you are wasting your time.

opal plank
#

PostgreSQL

Is there a way to retrieve all PRIMARY_KEYS under a table?

eternal osprey
#

yeah but i already started and am almost done with this code.

#

i can't just throw my progress of the day away

opal plank
#

Feud is right about that

eternal osprey
#

yeah you guys are right about that

lyric mountain
opal plank
#

that doesnt help

lyric mountain
#

Isn't there something like SELECT PRIMARY KEY FROM table?

opal plank
#

nope

#

schemas or tables are under its own table

cinder patio
#

did you google it

opal plank
#

i did, though some of the queries are bound for a whole schema/db

#

im trying to fetch a specific table with the types + contraints

lyric mountain
#

Anyway, why do you need to do such thing?

opal plank
#

but JOIN also doesnt have the same shape, so i cant merge them into a query

lyric mountain
#

What are u trying to achieve?

opal plank
#

Improving this

#

Ts dynamic type generation on schemas/tables

mellow kelp
#

magik

lyric mountain
#

Sorry, no images for me

#

I've disabled them to preserve mobile data

opal plank
#

well, i explained it anyway

earnest phoenix
#

Have you tried the one from stackoverflow?

opal plank
#

wdym tried the one from stackoverflow?

odd stratus
earnest phoenix
#

the query

opal plank
#

WHICH query?

lyric mountain
odd stratus
#

Gives like 2 XP needed as the number

#

And apparently ^ in JavaScript isn't a thing for powers

opal plank
#

Math.pow()

mellow kelp
#

or **

odd stratus
#

I tried Math.pow() too but it seemed to give some messed up number

mellow kelp
#

both work the same way

opal plank
#

Math.ceil()

odd stratus
#

Alr I'll try **

mellow kelp
#

well its the same as math.pow

#

so if the first one doesnt work ** wont either

earnest phoenix
lyric mountain
#

Btw, define "messed up numbers"

#

Because pow will get u exactly the number to some power

opal plank
#

i need 2 JOIN queries

#

i tried this one before

#

the issue with is it is the types

earnest phoenix
#

the types?

lyric mountain
#

Oh, that formulae won't work

opal plank
#

this should give an idea of what im trying to accomplish

#

i need a query that returns, per table, the collumn, the constraints, and the types of each collumn

#

i could do 2 queries and join them in code, but i'd much rather have a single database call instead

#

actually, i noticed a flaw in that query

odd stratus
#

I tried 50 * level ** 2 but why does it go from 50 to 200? Why not 50 to 100?

eternal osprey
#

how would i remove it?

opal plank
#

.replace() ?

mellow kelp
#

50 * 1 ** 2

#

50 * 1

#

50

opal plank
#

or put it in parenthesis

mellow kelp
#

thats why i use math.pow

eternal osprey
mellow kelp
#

makes the order more clear

opal plank
#

(50 * level) ** 2

#

fixed

#

or

#

Math.pow((50 * level), 2)

earnest phoenix
#

so you don't care with it being a primary key or not?

snow urchin
#

I have a reaction collector for a function on my bot, and a simple filter allowing only the message author to make the reactions do something, but how can I have it remove someone elses reaction if its not the msg author?

cinder patio
#

Then you'd have to get rid of the filter, and in the "collect" event check if the reaction is coming from the author, and if it's not, remove the reaction

odd stratus
opal plank
#

thats what you are doing though

lyric mountain
opal plank
#

50 * level ** 2

lyric mountain
#

You'll need a log scale

opal plank
#

50 * 2 = (100)^^2 = 100 * 100 = 10k

lyric mountain
#

That formulae will scale really quick

opal plank
#

the math is right, your formula is wrong

lyric mountain
#

Wait, no

#

Not the way you explained

#

50 * level ** 2 will be Level ** 2 = result
Then 50 * result

opal plank
#

(50 * 2) ** 2 = (100) ** 2 = 100 * 100 = 10k

#

i explained it right

#

10k, as seen here

opal plank
lyric mountain
#

Ah, yes, if you put it that way

opal plank
#

i just used ^ intsead of ** to make more sense of it

lyric mountain
#

I was talking about my formula

#

It wouldn't work the way he want

#

50
200
450

odd stratus
#

God damn bruh why is this part of the code so difficult to even do mikebruh

lyric mountain
#

It's not

mellow kelp
#

getting the formula correct is kinda hard sometimes

#

like, to get something balanced

lyric mountain
#

You need to experiment different formulas

faint prism
#

Anyone see this in the Discord update?

Postulated new slash commands for bots. Performing actions with bots is easier than ever. Now, developers can have a list of commands available for their bots accessible by the slash key (/). You won’t have to remember bot commands anymore and get laughed at when you get the command wrong 😦 !help…..!help….please

cinder patio
#

yes

eternal osprey
#
allItems = fs.readFileSync("./cart.txt", "utf8").split("\n").map(x => x.split(/ +/))
console.log(allItems)
let filtered = allItems.filter(x => x[0] === message.author.id)
let final = filtered.map(x => x[1]).join("\n")
let d = allItems.filter(s => s.replace(/\s+/g, '').length !== 0)```` i am tying to remove the extra space i have in my text file.
#

s.replace is not a function

#

the outcome

#

why is this and how do i fix it?

cinder patio
#

If allItems is an array of arrays, then s would be an array, not a string

eternal osprey
#

ffs ofc. So replace wouldn't work again

#
allItems = fs.readFileSync("./cart.txt", "utf8").split("\n").map(x => x.split(/ +/))``` isn't there any other way to remove a space from this array.
opal plank
#

you should, at the VERY LEAST, keep the cart in memory rather than reading it everytime

#

its really sstupid to do it that way, regardless if you want a database or not

#

at LEAST keep it in memory

eternal osprey
#

i am not going to post the bot..

#

just for myself

opal plank
#

im aware, that doesnt change the fact

#

you said yourself you are doing this so you could learn, im teaching you NOT to corrupt your txt file

#

keep it memory and manipulate it inside

earnest phoenix
#

@opal plank primary key per table with its type, is this what you're trying to get?

eternal osprey
#

hey

#

how do i change my reaction collector to work in dm?

distant light
opal plank
#

not ONLY primary keys inside a table, but all types + primary

#

as a better example, i need something like this

eternal osprey
#
const collector = message.author.dmChannel.createReactionCollector(filter, { time: 60000 });```uhh this ain't really working.
#

message.author.dmChannel.createReactionCollector is not a function

opal plank
#

@earnest phoenix
table_name = foo

returns {
column_1 : {
type: 'int'
PRIMARY_KEY: true
}
column_2: {
type: 'charcter_varying'
PRIMARY_KEY:false
}
//all other collumns in table

}

#

the data that i need is;
input table name
retrieve type, collumn name, constraint PK and IS NULLABLE, for all collumns inside table name

#

which is what im struggling to retrieve

lyric mountain
distant light
lyric mountain
#

When you send the message, if you await it u get the message object

#

Use it to add reactions, not the message object passed to the command

opal plank
#

@earnest phoenix i got what i needed, i just need to merge them inside a single query

#

i neeed to merge them by table_name

earnest phoenix
#

oh nice, I just messed around with what I found on stackoverflow

opal plank
#

LEFT JOIN probably would be the best bet here

eternal osprey
#

anyone that can tell me how i make my reaction collector work in dm

earnest phoenix
opal plank
#

i already looked both in pg docs and stackoverflow, neither helped too much

#

there arent very use cases for this, its very rare for someoen to need to map a whole schema/table types

earnest phoenix
#

yeah xd

#

I learned something today doe, never knew what join does

opal plank
#

it joins tables basically, but its a bit complicated

distant light
opal plank
#

i usually do function joins, which is a bit more complex

lyric mountain
#

No, I recommend doing easier stuff before trying more complex commands

#

There's no shame in starting with Hello World

earnest phoenix
#

oh, so USING is the shorthand for ON if the column name is the same

eternal osprey
#

could anyone please tell me

#

how i can make my collector work in dm

lyric mountain
#

Any error?

eternal osprey
#
 const filter = (reaction, user) => {
                return reaction.emoji.name === '❌' && user.id === message.author.id;
              };
              
              const collector = cart1.createReactionCollector(filter, { time: 60000 });
              
              collector.on('collect', (reaction, user) => {
                 message.channel.send("Okay, this process has been stopped!")
              });```
#

i just don't know how to do it.

lyric mountain
#

Check the docs then

eternal osprey
#

never mentioned collecting in dm

#

i have already checked the docs

lyric mountain
#

It's the same thing

lyric mountain
#

But you can't get guild data because its not a guild

eternal osprey
#

no guild data or anything.

#

but i can't find on the web how to do it.

lyric mountain
#

What's cart1? Where are u defining it?

eternal osprey
#
const carts = new Discord.MessageEmbed()
.setColor('RANDOM')
.setTitle('**This is your checkout cart!**')
.addFields(
  { name: '**items**', value: `${final}`, inline: true },
  { name: '**Total price**', value: `${money}$`, inline: true },
)
.setDescription('**Click on the :x: if you want to stop. Click on the :white_check_mark: to proceed to checkout!**')
.setImage('https://media.giphy.com/media/3mfxyjHgjQptBZKyHX/giphy.gif')
.setTimestamp()
  .setFooter('Command hosted for you!')
  let cart1 = await message.author.send(carts);
await cart1.react(reactionEmoji2);
await cart1.react(reactionEmoji1);```
earnest phoenix
# opal plank kinda, yes

I see, so mine could've been

        SELECT c.table_name,
        c.data_type,
        constraint_name,
        constraint_type,
        c.column_name as column
        FROM information_schema.table_constraints JOIN information_schema.columns c USING (table_name)
        WHERE c.table_schema not in ('pg_catalog', 'information_schema') AND c.table_schema not like 'pg_toast%'
"""
lyric mountain
#

So, why is it not working?

#

Again, any errors?

eternal osprey
earnest phoenix
#

discord.User has no roles?

eternal osprey
#

it just doesn't work in dm

#

i have no clue why

earnest phoenix
#

discord.User doesn't have roles attribute, Member does

eternal osprey
#
let channel = Discord.DMChannel
              const collector = channel.cart1cart1.createReactionCollector(filter, { time: 60000 });``` i tried this but it didn't work either
lyric mountain
#

I'm afraid I can't answer your issue

eternal osprey
#

Cannot read property 'createReactionCollector' of undefined

#

okay

#

that's alright!

lyric mountain
#

Cart1cart1

crimson vapor
#

what does discord use to turn the user/bot's ID into the first part of their token?

gilded olive
#

Wait

#

What?

crimson vapor
#

how would I do that?

eternal osprey
lyric mountain
#

Pretty sure it's base64 for the whole token except the key

crimson vapor
#

maybe

gilded olive
#

It's because of "return"

crimson vapor
#

but how would I turn a number into base64?

lyric mountain
crimson vapor
#

hmm

gilded olive
#

Everything after that line would not be executed since "return" by default returns None

lyric mountain
#

Every lang has at least one

crimson vapor
#

yea

lyric mountain
#

Don't ask me HOW to generate one from scratch tho, idk how tf base64 is calculated

#

Only know there's a lib for it

gilded olive
#

Instead of multiple ifs and 1 else

#

Use if

#

Elif

#

And 1 else

crimson vapor
#

probably Buffer

lyric mountain
#

Buffer?

gilded olive
#

🤔 oh you used discord.User

crimson vapor
#

for the base 64 string

#

lemme see if I can do it

gilded olive
#

Yep

crimson vapor
#

figured it out

#

Buffer.from(id).toString('base64')

#

${message.author}, you are ${Math.floor(Math.random() * 100)}% gay.

#

almost there

#

but you were mixing `` and ''

regal creek
crimson vapor
shut swan
#

hi

#

!bot

#

!bots

#

!mybots

umbral zealot
earnest phoenix
#

the token is longer than in the pic

#

so i don't blur it

tulip ledge
#

Ok so I have this array:
[{name: "user1", gold:100}, {name:"user2", gold:200}] and I need to sort it on gold high to low how would I do that?

mellow kelp
#

use Array.sort

earnest phoenix
#

use sort

#

tested

mellow kelp
#

bruh, spoonfeed

earnest phoenix
#

hmm

#

ok

#

deleted

mellow kelp
#

k

earnest phoenix
#

can u help me with my question

#

wait

#

wrong channel

tame kestrel
#

s just postman but

#

when I send auth headers usually I have to prefix them with the type of token

#

Authorization: Bearer {token}

earnest phoenix
#

oooh

#

i found that

#

the token is not mine

#

that's the docs token

prisma wren
#
  "name": "Discordbot",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^12.5.1",
    "mongoose": "^5.11.3",
    "ms": "^2.1.2"
  },
  "devDependencies": {
    "nodemon": "^2.0.6",
    "prettier": "^2.2.1"
  },
  "description": ""
}

I haven't been on VS Code for a bit and missed the update. Apparently there is now something wrong with this. It says that the "Discordbot" string in "name": "Discordbot", doesn't match this pattern. I'm using Java but this is a json file.

pale vessel
#

iirc the api token doesn't have any prefix

mellow kelp
#

the package.json name must be lowercase

#

it has some other rules but thats whats wrong there

prisma wren
#

so it needs to be discordbot instead of Discordbot?

mellow kelp
#

yea

#

or discord-bot

prisma wren
#

ok ty

mellow kelp
#

np

earnest phoenix
#

Nice

#

hey how do i make an async command on if (message.content === 'command' etc

#

in discord.js

pale vessel
#

make your callback async

earnest phoenix
#

lol

hidden lynx
#

am i dumb how do i cover links in embed fields? (discordjs)

pale vessel
#

you can only use them in field values and embed description

#

not sure what you mean by cover links though

hidden lynx
#

nvm got it

#

just like basic markdown

#

thanks tho

#

confused me that users cannot do it in chat the same way

summer torrent
#
let o = {
    '123': [
        {
            webhook: [Object],
            user: [Object],
            channel: 'XXX'
        },
        {
            webhook: [Object],
            user: [Object],
            channel: 'XXX'
        }
    ]
}
Object.keys(o).forEach(a => `${a} - ${o[a]}`)```
what is wrong? returns `undefined`
pale vessel
#

values?

summer torrent
#

same

earnest phoenix
#

Object.keys() returns string forms of the properties

#

You can't access their value like that

summer torrent
#

oh

#

so how

pale vessel
#

Object.values() return the same thing?

earnest phoenix
#

Well uhh, Object.entries() exist

hidden lynx
#

you could do it with for and of

pale vessel
#

bruh

hidden lynx
#

thats the way i like to do it

earnest phoenix
#

for..of is for iterating through an array, not object

hidden lynx
#

you can iterate through objects as well

pale vessel
#

that's for in

earnest phoenix
#

Not with that

#

for..in

hidden lynx
#

works with of as well

pale vessel
#

nope

earnest phoenix
hidden lynx
#
for (let i of Object.keys(idkwhat)) {
    console.log(idkwhat[i];   
}```
#

pretty sure this works

earnest phoenix
#

Without the usage of Object.keys()

summer torrent
hidden lynx
#

if using JS is not allowed xD

#

anyways he got his answer

earnest phoenix
#

Well not using your logic tho

hidden lynx
#

i have no idea what you are trying to say

cursive scarab
#

Hey guys, I'm making a Discord server and i want to invite as many bots as posible. If you host a bot can you send me the invite to DMs?

regal saddle
#

noooooooo

earnest phoenix
#
- let i of Object.keys(object)
+ let i in object```
#

Moment

hidden lynx
#

i stand to my Object.keys <3

crimson vapor
#

I use Object.keys also

mellow kelp
#

yea same

kindred niche
#

Hello, im having a problem with quick.db installation

#

The command prompt gives me alot of errors when i type the command: npm install quick.db

solemn latch
#

did you follow the quickdb troubleshooting?

kindred niche
#

what is that

#

im installing the prebuild but i dont know if i shoud to that

solemn latch
uncut vortex
#

Hey I was wondering how would you get all messages from a channel?

#

its discord.js

kindred niche
#

Thank you Whoo!

earnest phoenix
#

free source codes embarrassed

sterile minnow
sterile lantern
#

maybe something with the request

#

or syntax

sterile minnow
#

Its literally copied from another project where its working fine

#

Even postman says its good. But even there a 400

#

wtf is this Webhook stuff

odd stratus
#

Anyone have any sort of idea of how a bot would add multiple language support and have it respond with whatever language the user sets the bot as with a settings command?

sterile minnow
#

fck finally

sharp birch
#

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});

client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
}
});

client.login('token');

#

umm

earnest phoenix
#

free code

#

lets go

sharp birch
#

Ok what it is

summer torrent
#

🤔

hollow sedge
#

but you have a bot listed on top.gg?

#

shouldnt you know that

tulip ledge
#

how do I fetch for a message by ID?

honest perch
#

@scenic kelp

#

Bad word above

tulip ledge
#
let sEmbed = new Discord.MessageEmbed()
                const channelStrikes = bot.channels.cache.get('791454242908012564')

Swap these

uncut vortex
#

Anyone know how to send a discord attachment text file from a string without using the file system

tulip ledge
#

channel.messages.fetch('791453903165194240').edit -> channel.messages.fetch(...).edit is not a function

summer torrent
#

fetch returns Promise

tulip ledge
#

so

#

I await

#

?

pale vessel
#

yes

tulip ledge
#

so

#

do I do

#

msg = await fetch

#

msg.edit

pale vessel
#

yes

tulip ledge
#

or can I just await fetch.edit

pale vessel
#

you can if you use (await channel.messages.fetch('791453903165194240')).edit()

#

if you want to await the edit use await (await channel.messages.fetch('791453903165194240')).edit()

tulip ledge
#

(await lbChannel.messages.fetch('791453901290209291')).edit(
Unexpected identifier

sudden geyser
#

is that a 1 (number)

tulip ledge
#

?

pale vessel
#

it's probably lb

solemn latch
#

lbchannel or 1bchannel

tulip ledge
#

lbChannel

#

it stands for leaderboard

sudden geyser
#

Your code looks correct. Can you share more of it via hastebin

tulip ledge
fast trench
#

error: https://prnt.sc/w89c1i
code:```js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { ThemeProvider, CSSReset } from "@chakra-ui/react"

ReactDOM.render(
<React.StrictMode>
<ThemeProvider>
<CSSReset />
<App />
</ThemeProvider>
</React.StrictMode>,
document.getElementById('root')
);

reportWebVitals();

Lightshot

Captured with Lightshot

sudden geyser
#

vigin ngl that's quite hard to read

fast trench
#

I'm not entirely sure about react/chakra 😅

tulip ledge
#

just look at line 293

#

its where the error is

pale vessel
tulip ledge
#

oh

pale vessel
#

.then(async () => {})

tulip ledge
#

fuck

earnest phoenix
#

how can i make my bot identify if a constant's value isn't a number?

pale vessel
#

use the is-number package

earnest phoenix
#

oh right

#

let me install it

misty sigil
#

what

hollow sedge
#

you need a package to check if a string is a number?

misty sigil
#

no

mellow kelp
earnest phoenix
#

no

#

NO

mellow kelp
#

isNaN('not-a-number')

hollow sedge
#

is this a joke

earnest phoenix
#

oh right

earnest phoenix
#

if you feel stupid, remember that i tried to change a constant's value in another line of the code.

sudden geyser
#

You'll feel stupid when you spend 10 minutes trying to optimize something to then realize it shouldn't have been adjusted in the first place

earnest phoenix
#

uh

opal plank
#

if you feel stupid, remember some idiot managed to get by with spamming Twitch's API with a test library and a shard spawner with 3000 shards within 12 seconds

#

Not pointing fingers though, but he's here in this channel

#

👀

sudden geyser
#

is it me

opal plank
#

i dont recall you ever touching Twitch API (which no human being should, its trash)

sudden geyser
#

You should see Hypixel's API

opal plank
earnest phoenix
#

hey

opal plank
#

read a couple messages above to spot the idiot

earnest phoenix
#

how can i make my bot identify if the ID of a channel provided is from the same server?

sudden geyser
#

find the channel in the guild channels cache by id

earnest phoenix
#

cache

#

thx!

sudden geyser
#

Which is as easy as this if you're using Discord.js: js <Guild>.channels.cache.has(id)

earnest phoenix
#

thx!

boreal flume
#

Is there a way to use discord OAUTH-2 to write an activity to a user

mellow kelp
#

wdym write an activity?

twin urchin
earnest phoenix
boreal flume
#

How would I go about doing so?

boreal flume
earnest phoenix
boreal flume
#

Hmm...

twin urchin
# earnest phoenix

possibly just use the built in respectable classes (as MessageEmbed or RichEmbed) and make a check to see if it has a title / description and if so set the title and description.

boreal flume
#
for(const prop of obj){
  if(obj[prop] === null) delete obj[prop]
}
#

Then you can just convert the object to an array and send the array joined by '\n'

boreal flume
twin urchin
#

well using oauth, you pass the scope and once they accept it you will have their access token and do x if you have privileges.

boreal flume
#

Is there a way to do it using passport-discord?

twin urchin
#

Yeah, just do all of the normal stuff then pass in the extra scope.

boreal flume
#

I know the scopes

#

I just don't know the code to change the activity

#
const DiscordStrategy = require('passport-discord').Strategy;
const passport = require('passport')

passport.use(new DiscordStrategy({
    clientID: process.env.CLIENT_ID,
    clientSecret: process.env.CLIENT_SECRET,
    //callbackURL: process.env.CLIENT_REDIRECT,
    scope: ['identify', 'email', 'guilds', 'activities.write'],
}, (accessToken, refreshToken, profile, cb) => {
    console.log(profile.username);
    console.log(profile.id);
    console.log(profile.guilds.length)
    cb();
}))
//discordstrategy.js
#

This is my discord strategy file

#

What would I add to make it update the activity... Looking through the docs all of the discord examples are written in python

earnest phoenix
#

hi

#

me have question

crimson vapor
#

whats your question?

timber grotto
#

j

earnest phoenix
mellow kelp
#

its kind of a long process

crimson vapor
#

ye

earnest phoenix
#

oh

mellow kelp
#

check on youtube

earnest phoenix
#

but can i connect it on my index.js

mellow kelp
#

what is your index.js supposed to be

#

idk

earnest phoenix
mellow kelp
#

the bot's main file?

earnest phoenix
#

uhhh wdym?

mellow kelp
#

nvm

wide moth
#

test

earnest phoenix
crimson vapor
#

@tired oasis

#

shit wrong channel again

earnest phoenix
mellow kelp
#

i meant look up tutorials

#

i got some examples from there and built up from them

earnest phoenix
#

yea i did

slate oyster
#

Because I used the wrong method

pale vessel
#

and you must properly encode it

opal plank
quaint peak
#

how would i delete only the bots messages without going over any other messages in discord.py?

slate oyster
opal plank
#

cuz depending on ur answer it might be a big flaw

slate oyster
opal plank
#

oh, okay, i thought it was js for a second and things could be sketchy with that

#

for example ${process.exit()}

slate oyster
#

Oh, the localization
I just use .replace for that too

opal plank
#

just making sure you're actually replacing the string rather than running it with the user inside

slate oyster
#

Lol

opal plank
#

ngl seen some people here actually pull off similar stunts

#

just making sure

slate oyster
#

@opal plank My brain couldn't think of hacky code if it tried lol

opal plank
#

lmao

#

fair

slate oyster
#

I'm actually not using my localization code here, but I should

#

Just that I don't have a handle to a Locale instance here, which complicates everything
Normal commands have access to an instance of that, but this is a hook, not a normal command

#

Except for levelling, this is the code that I usually use when localizing

#

(For the V4 Alpha version of my bot, not the stable V3 version)

opal plank
#

i understand some of it but not fully

#

Java aint my forte at all

slate oyster
#

oof

opal plank
#

though because of js i understand quite a bit of it

#

the methods are similar, but both the syntax and the structure are different

slate oyster
#

Yea

opal plank
#

it is weird that you're using json though

earnest phoenix
earnest phoenix
#

embed

slate oyster
opal plank
#

which field?

earnest phoenix
#

embed.fields.value

opal plank
earnest phoenix
#

I took the embed as a message.

opal plank
#

actually

earnest phoenix
opal plank
#

fields.value ?

earnest phoenix
#

yeah

opal plank
#

fields is an array not an objcet

craggy pine
#

That doesn't look like an embed

opal plank
#

thats not an embed at all

#

thats just normal content

slate oyster
#

@opal plank I stopped that, like, over a half year ago
At first, I just swapped to a multi-folder system to minimize corruption
But now, I now use a DB for anything that can be modified

#

Speaking of, it's been a month or two since my last DB backup

opal plank
#

cant you just use something like JDBC and call it mid way?

slate oyster
#

@opal plank I don't even cache the DB lol (and performance is just fine!)
The json is only for configuration and resources. It doesn't mutate at all.

opal plank
#

though when the user changes the message it should write on it right?

slate oyster
#

That writes to the DB, not JSON

opal plank
#

say, someone were to poorly time it and the admin of the server does !edit and a user talks (or even the admin messag) both trigger a write and a read, wouldnt that be an issue?

opal plank
#

they would de-sync then, no?

slate oyster
#

Afk

earnest phoenix
#

Hello

slate oyster
#

I'm using levelling as a hook, which does not have access to a Locale (the snippit of code with the JSON)

#

Therefore I can't use that part

lyric mountain
#

Wait, that's java right?

#

Why u use json instead of hashmap?

slate oyster
#

Anyways, if I did have access to a Locale grip in that area, my code would look like this

slate oyster
lyric mountain
#

The json is stored locally or in memory?

slate oyster
#

It's initially stored in disk, but we then parse it into memory

#

@lyric mountain

#

We don't modify it at all

lyric mountain
#

Still, you could unload the json into a hashmap

slate oyster
#

Since we use a DB for things that get modified

lyric mountain
#

It's more optimized

#

If you use the official json lib you can directly convert from one to another

slate oyster
#

And it loads just fine

#

I don't think I really need optimization

lyric mountain
#

Wait, is that a localization file?

slate oyster
#

Yea, why?

lyric mountain
#

Why are u using a json?

slate oyster
#

I don't like Java's built in system

#

of localization

lyric mountain
#

Why not?

#

Locale files can get really big

#

And jsons inflate a lot when in memory

crimson vapor
#

@opal plank you were the one that said nano bad right?

slate oyster
#

I'm pretty sure that the library is caching every single member, anyways

#

Which has got to be a lot worse than JSON

#

Let me boot up VisualVM

opal plank
#

it does what its meant to do

slate oyster
#

@lyric mountain So as long as it's not this random byte array, I should be fine...

opal plank
#

nothing wrong with that

#

i just dislike it

crimson vapor
#

well

#

ssh vscode kinda pog

#

ngl

#

even port forwards

slate oyster
#

Wait
I think that byte array might actually be a memory leak
Because it keeps increasing

#

Nm

stark abyss
#

So right now I am doing

let name = arr[i].slice(0, -5)
let user = await msg.guild.members.fetch({ query: name, limit: 1 })

but as you can see I am slicing off the tag because it won't work if I don't, so does anyone know a method where I don't have to slice off the tag.

#

I mean this works, but I would have to check it with arr[i] again in case they have same username but different tag

gilded olive
#

dev advice if someone kicks or bans the bot should the guilds data still be there

#

keep in mind if the guilds data is gone so is the user's (for that guild)

haughty marten
#

@earnest phoenix if you're asking for help with coding a bot I think this is the channel

#

I used to but now I don't. I'm using repl.it rn

haughty marten
slate oyster
#

I'm going to assume you are using Discord.py, since your status shows you use python

gilded olive
#

yes

#

I mean from a database

#

so if one user from x guild collected 100 coins

#

then that bot got yeeted from x guild

slate oyster
#

Oh
If you are storing data to a database manually, you would have to delete the data yourself, else no

gilded olive
#

those 100 coins are gone

haughty marten
#

well which bot language do you want to use?

gilded olive
#

it's 1 line to delete the data

await Guild.filter(discord_id=guild).delete()```
#

all of it

#

would go in that 1 line

#

but I don't know if they add the bot back

#

and see everything is gone

#

and get upset or something

#

so looking for advice

slate oyster
#

You can add a time cooldown, maybe?

gilded olive
#

elaborate...

slate oyster
#

I dunno how Discord.py handles this, so you'll have to check

#

But I digress

gilded olive
#

it's on_guild_remove

#

when bot gets kicked/banned (basically leaving the guild)

slate oyster
# gilded olive elaborate...

Anyway, you can delay the action to be, say, 2 days later. After that 2 days, if the bot still has not been re-added to the guild, you can delete the data. If it has been re-added, then don't delete the data

slate oyster
#

Since I know some libraries do so

#

Sorry I'm busy helping somebody else

#

Also I don't use VS

gilded olive
#

I'll look into it some more

#

since like nothing is global

#

should probably start making them but whateves

slate oyster
gilded olive
#

xD

#

Yes @earnest phoenix

#

my b i didnt ping

#

what do you need help with?

trim saddle
#

@pale vessel elp

pale vessel
#

fuc

trim saddle
#

message objects don't tell if the author is a bot, do i have to request that or something

gilded olive
#
<Message id=791518241092141056 channel=<TextChannel id=783731792389603340 name='main' position=15 nsfw=False news=False category_id=770887335629291524> type=<MessageType.default: 0> author=<Member id=784132540587704320 name='Why r u gey' discriminator='7336' bot=True nick=None guild=<Guild id=770887335629291520 name='Tabi' shard_id=None chunked=True member_count=16>> flags=<MessageFlags value=0>>```
#

they do

#

but you can check that tho

pale vessel
#

no

#

he's making his own lib

gilded olive
#

oh

pale vessel
#

unless they're partials

#

idk what your payload looks like

slate oyster
#

@trim saddle Why you be writing your own lib? Discord has plenty of libraries
I mean, I wrote a library for a different chat client, but at least it didn't have a million libraries already

rustic nova
#

Making your own Library is a good way to expand your knowledge in a specific language

slate oyster
#

Ah, the only new language I've started learning lately is Haskell
Which I am really, really bad at
I glanced at Python, it was easy, so I figured no point learning it until I need it.

rustic nova
#

I'm slowly slithering into typescript/js through adding features to the top.gg premid presence

#

It's quite fun to work with, i gotta admit

slate oyster
#

JS was my first language
Surprising that I ever managed to get interested in programming lol

sudden geyser
earnest phoenix
#

hi

#

can u suggest some good api to connect a website and a discord bot

lucid prawn
#
prebuild-install || npm run build-release
       
       sh: 1: prebuild-install: Permission denied
       /tmp/build_c5542ad3_/node_modules/.bin/node: 1: /tmp/build_c5542ad3_/node_modules/.bin/node: MZ����@H��: not found
       /tmp/build_c5542ad3_/node_modules/.bin/node: 1: /tmp/build_c5542ad3_/node_modules/.bin/node: Syntax error: Unterminated quoted string
       npm ERR! code ELIFECYCLE
       npm ERR! errno 2
       npm ERR! better-sqlite3@7.1.1 install: `prebuild-install || npm run build-release`
       npm ERR! Exit status 2
       npm ERR! 
       npm ERR! Failed at the better-sqlite3@7.1.1 install script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.7uTMh/_logs/2020-12-24T05_21_23_383Z-debug.log
       - Node version not specified in package.json ```
         How do i fix this
sudden geyser
earnest phoenix
quaint peak
#

how would i make a bot delete a certain users messages without going over other messages, just that specific users in discord.py.

slate oyster
#

@quaint peak I once did this in D4J (yes, it's a different library, but same concept)
You need to get all messages within the last 2 weeks (you cannot go past that)
Filter by ones with a matching ID
And bulk delete the ones that remain

quaint peak
#

what

trim saddle
gilded olive
#

You can loop through channel.history and use a lamdba to check if the author is a certain person

slate oyster
# quaint peak what

I'm just giving you the basic concept
You'll need to ReadTheDocs for the exact methods you will need

slate oyster
lucid prawn
atomic vault
#

how do i ban and unban user in js
after getting user name

gilded olive
#

The limit can be anything

sudden geyser
#

insane can you show us your package.json file

gilded olive
#

Its a kwarg anyway

slate oyster
# gilded olive The limit can be anything

Anything less than 2 weeks
Otherwise, you are uselessly looping over messages that cannot be bulk deleted
(A huge time waste, I've made that mistake before)
And using normal delete would just a) be API spam b) take an eternity

gilded olive
#

And you can then add a check if that arg is over some nimber raise ValueError

#

Or something like that whatever floats your boat

slate oyster
gilded olive
#

That is the limit

#

Is it not?

#

what does it return

slate oyster
#

Messages just won't delete if you go older than that
If you specify a custom limit, you can delete less messages, but you cannot delete more, so there's no point in even trying

#

(Assuming you use bulk delete, which you should be, as otherwise you would be spamming the api)

gilded olive
#

🤔

tribal siren
#

so i got a question

#

if i want something to happen in a specific time, i use setTimeout

atomic vault
#

hellow

slate oyster
tribal siren
#
  something
}, 5000)```
#

now, how to make something happen every 5 seconds for example?

gilded olive
slate oyster
#

But if you shut down your bot, that repeated action won't persist, just a note

tribal siren
#
  yes
}, 5000)```
#

like this?

slate oyster
#

Yea

tribal siren
#

oh

#

thanks

slate oyster
#

It won't persist though
You'd have to use a DB to make it persist

atomic vault
#

how can i unban user in js

rustic nova
tribal siren
gilded olive
carmine summit
#

TypeError: error is not defined.

sudden geyser
#

@earnest phoenix when asking for hep, you should be clear and concise. Right now, I can't understand a single thing you said.

pale vessel
#

What error?

tribal siren
#
console.log(ms(5s)) // returns 5000
// how to do it the other way round, like make 5s out of 5000?```
atomic vault
tribal siren
atomic vault
#

mes.guild.members.unban(mem, 'hi')

tribal siren
#

no like

atomic vault
#

?

tribal siren
#

is your command just that?

atomic vault
#

if(mes.content.startsWith('eme')){ let ful = mes.content.substr(3) let sp = ful.split(" ") let arg = sp.slice(1) let ss = arg.toString() let mem = mes.mentions.users.first() if(mes.member.hasPermission('BAN_MEMBERS')){ mes.guild.members.unban(mem, 'hi') }else{ mes.reply('You dont have permission for baning user') } }

tribal siren
#

thanks

near stratus
#

which language is this ? PHP ?

tribal siren
#

bad joke my m8

sudden geyser
pale vessel
near stratus
#

bruh

gilded olive
#

Oh brother

near stratus
#

lemme Google for BDFD

crimson vapor
sudden geyser
#

ms

#

very popular

crimson vapor
#

why would anyone need this

tribal siren
#

lots of guys need it

crimson vapor
#

just parse it yourself

#

make a util file called ms

tribal siren
#

reminders, giveaways, tempmute, temprole

#

all in ms

crimson vapor
#

and make your own function

sudden geyser
#

Why do that when a library already does it for you? :^)

#

It's more than what you think it is.

crimson vapor
#

because you don't need bloat packages

near stratus
sudden geyser
#

Please see the package before criticizing it, because there's more to it than you probably see.

tribal siren
#

i guess

atomic vault
#

i will try

crimson vapor
#

true and it probably does exactly what its supposed to for the people who use it

#

but imo its kinda just bloat

sudden geyser
tribal siren
#

ms is like everything about time

carmine summit
#

@sudden geyser what package is that

sudden geyser
#

ms

carmine summit
#

ofcourse

atomic vault
#

@tribal siren it shows Cannot read property 'id' of undefined

carmine summit
#

if there is fs, surely there is ms

tribal siren
sudden geyser
#

milliseconds system

atomic vault
#

tho?

sudden geyser
#

for every millisecond one file is created

#

for every 60,000 ms, one minute passes.

crimson vapor
#

do you guys use 60000 as your 1 minute constant or 60 * 1000?

pale vessel
#

60000

#

unless it's above that lmfao

sudden geyser
#

doesn't matter which one you choose, but you can add underscores for readability (60_000)

crimson vapor
#

damn you scum

crimson vapor
#

60 * 1000 > 60000

#

actually 60_000 seems cool

sudden geyser
crimson vapor
#

no hate for that

pale vessel
#

foo?.bar || "n/a" or foo ? foo.bar : "n/a"

crimson vapor
#

hmm

#

depends on what im doing

pale vessel
#

i used to use the latter but now that i upgraded my node

sudden geyser
#

it's useful but can be harder to understand for larger numbers: 86_400_000 vs. 60_000 * 60 * 24

pale vessel
#

first one seems cleaner

crimson vapor
#

depends for me

pale vessel
#

or (foo || {}).bar || "n/a"

#

troll

crimson vapor
#

if im writing code for me probably the first one

atomic vault
crimson vapor
#

but if im doing something someone else can use the second one

#

since no errors

tribal siren
atomic vault
#

how

tribal siren
#

read this then

tribal siren
atomic vault
#

ya sorry

#

how to get the id?

rustic nova
#

that's the user id

#

you can get it through multiple ways like mentioned users or just using the id argument from your unban command

atomic vault
#

.id is undifined

#

it shows

trim saddle
pale vessel
#

what does the object look like

rocky hearth
#

hey flaze, do u know ts well?

lucid prawn
#
client.on('guildMemberAdd', async member => {
    if (message.content.startsWith(prefix + "wl")) {
    const channel = member.guild.channels.cache.find(ch => ch.name === '💠bot-commands');
    if (!channel) return;

    const canvas = Canvas.createCanvas(700, 250);
    const ctx = canvas.getContext('2d');

    // Since the image takes time to load, you should await it
    const background = await Canvas.loadImage('./Untitled-3.png');
    // This uses the canvas dimensions to stretch the image onto the entire canvas
    ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
    // Use helpful Attachment class structure to process the file for you
    const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'Untitled-3.png');

    message.channel.send(`Welcome to the server, ${member}!`, attachment);
    }
});
#

it not working

pale vessel
#

what's not working

#

tell me

lucid prawn
pale vessel
#

do you have the guild members intent

#

you need it for the event to trigger

#

sfsd;lfoijsfd

trim saddle
#
{ type: 0,
  tts: false,
  timestamp: '2020-12-24T06:04:15.269000+00:00',
  referenced_message: null,
  pinned: false,
  nonce: '791546753089273856',
  mentions: [],
  mention_roles: [],
  mention_everyone: false,
  id: '791546766113767454',
  flags: 0,
  embeds: [],
  edited_timestamp: null,
  content: 'e',
  channel_id: '791500215009935371',
  author:
   { username: 'Skullbite',
     public_flags: 131840,
     id: '158750488563679232',
     discriminator: '5245',
     avatar: 'f5e9fddf28b6856a64415b5431014a5f' },
  attachments: [] }

this is for a fucking dm message

pale vessel
#

you need to fetch it then

#

since other libs have structures + caching

#

so the author object is guaranteed to have the bot property

trim saddle
#

slow downeeeeeeeee

lucid prawn
pale vessel
lucid prawn
earnest phoenix
#

What is better? Storing just channel ID123456789 in database or storing like this [#123456789](/guild/264445053596991498/channel/123456789/) in db

pale vessel
#

Just the ID

earnest phoenix
#

Why not [#123](/guild/264445053596991498/channel/123/)

pale vessel
#

Because you can easily add those

lucid prawn
#

if i do id is that only going to work for my server

pale vessel
gilded olive
#

yes

#

Unless that id is able to be changed at will

#

To something different

lucid prawn
#

im not smart to do that

earnest phoenix
#

Can someone help me with Pating a User?

#

How that works

#

(Pat a user)

gilded olive
#

Lang and lib?

atomic vault
#

i am trying to get the id of user i have meansed in message but it shows id is undifined

earnest phoenix
gilded olive
#

Welp

earnest phoenix
#

NodeJs

atomic vault
#

?

pulsar bone
#

is there anything called embed.title.content

tribal siren
#
let unban = message.guild.bans.get(args[0])```
#

why cryingman

summer torrent
#

message.guild.bans is not a thing

pulsar bone
tribal siren
#

how to do it properly then

summer torrent
#

use message.guild.fetchBan(args[0])

pulsar bone
#

;-;

tribal siren
#

idek myself so ye look at that instead

pulsar bone
#

ok

strong escarp
#

how do i put server count of my bot in the web?

summer torrent
#

don't spoonfeed pls

near stratus
near stratus
strong escarp
#

do i need to change dbl.on to client.on?

summer torrent
#

no?

#

it is dbl's events

strong escarp
#

;-;

#

ok

#

but bot library is discord.js

#

;-;

summer torrent
strong escarp
#

reh?

#

eh?

#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);

// Optional events
dbl.on('posted', () => {
  console.log('Server count posted!');
})

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

That shouldn't post server count

strong escarp
#

wrong place'

carmine summit
#

its an event

#

not a method

strong escarp
#

;-;

#

i dont use async function

crimson vapor
#

use async

strong escarp
#

i dont use module.export

#

my whole bot is without async

near stratus
#

just run a setTimeout and pass dbl.postStats(client.guilds.size)

strong escarp
#

Oops! Error: 401 Unauthorized

near stratus
carmine summit
#

you need authorizeation key

#

authorization key

strong escarp
#

;-;

pulsar bone
#
if(message.content.toLowerCase().includes('cyber'))
    message.channel.send("Key Word Detected ");
else {
    for(var i = 0; i < message.embeds.length; i++) {
        if(message.embeds[i].title.includes("cyber") || message.embeds[i].title.includes("cyber")) {
            message.channel.send("Detected");
            break;
    }
}
 ```
what we are using i variable for in this code
near stratus
#

i is the loop variable isn't it

pulsar bone
#

its also used in embed[i]

near stratus
#

you can't run a for loop without it

lucid prawn
#
catch (error) {
    console.error('Error trying to send: ', error);
  }
});
function catchErr (error, message) {
client.users.get("390690088348024843").send () ("There was an error at channel" + message.channel + "in guild" + message.guild);
client.users.get("390690088348024843").send ("ERROR" + error)
}

why is it not working

near stratus
pulsar bone
pulsar bone
near stratus
near stratus
near stratus
#

@pulsar bone for your concern

let a = [1,2,3,4,5,6]
for(let i = 0; i <a.length ; i++){
    console.log(a[i]);
}
carmine summit
#

make it a.length + 1

#

to include the last item

strong escarp
#

lol i am so confused

pulsar bone
strong escarp
#

how do i authorize my self -_-]

near stratus
near stratus
strong escarp
#

wait

#

nvm i mistakenly deleted all my code

#

nvm i have a backup

#

;-;

near stratus
near stratus