#development

1 messages · Page 1852 of 1

hollow depot
#

anyone know how to solve this issue? internet has not been helpful lol
using node v16.6.1

radiant kraken
hollow depot
#

that's a problem

worn hazel
#

Hey uh can anyone help me why does my bot keeps getting timed out?
the ping is fine and my other bots on the vps work just fine, its just that this one bot keeps dying randomly after 3-5hrs

#

My Client is initialised like this

#

please ping me if you know how can i fix this

hollow depot
radiant kraken
#

maybe it could be caused by the different os? im not quite sure

azure lark
#

how do i get the mentioned user from a slash command

wraith urchin
#

I think I'm finally about to fix jibakoma : D
Just got to take care of this error:

#

@drowsy crag scambot

tulip ledge
#

Anyone knows how to update nodejs on ubuntu? I tried using the n module it sais it installed nodejs v16.7.0 but when I do node -v it shows v15.8.0

pale vessel
#

I'd just purge and reinstall lul

tulip ledge
#

how?

tulip ledge
#

ty

earnest phoenix
tulip ledge
earnest phoenix
#

Thats why never use nvm lol

#

Run:

tulip ledge
#

u just told me to use nvm

pale vessel
#

so confused

earnest phoenix
#

sudo npm install pm2 -g

pale vessel
#

oh god no

earnest phoenix
#

pm2 update

tulip ledge
#

Bro

#

U just told me to use nvm

#

then told me to never use it

#

huh?

pale vessel
tulip ledge
#

Did that

#

Still gives error

earnest phoenix
#

You still need to update pm2

pale vessel
#

don't think so

#

Just delete the process and do pm2 start again

earnest phoenix
#

I installed v16 yesterday and it was required

tulip ledge
earnest phoenix
#

pm2 update has the same approch,nvm there are many solutions ;) ,maybe mine wasn't the eaisest

mild agate
#

message.channel.send({ content: "Pong" })
Nvm I always forget to scroll. sry

hollow loom
#

k

crimson vapor
#

pm2 always uses the base node version

azure lark
#

how do i get the mentioned user from a slash command

modest maple
#

aha no

#

@drowsy crag you are of the need

peak patrol
#

Guys

#

I need help with a weird bug

#

I had an old bot

#

that perfectly work with the token runner command

#

and i put the same command

#

in another bot

#

and it didn't work

#

and im sure it's the same

#

ping me when there's answer please

wheat mesa
nova basin
#

Hello I wanted to use discord-buttons but I had a problem I put const disbut = require('discord-buttons'); disbut(client); in index.js but I got an error

lethal trout
#
const emo = {
        fun: "🎮",
        ticket: "🥴",
        utility: "2️⃣",
        moderation: "⚙️",
    }

    // now lets run it
    array.forEach(cca => {
        let name = cca;
        let sName = `${name.toUpperCase()}`
        let tName = name.toLowerCase();
        let fName = name.toUpperCase();
        let e = emo

        return menus.push({
            label: sName,
            description: `${tName} commands!`,
            value: fName,
            emoji: e[name]
        })
    });```
emoji aint working 😦
wheat mesa
nova basin
#

Ah

nova basin
wheat mesa
#

Define client

nova basin
#

How

wheat mesa
#

Do you know how to instantiate a discord client?

cinder patio
#

e[name] + sName

wheat mesa
#

You’re using client before you made an instance of a Discord.Client with the name of client

nova basin
#

Ah

earnest phoenix
nova basin
#

Okey I'm going to go do this and I'll tell you how it works

sudden geyser
earnest phoenix
nova basin
#
const client = new discord.Client(); //Creating discord.js client (constructor)
const disbut = require('discord-buttons');
disbut(client);```
#

It's good ?

hollow depot
nova basin
#

Because I have error ☹️

nova basin
#

I have question

#

How pepowot

pale vessel
#

why use discord-buttons

nova basin
#

Because it puts an error :(

burnt anchor
#

error

C:\Users\Mustikk\Desktop\Projects\Lxyon\index.js:102
    const guild = client.guilds.get('878986911908241489');
                                ^

TypeError: client.guilds.get is not a function
    at Client.<anonymous> (C:\Users\Mustikk\Desktop\Projects\Lxyon\index.js:102:33)
    at Client.emit (node:events:394:28)
    at Object.module.exports [as GUILD_MEMBER_ADD] (C:\Users\Mustikk\Desktop\Projects\Lxyon\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBER_ADD.js:16:14)
    at WebSocketManager.handlePacket (C:\Users\Mustikk\Desktop\Projects\Lxyon\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
    at WebSocketShard.onPacket (C:\Users\Mustikk\Desktop\Projects\Lxyon\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (C:\Users\Mustikk\Desktop\Projects\Lxyon\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (C:\Users\Mustikk\Desktop\Projects\Lxyon\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (node:events:394:28)
    at Receiver.receiverOnMessage (C:\Users\Mustikk\Desktop\Projects\Lxyon\node_modules\ws\lib\websocket.js:970:20)
    at Receiver.emit (node:events:394:28)
PS C:\Users\Mustikk\Desktop\Projects\Lxyon>
pale vessel
#

v13 have components, update

burnt anchor
#

code

client.on('guildMemberAdd', guildMember => {
    const guild = client.guilds.get('878986911908241489');
    const channel = '879016940071444490';
    var userCount = guild.memberCount;

    channel.send(`> <@${guildMember.id}> joined to our server.We are ${userCount} members with u!`);
});
#

i tried client.guilds.find

#

too

pale vessel
#

client.guilds is a guild manager

burnt anchor
#

how can i fix?

pale vessel
#

Look in docs for GuildManager

burnt anchor
#

ok

pale vessel
#

there's the cache property you can access which is a collection

nova basin
#

"just specify the intents if you are on v13 and youre good" how ? @pale vessel

pale vessel
#

client.guilds.cache.get()

pale vessel
#

new Discord.Client({ intents: here })

#

You can provide an array of intents

burnt anchor
pale vessel
#

Channel is a string

#

You can't use .send() on a string

#

get the actual channel from the guild

lethal trout
# cinder patio Put the emoji in the label
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Invalid Form Body
components[0].components[0].options[0].emoji.name: Invalid emoji
components[0].components[0].options[1].emoji.name: Invalid emoji
components[0].components[0].options[2].emoji.name: Invalid emoji
components[0].components[0].options[3].emoji.name: Invalid emoji```
pale vessel
#

guild.channels.cache.get(id)

#

You don't even need the guild, you can use client.channels.cache.get(id)

cinder patio
#

debug your code dude

#

console log everything

#

use a debugger

#

did you remove emoji: e[name]?

sudden geyser
#

or just learn to learn

cinder patio
#

the emoji field is for custom emojis only

#

put unicode emojis in the label

nova basin
pale vessel
#

none

#

Read the guide and use intents that you need

lethal trout
nova basin
lethal trout
cinder patio
#

remove that

#

I told you to put the emoji in the label

#

not the other way around

clever orchid
#

does anyone know how to make my bot respond with the message.reply() function without pinging the user¿¿

cinder patio
#

label: e[name] + sName

#

and remove the emoji field

cinder patio
#

e[tName]

#

not sName

#

sName is your command name in uppercase, while your property names are all lowercase

#

serious question: do you know what you're doing?

worn sonnet
#

kuyaj | Team Peipei | 𝔽𝟠 𝔾𝕦𝕚𝕝𝕕#

#

When trying to write it to a CSV file i get error with encoding thingy
I'm using Python

earnest phoenix
#
if(command === "daily") {
    const member = await Economy.findOne({ userId: message.author.id })
    const cd = await Cd.findOne({ userId: message.author.id })
    const timeout = 8.64e+7;
    const timer = cd.get("daily")
    if(timer !== null && timeout - (Date.now() - timer) > 0){
    const timeEmbed = new Discord.MessageEmbed()
      .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
      .setColor("RED")
      .setDescription(`${tickno} | You can next collect your daily in **${prettyMS(timeout - (Date.now() - timer))}**`)
      .setTimestamp()
      return message.channel.send(timeEmbed)
    } else {
      const bal = member.get('money')
      await Economy.updateOne({ userId: message.author.id }, { money: bal + 1000 })
      await cd.updateOne({ userId: message.author.id }, { daily: Date.now() })
      const embed = new Discord.MessageEmbed()
       .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true }))
       .setColor("GREEN")
       .setDescription(`${tickyes} | You have collected your daily reward of \`1000\`${coins}`)
       .setTimestamp()
       message.channel.send(embed)
    }
  }```
Hey this is showing "cannot read property get of null". Whats the reason?
clever orchid
#

in member.get('money') i guess

worn sonnet
#

Apparently it's due to this 𝔽𝟠 𝔾𝕦𝕚𝕝𝕕# is there a way i can add this thing too?

earnest phoenix
#

but it is not telling in which line

umbral lake
#
client.on("presenceUpdate", (oldPresence, newPresence) => {
    if(!oldPresence) return
    if(!newPresence) return
    if (!oldPresence.activities[0].state) return
    if (!newPresence.activities[0].state) return
    const guild = client.guilds.cache.get("876082294283186186")
    const role = guild.roles.cache.get("876084564240531487")
    if(newPresence.activities[0].state.includes(".gg/tbs")) {
        if(!oldPresence.activities[0].state.includes(".gg/tbs")) {
            newPresence.member.roles.add(role)
        }
    } else if(oldPresence.activities[0].state.includes(".gg/tbs")) {
        if(!newPresence.activities[0].state.includes(".gg/tbs")) {
            newPresence.member.roles.remove(role)
        }
    }
});

when some users has the .gg, the bot dosen't add the role :/

#

and if I remove ```
if(!oldPresence) return
if(!newPresence) return
if (!oldPresence.activities[0].state) return
if (!newPresence.activities[0].state) return

for some users, the bot has an error
earnest phoenix
acoustic reef
#

Does anybody know why my bot randomly goes offline?

Additional info: Slash commands, hosted on replit

earnest phoenix
#

replit turns off your repl after five minutes

acoustic reef
#

It has the keep alive thing

#
  • uptime robot
earnest phoenix
#

those don't work anymore or you didn't set it up properly

acoustic reef
#

I prob added the wrong link in uptime robot

earnest phoenix
#

I have a question
I have a URL like this: /v1/npkn/handle/image/upload
I want to extract the part after handle
I'm using nodejs path to parse URLs

burnt anchor
#

CODE

const { MessageEmbed, Client, Message, Discord } = require('discord.js');
module.exports = {
    name: 'rectrole',
    description: "If anyone reacts to msg gains role.",
    async execute(msg, args, Discord, Client){
            const Role = msg.guild.roles.cache.find(role => role.name === "Member");
            const channel = '878990757615247410';
            const Emoji = '878990351753429073';
    
            const reactionchannel = msg.channel
            const reactionEmbed = new MessageEmbed()
            .setColor('#ffffff')
            .setTitle('REACT TO GET ROLE')
            .setDescription('Reacting for get role is important for u to be verified.');
            const embed = await reactionchannel.send({ embeds: [reactionEmbed] });
            embed.react(Emoji)
            
            Client.on('messageReactionAdd', async (reaction, user) => {
                if(reaction.msg.partial) await reaction.msg.fetch();
                if(reaction.partial) await reaction.fetch();
                if(user.bot) return;
                if(!reaction.msg.guild) return;
                if(reaction.msg.channel.id == channel){
                    if(reaction.Emoji.id === Emoji){
                        await reaction.guild.members.cache.get(user.id).roles.add(Role);
                    }
                }
            });
    }
}
#
C:\Users\Mustikk\Desktop\Projects\Lxyon\data\commands\rectrole.js:19
            Client.on('messageReactionAdd', async (reaction, user) => {
                   ^

TypeError: Cannot read property 'on' of undefined
    at Object.execute (C:\Users\Mustikk\Desktop\Projects\Lxyon\data\commands\rectrole.js:19:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
#

it reacts but doesnt gives role to the member

earnest phoenix
#

Client is not defined

#

You are not passing the client to your execute function

burnt anchor
#
const { MessageEmbed, Client, Message, Discord } = require('discord.js');
    async execute(msg, args, Discord, Client){
#

here it needs to be defined

earnest phoenix
#

No

#

The value is undefined in the function

burnt anchor
#

value?

#

of what

earnest phoenix
#

Your command handler is not passing the client to the execute function

burnt anchor
#

how can i fix?

#

am i need to change command handler?

earnest phoenix
#

yes

burnt anchor
#

omg

#

so many jobs

#

thanks for ur help

#

xd

earnest phoenix
#

yw

acoustic reef
earnest phoenix
#

huh

#

did you set the type as https in uptime robot

acoustic reef
#

Yes

earnest phoenix
#

that shouldn't be happening

acoustic reef
#

I set it all up correctly

earnest phoenix
#

idk man

#

havent used replit in a while

acoustic reef
#

Keep in mind the error is "No module named 'discord_slash'". I have to re-install it every time after it goes offline

earnest phoenix
#

That's expected since replit deliberately reinstalls all your dependencies if you change anything in package.json

earnest phoenix
#

ok i just realized

url.split("/image")[1];
#

skill issue

burnt anchor
#

@earnest phoenix

sterile thicket
#

How do I export a function in js?

export default functionName``` gives me an error `Unexpected token 'export'`
cinder patio
#

js or node.js?

tulip ledge
#

export default is for typescript no?

cinder patio
#

not only ts

tulip ledge
#

Oh

sterile thicket
cinder patio
#

es6 modules

tulip ledge
#
module.exports = function functionName() {}

or

function functionName() {}

module.exports = functionName
cinder patio
#

that's node.js

tulip ledge
#

Does it not work in js too?

#

ok mb scratch that then

cinder patio
restive furnace
wheat mesa
#

Let's be honest, internet explorer's only use was to download other browsers

earnest phoenix
sterile thicket
restive furnace
#

you're using require, not import

summer torrent
#

lmao

sterile thicket
restive furnace
#

for ts and es6 modules

sterile thicket
#

Im in js

tulip ledge
#

If you say module.exports = functionName I'm pretty sure you can't deconstruct it

restive furnace
summer torrent
sterile thicket
#

lmao me newb

summer torrent
sterile thicket
#

so import {function} from ../../path?

summer torrent
#

path in "", yes

lethal trout
sudden geyser
#

It'll help to spend more time learning JavaScript.

earnest phoenix
#

Instead change the require of index.js in /home/container/commands/economy/daily.cjs to a dynamic import() which is available in all CommonJS modules.

#

fix?

#

anyone please

sudden geyser
#

It means you should use import instead of require(...)

earnest phoenix
sudden geyser
#

For example, you could do import * as ms from "parse-ms"

earnest phoenix
#

aight

#

thanks

lethal trout
#

the slash comamnds work

earnest phoenix
sterile thicket
#

^ same

sudden geyser
#

I think you need to set the type key in your package.json to "module"

earnest phoenix
#

how? (:

sterile thicket
#

"type": "module"

earnest phoenix
#

oh got it

quaint wasp
#

uh..

#

Im trying to make a Discord Aotho2 on my website..

#

and when I login I get this

#

how do I get that with HTML and get data from it?

#

like users username, guilds they are in, ect that comes with my scopes..

sterile thicket
sudden geyser
near stratus
#

You'll get a token

#

save that and use it later for authorization

#

I suggest doing it in Backend tho

quaint wasp
#

? Whats the difference between backend and front end... I thought frontend is like design and backend is code..

near stratus
#

If you're doing it on Frontend use 'grant_type': 'token' instead of 'code'

quaint wasp
#

alright :/

crystal wigeon
#

Anyone good at content writing? Or flutter? I have a job opportunity, remote, contract base thing.

#

Ik this not the right place but there good developers here

crystal wigeon
#

Basically creating content for a brand.

#

Twitting stuff etc

austere zealot
#

is there a way i can connect to my already exisiting postgres db from vultr?

sudden geyser
crystal wigeon
#

is there a way i can connect to my already exisiting postgres db from vultr?
@austere zealot yeah, what exactly are you trying to do

austere zealot
crystal wigeon
austere zealot
crystal wigeon
#

where is your database located?

austere zealot
#

you have to host your db?

near stratus
crystal wigeon
#

..

#

yeah, it wont work on loclahost

austere zealot
#

bruv

austere zealot
crystal wigeon
#

well you can install postgres on the same machine

#

but if you have a big project its better to separate them

austere zealot
#

i dont really have a big project

near stratus
brave garnet
#

asap question -> is it possible to convert google sheet managed by google form to json? i wanna use data somewhere....

brave garnet
#

PS: i was using a few scripts alreday but all broken =p

near stratus
#

You can create an app from the GCP dashboard (free for smol)
Then Google sheet becomes like a real time db
You can fetch all as csv then convert to json or whatever

brave garnet
#

and converting via modifying url doesnt work

brave garnet
brave garnet
#

noone for mine?

#

;-;

near stratus
#

I'll delete that useless link

brave garnet
#

same - google says nothing. i was trying to use dis $#it :

/* Source: https://gist.github.com/daichan4649/8877801 */
function doGet(e) {

  var sheetName = "2";
  var sheetId   = "1XK5hkOzBZ1IYtxkPwJKQ__maOUyiwN5Gu7hIlMaIS4Y";

  var book = SpreadsheetApp.openById(sheetId);
  var sheet = book.getSheetByName(sheetName);

  var json = convertSheet2JsonText(sheet);

  return ContentService
          .createTextOutput(JSON.stringify(json))
          .setMimeType(ContentService.MimeType.JSON);
}

function convertSheet2JsonText(sheet) {
  // first line(title)
  var colStartIndex = 1;
  var rowNum = 1;
  var firstRange = sheet.getRange(1, 1, 1, sheet.getLastColumn());
  var firstRowValues = firstRange.getValues();
  var titleColumns = firstRowValues[0];

  // after the second line(data)
  var lastRow = sheet.getLastRow();
  var rowValues = [];
  for(var rowIndex=2; rowIndex<=lastRow; rowIndex++) {
    var colStartIndex = 1;
    var rowNum = 1;
    var range = sheet.getRange(rowIndex, colStartIndex, rowNum, sheet.getLastColumn());
    var values = range.getValues();
    rowValues.push(values[0]);
  }

  // create json
  var jsonArray = [];
  for(var i=0; i<rowValues.length; i++) {
    var line = rowValues[i];
    var json = new Object();
    for(var j=0; j<titleColumns.length; j++) {
      json[titleColumns[j]] = line[j];
    }
    jsonArray.push(json);
  }
  return jsonArray;
}
#

copied and modified from somewhere. but how to make json from this? url? irdk

brave garnet
#

didnt yet crashed and only this good

#

oh, sorry, got smth

#

dis jason a little works... maybe.... ok.

rich heart
#

how?

brave garnet
#

shell?

#

learn linux, then say. @rich heart

austere zealot
#
await asyncpg.create_pool(database="dbname",user="postgres",password="",host="localhost")
``` this is how im connecting to it
near stratus
#

also I don't code Python

austere zealot
tulip ledge
#

{ onCollect: (f: (buttonId: string, user: User) => void) => { onExpire: (f: () => void) => void } } typescript be like

tulip ledge
#

yes but if I can I like giving everything a type x)

#

I don't like using any

brave garnet
#

okay... this time i was trying to make a hardcore... (pithon ofc). code here:

@bot.listen("on_message")
async def scam(ctx):
  msg = ctx.content.lower()
  scamlist = 'https://script.googleusercontent.com/macros/echo?user_content_key=Efu2RvJxsVQeh3xv9Vb0RSO-d1RrZCrqjk2D1jQhhvSiWW2C47NXP0mEcyH_e7p4cccugpWX4RfPdkWhvG0kfhRvrC5l9wAqm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnA1zRMJcOWhp5p8-TrasYiLfc8s82yHYvncMdEYM4VMzrAWyr3_vgWcPkd2qwPRs1bz0TAVXLS4Dleb--x_lwbJ0QrOacq8a_9z9Jw9Md8uu&lib=Mvhguv8KrjGlroshaZkuz2rjldAiTUHuJ'
  scam = requests.get(scamlist, headers={"Accept":'application/json '}).json()
  data = scam
  for word in data:
    if word in msg:
      await ctx.delete() 

error i got :

TypeError: 'in <string>' requires string as left operand, not dict

someone know how to make this magik work?

#

i know bout this overused variable data = scam but ths shouldnt throw error btw

#

•~•;

#

noone knows .py too much?

#

;;;-;;;

tulip ledge
#

word is a dictionary

#

and needs to be a string

brave garnet
#

yep. how to convert?

#

(this data = scam had this purpose btw)

tulip ledge
#

json.dumps() I think

brave garnet
#

means? this dict have really a few values nested, so.....

pale vessel
#

that's what .json() does

tulip ledge
#

idk I don't rlly use py

brave garnet
#

its just a database to filter

earnest phoenix
#

How the data even looks like?

#

Also, requests is blocking

brave garnet
#

(and yes its this connection between google sheets, forms to collect scams and pithon)

brave garnet
#

here ya have all the db:

[{"Timestamp":"2021-08-06T16:16:08.751Z","put here stean scam: ↓↓↓":"https://steamcommunity.link/tradeoffler/?partner=1174256784&token=J7GrEW-B"},{"Timestamp":"2021-08-06T16:32:03.210Z","put here stean scam: ↓↓↓":"https://dlscord.world/steam/giveaway-nitro"},{"Timestamp":"2021-08-09T08:16:51.098Z","put here stean scam: ↓↓↓":"https://steamcommunity.link/tradofffer/new/?partner=1284276765&token=Qzk13zaHL2"},{"Timestamp":"2021-08-09T15:32:53.842Z","put here stean scam: ↓↓↓":"https://discorb.co/nitro"},{"Timestamp":"2021-08-14T18:25:13.471Z","put here stean scam: ↓↓↓":"https://discrodnitro.org/discrodgift"},{"Timestamp":"2021-08-18T09:16:24.555Z","put here stean scam: ↓↓↓":"https://discord-nitro.link/gift=8634"},{"Timestamp":"2021-08-18T18:58:42.695Z","put here stean scam: ↓↓↓":"https://steancommunity.link/tradeotfer/?partner=1278625821&token=ZssMJ7Uq"},{"Timestamp":"2021-08-18T19:19:28.111Z","put here stean scam: ↓↓↓":"https://steamcommunity.com/tradeoffer/new/?partner=333240728&token=lXk110d0"},{"Timestamp":"2021-08-21T06:40:56.972Z","put here stean scam: ↓↓↓":"https://discorb.ru.com/nitro/gift"},{"Timestamp":"2021-08-22T06:17:54.401Z","put here stean scam: ↓↓↓":"https://discorcl.click/="},{"Timestamp":"2021-08-22T10:15:12.617Z","put here stean scam: ↓↓↓":"https://freenitroi.ru/give-nitro"},{"Timestamp":"2021-08-22T11:16:05.170Z","put here stean scam: ↓↓↓":"https://discorcl.click/gift/steam"},{"Timestamp":"2021-08-22T11:19:45.200Z","put here stean scam: ↓↓↓":"https://discorcl.click/gift/steam"}]
#

converted from google forms to sheets and then to jason

earnest phoenix
brave garnet
#

jason. yes it is

#

db

#

and yes im gonna remove this question. also annoys me

earnest phoenix
#

Well, I suppose you wanna get a list of the URLs? A list comprehension would do the job, i.e., [i["put here stean scam: ↓↓↓"] for i in data]

pale vessel
#

You're requesting that file on every message?

#

That doesn't sound efficient, especially when it's blocking

brave garnet
#

urls, yes. only urls, not question, timestamp, etc. just this link, yep

#

and nothing blocks. just i got error, then i'll check

earnest phoenix
#

It really blocks, maybe it's negligible for now. It's definitely blocking though

vivid fulcrum
#

i don't think you quite understand what you're doing

brave garnet
#

i just wanted to do something good, yep?

#

and as i see -> i'll need to ask someone else

#

-_-

#

asked btw

wraith urchin
#

what do i do to fix this?

brave garnet
#

nothing. its a bug in ur ide =p

#

if throw error - just say it. red vawe doesnt yet say anything

wraith urchin
#

so what code do i enter

brave garnet
#

nothing, run and if error shows in terminal - say it (but i dont think it will)

wraith urchin
#

it shows this

#

I ran the project and it just showed that and didn't run it

brave garnet
#

semicolon? comma? try something

boreal iron
#

What’s even the sense of defining another var of your environment var?
var a = 1
var b = a
print b

vivid fulcrum
#

trying to outsmart node's JIT 🧠

boreal iron
#

Didn’t I read somewhere node‘s environment vars need to be strings, or am I wrong ?

quaint wasp
#

uhh..

#

How can I go to onather commit on github?

#

Bc I kinda did smth stupid rn

#

and need to make it go back

boreal iron
#

I wonder if the environment property can be an object… don’t think so

quaint wasp
#

..
the commits on the insgihts page just says crrunching up the data for like 4 minutes now..

boreal iron
#

(see what I mentioned above)

pale vessel
#

Check other part of your code

quaint wasp
#

very urgent

pale vessel
#

Revert the commit

quaint wasp
#

on their website

pale vessel
#

Use CLI or GitHub desktop

quaint wasp
#

i cant rn

#

not my computer 😅

pale vessel
#

You can't revert commits on web afaik

quaint wasp
#

wwhhyyyy

quaint wasp
pale vessel
#

Right click the commit

quaint wasp
#

thanks

lyric mountain
#

just select the desired commit, click on branch selector and create a new branch from there

jovial vapor
lyric mountain
#

try || instead of ??

#

that might be node version issues tho

jovial vapor
#

i havent used "??"

#

i make the token thingy and put just the token in it

#

thats all

#

im sorry if im being dumb or something, havent touched bots in a fat minute

pale vessel
#

You need node 16.6 for Discord.js v13

rose warren
#

But that client doesn't look like V13

pale vessel
#

They should upgrade I suppose

jovial vapor
rose warren
#

Well it's wrong then

#

But the problem is most definitely related to the node version

#

In this case

pale vessel
#

You need that to use v16.6 on repl.it

#

And the ?? operator isn't supported on node 12 which is what repl.it uses

rose warren
#

You can get node v16.4 on replit apparently

#

But you need Tim's hak to get 16.6

pale vessel
#

Wonder why they use an old version by default

boreal iron
#

Well, never change a running system oldEyes

rose warren
#

Yeah. I have a friend who started djs dev a couple of days ago on replit and she only managed to get v16.4. So I asked Tim for his link.

quartz kindle
#

btw i have another one as well

#

the previous one runs on NIX and relies on fetching their unstable repo, which is slow af
this one runs on bash and downloads the node tarball directly, and you can configure the exact version and file you want

wraith urchin
#

jibakoma is fixed 😄

quartz kindle
#

lmao

#

its a pain tho that you cant change repl.it's PATH variable programatically

#

you can change it for the script itself, but not for the console

thorny flume
#

how can I know how long each user has been on call?

lyric mountain
#

gambiarra at its finest

sudden geyser
#

So you could watch for when members join a voice channel and record the timestamp

tulip ledge
#

If you do it over alot of channels/guilds you'll prob run into ratelimit issues tho

thorny flume
#

ok...

#

20 channels voices

#

lol

lyric mountain
#

getting whether an user is in a voice channel doesn't cause ratelimit ig

tacit sundial
#

I'm getting the "RuntimeError: PyNaCl library needed in order to use voice" error, I installed PyNaCl but somehow I think the install is not correct, it shows me this:

#

anyone knows how to fix this

calm stone
#

how would i do that

  const voteuser = vote.user
  voteuser.send('Thx for voting!') 
sudden geyser
#

vote.user is probably going to be a user ID, so you'd send a message to a user by ID

#

e.g. client.users.fetch(...).then((user) => user.send(...))

calm stone
sudden geyser
#

Then you'll want to use the webhooks API

calm stone
sudden geyser
boreal iron
#

Doesn’t that only work for approved bots?

sudden geyser
#

yeah

#

but you aren't going to be getting votes from an unverified bot

calm stone
sudden geyser
#

yes

#

by verify I mean get approved on top.gg

calm stone
boreal iron
#

Expect this approval taking a few days/weeks

quartz kindle
#

hmm creating a cache for discord is proving to be much more complicated than i thought

boreal iron
#

Do u still maintain djs-light btw?

#

Just to know…

quartz kindle
#

for djs v13 yes

#

aka djs-light v4

#

for v14 likely not

boreal iron
#

Just tried to download the tarball a few days ago and got a file not found error

quartz kindle
#

wut

boreal iron
#

ffs discord mobile trash

pale vessel
#

wat

boreal iron
#

Discord and a slowly mobile connection is pain

#

I can see my message be sent like 10 times

#

But couldn’t edit it or do anything else

#

Pffff

#

Not sure if that message has made it through

#

Just tried to download the tarball a few days ago and got a file not found error

rose warren
#

It did

boreal iron
#

Tried to install the GitHub tarball via npm and it failed

quartz kindle
#

djsl?

boreal iron
#

Yeah

quartz kindle
#

weird

#

anyway you can install it from npm directly, no need for github

boreal iron
#

Tried a few days later again, same result

#

Hmm yeah well as I said I found out I don’t need to deal with caching for the bots size

#

Just wasn’t sure about it until now

#

This fucking country and it’s mobile connection outtakes…
Worse than any 3rd world country, I promise notlikenoot

quartz kindle
#

lmao

quartz kindle
#

he told you how to do it lol

boreal iron
#

Btw don’t you actually sleep sometimes, Tim? oldEyes

thorny flume
# quartz kindle he told you how to do it lol

I know, but I'm having problems with the callback. I'm getting an array with a "VoiceState " object that gives me the user id, guild information that the user connected to the voice channel, but that's not the problem. Problem is, timestamps keep guild information and not along with the user information are these timestamps when the user joins the guild or when connected to the voice channel?

rose warren
quartz kindle
#

Lol

#

i do sleep, and very well

#

which btw gonna be in a few mins

quartz kindle
#

when a user joins voice, create a timestamp and add it to the voicestate

#

when the user leaves, get the timestamp from the voicestate and see how much time passed

thorny flume
boreal iron
#

I knew it, he’s a bot

thorny flume
#

I created an "if" that takes the value of "if ternary" and the value is "online / offline" and when that "if" is true for "online" it starts a 5 minute setInterval to add coins for a user, but this setInterval does not deactivate when a user leaves the voice channel, how can i deactivate it?

tulip ledge
#

clearInterval

boreal iron
#

Just add a property to the client’s voice state object.

thorny flume
#

but it works like this:

if(verific_on_1 === 'online') {
            setInterval(function() {
                console.log(`adicioned 5`)
            })
        }
tulip ledge
#

You will want to save the interval somewhere so you can clear it

thorny flume
#

how do I do that?

tulip ledge
#

I legit told u

thorny flume
#

let interval = '300000'

#

?

tulip ledge
#

You will want to save the interval

#

what makes u think u want to save a string of 300000?

thorny flume
#

hm....

#

lol

#

is the value of milliseconds

boreal iron
#

At the moment the user changes it’s voice state just add a new property to the member/user object including the current timestamp (he joined/left a channel)

tulip ledge
#

If you set a new key to the object will it transfer over to the next time the event triggers?

thorny flume
tulip ledge
#

Yes but I mean

#

in the when join call event thingy if you set a key to the user

thorny flume
#
const verific_on_1 = verific_channel_1_new === channel_1 ? 'online' : 'offline'
tulip ledge
#

it won't transfer over to the leave call thingy

#

so what FakE said is wrong

thorny flume
#

ok

boreal iron
tulip ledge
#

ahhh you meant the client

thorny flume
split hazel
#

so I'm writing a raw array implementation and I'd need to be able to tell the difference between the number 0 and "null" aka empty. to do this would i need to keep a separate list which specifies if a specific index is empty or not?

tulip ledge
#

I thought u meant the client.on("blabal", parameter => parameter.balba)

tulip ledge
split hazel
#

this isn't really specific to a language but rather the context is an empty element is initialised with a 0

tulip ledge
#

wdym?

split hazel
#

I'm working in an osless environment and I'm implementing an array (which is just a sequence of memory registers) and those registers are 0, id want to tell the difference if an element is 0 or is empty

#

it sounds like a trivial question but it's quite tricky

tulip ledge
#

so you want to know if the memory register is empty?

boreal iron
#

Well convert the element to a boolean

split hazel
#

that'd turn into a 0 😂

boreal iron
#

null is always null, but 0 is false

tulip ledge
#

null stays null?

#

the more you learn

thorny flume
#

@tulip ledge I can do something like this:

const interval = setInterval(function() {
  console.log(`adiconed 5`)
}, 3000000)

interval.clearInterval

?

tulip ledge
#

no clearInterval is a function

split hazel
#

actually I have an idea

thorny flume
#

hm

split hazel
#

what if I allocate an extra byte for each element and just before that element, set a 1 or 0 to figure out if its empty or not

#

that way I save another block allocation

tulip ledge
#

still how are u gonna determine to put a 1 or a 0?

split hazel
#

that byte will be set to 1 as soon as the "element" is occupied which would tell me if its truly empty or not

tulip ledge
#

ahhh I get it now

split hazel
#

I have direct access to each individual memory register which lets me do that

tulip ledge
#

So you're setting all to 0 but when you store something you put it to 1?

#

Am I getting it right?

split hazel
#

yeah pretty much

#

to know its truly a 0

tulip ledge
#

Yeah I mean that could work

#

I don't see a better option

split hazel
#

I might go back to high level programming soon before I go crazy with no operating systems

boreal iron
#

null is something "else" in this context like the fat and ugly kid no one wants to play with oldEyes

tulip ledge
#

kekw

split hazel
#

null is really just a 0 lmao

#

but high level languages abstract it to actually check if something is "empty"

boreal iron
#

0 can be parsed to a boolean, null can’t

boreal iron
#

aka. ISSET

quartz kindle
split hazel
#

a single type, can be an int for example

quartz kindle
#

so int or null?

#

or just int?

split hazel
#

there isn't really a null in my environment lmao

crimson oracle
#

is repl good for hosting bots?
I tried switching because i heard it was bad for hosting bots

quartz kindle
#

if its a typed array, then it cant really hold null if its declared as int

#

so there is no null vs 0

split hazel
#

just so you know this is an osless environment with me interacting with each memory register individually

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

you want to make a sparse array?

split hazel
#

there isn't really a null, you could call it 0

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

a sparse array would be a non-contiguous array, which can hold empty values

#

a normal fixed-length array cannot hold empty values

split hazel
#

because c++ doesn't really have proper arrays (at least ones that don't only accept built in types), I'm making an array which you create with a specific type and length

quartz kindle
#

how doesnt it?

split hazel
#

I call them btec arrays

#

an "array" there is just a sequence of memory registers there is no real catch to it

#

you might as well just do 0x1 = 1 0x2 = 2 except its made easier with that

#

so I'm making an abstracted array

quartz kindle
#

yes but what are you trying to do that you cant do with vectors for example?

split hazel
#

I don't have access to the standard environment

quartz kindle
#

ah

split hazel
#

I have to write them myself lol

quartz kindle
#

on the heap or on the stack?

split hazel
#

the heap, wrote a simple heap allocator and deallocator

quartz kindle
#

fixed length and single type?

split hazel
#

yeah

quartz kindle
#

then just write the type info in some header no?

split hazel
#

I will eventually get to making vectors

#

and huh?

#

I'm using templates to define the elements types

quartz kindle
#

for example you want to create an array of int32 of size 10, your array would be something like 41 or 42 bytes long, with first 1-2 bytes defining the array metadata, like type and length, followed by the raw int32 bytes

thorny flume
#

@tulip ledge

#
const interval = setInterval(verifications, 10)

        function verifications() {
            if(verific_on_1 === 'online') {
                console.log(`adicioned 5`)
            }else {
                setTimeout(function() {
                    clearInterval(interval)
                    console.log(`stoped`)
                })
            }
        }
quartz kindle
#

the array would be initialized to zeroes

#

there would be no concept of "empty"

split hazel
#

which is why I'm adding a byte before each element to figure out if its empty or not

#

either a 1 or 0

quartz kindle
#

why do you need this distinction tho?

thorny flume
#

does not stop even after setting setTimeout. didn't stop with the function itself, so I decided to do that @tulip ledge

quartz kindle
#

arrays of fixed types usually cannot have empty values

split hazel
#

yeah but this is rather unique

#

could call them js arrays almost

quartz kindle
#

well then its a dynamic array with dynamic type

boreal iron
#

Huh where the fuck did that message go?!

quartz kindle
#

in that case yes, prefix each item with a byte

#

if you're gonna have variable length items, use the byte to write each item's type and length

split hazel
#

a dynamic type array would be a mess to implement lmao (though wouldn't need it anyways)

#

they're just gonna store a single type no need

#

I can't really think of a use case where an array would need multiple types here

quartz kindle
#

well, a full byte to hold only 1 bit is kind of a waste of space

#

another way would be to define a number that you're guaranteed to never use, and use that number to represent empty lol

#

another way would be to use signed numbers, and have negative values represent empty

#

since signed only occupies 1 bit, rather than 1 full byte

split hazel
#

it is a waste

#

and I did think of those but they just don't feel right lmao

#

I might consider though

quartz kindle
#

there pretty much isnt any other option

#

unless you set a bitfield in the array header or something

#

as long as the number of items

#

well im off to bed, good luck!

bright thorn
#
 SyntaxError: INVALID_TYPE: Invalid MessageComponentType                                          │
│                                          ││ . >     at Function.create (/home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/interfac  │
│                                          ││ . >     at /home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/MessageActionRow.js:18:77  │
│                                          ││ . >     at Array.map (<anonymous>)                                                                   │
│                                          ││ . >     at MessageActionRow.setup (/home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/M  │
│                                          ││ . >     at new MessageActionRow (/home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/Mes  │
│                                          ││ . >     at Function.create (/home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/interfac  │
│                                          ││ . >     at /home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/Message.js:10:81           │
│                                          ││ . >     at Array.map (<anonymous>)                                                                   │
│                                          ││ . >     at ExtendedMessage._patch (/home/ubuntu/real/node_modules/discord-buttons/src/v12/Classes/M  │
│                                          ││ . >     at new Message (/home/ubuntu/real/node_modules/discord.js/src/structures/Message.js:44:20)

my bot is dead after sending this

split hazel
bright thorn
#

can anyone tell me about this errr

split hazel
bright thorn
#

where is this exactly trouble idk

boreal iron
#

Ur creating a message component somewhere obviously for a button or similar and passing a wrong type to it

bright thorn
#

in help cmd

boreal iron
#

There are only 3 types

bright thorn
#

thnq

boreal iron
bright thorn
#

i can send help cmd

#

can you check

boreal iron
#

Well at least the part which contains your message component stuff

bright thorn
boreal iron
#

Nope but I don’t think there are many places in your code you’re defining message components

boreal iron
#

Could also be your button package is outdated

bright thorn
#

?

wintry wing
#

Does anyone know the channel and role limit for discord?

bright thorn
#

how can i update ?

vivid fulcrum
wintry wing
boreal iron
boreal iron
stuck star
#

in my bot i set status is how many members the bot watching but it shows only 2

#

Actually that is in 15 servers

#

Can any one help

bright thorn
sage bobcat
#

One message removed from a suspended account.

stuck star
#

Y

bright thorn
wheat mesa
#

You never posted your code for that

worn sonnet
#

'2021-06-25T11:29:04.697236+00:00'

#

in which format is this datetime

#

i'm trying to convert it into datetime object

worn sonnet
#
datetime.strptime('2021-06-25T11:29:04.697236+00:00', '%Y-%m-%d %H:%M:%S')

I'm using python

#

Apparently I need to write the correct format here '%Y-%m-%d %H:%M:%S'

#

Nvm figured it out

earnest phoenix
#

What or how would I do to enable all intents on my bots code?

worn sonnet
wheat mesa
#

He means when instantiating a Discord client with v13

earnest phoenix
#

^

queen needle
#

I may be wrong but isn't it

intents: Object.values(Intents.FLAGS).reduce((a, p) => a | p, 0)
near stratus
latent heron
#

why are you using a pure int code for intents

#

use bit shifted types

near stratus
latent heron
#

people who use the exact flag data type for intents are psychologically impaired

#

please don't actually do that

#

we build enumerables and data classes specifically so that we can do relative imports of what's written from the dev docs

#

i know absolutely nobody who wants to do calculation for each of these

#

based people will always default their intents as a 513 status

sharp sail
#

!stary

#

!start

latent heron
#

what part of this channel looks like you run commands in it

#

you have the ability to read the whole convo above but you still ran commands

earnest phoenix
#

Okay, so I used

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS
  ]
});```

and that works, well, to the point where I do not get a error, I am trying to have it dm a user who joins the server, my djs and node are updated, but it does not log nor send the user a message when they join, both my Dev Portal intents are enabled, and I used the one above, how can i fix this?
latent heron
#

is there not a default flag for intents in d.js

wheat mesa
near stratus
#

It's privileged

latent heron
#

oh jfc

earnest phoenix
#

Ahhhh

#
 throw new RangeError('BITFIELD_INVALID', bit);
    ^
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.```
#

Nvm

latent heron
#

why does d.js handle intents so cancerous

earnest phoenix
#

Figured it out.

latent heron
#

do they actually force you to throw the intent flags in a list accumulatively?

near stratus
#

yes

wheat mesa
#

Welcome to discord.js

earnest phoenix
#

Okay, no I made it worse

wheat mesa
#

Glad I swapped KEKW

wheat mesa
#

Well, what’s your code?

earnest phoenix
#
const Discord = require("discord.js");
const { Client, Intents } = require('discord.js')
const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS, Intents.GUILD_MEMBERS, Intents.GUILD_MEMBER_ADD
  ]
});
wheat mesa
#

Intents.FLAGS

near stratus
#

bruh

earnest phoenix
#

pfft

#

whaaat

near stratus
#

Intents.FLAGS.BRRRRRR

wheat mesa
#

You need to use Intents.FLAGS.INTENTNAME

latent heron
#

why

#

why would d.js devs do this

near stratus
#

v13 fact

latent heron
#

surely they've never heard of automatically adding bit shift fields right?

#

at least gotta give them a reason for a poor design choice like that

near stratus
#

They used to be like

intents: [
  "GUILD_MEMBERS"
]

in v12
Then they changed it to that shit above
Surely there was a reason which I'm too smol brained to understand

earnest phoenix
#

Yeah

#

Exactly lmao

#

Okay, it still does not work LOL

#

Won't Dm the user when they join

#

Literally, ALL INTENTS ARE ENABLED

wheat mesa
#

Show code once again

earnest phoenix
#
const Discord = require("discord.js");
const { Client, Intents } = require('discord.js')
const client = new Client({
  intents: [
    Intents.FLAGS.GUILD_MEMBERS
  ]
});```
near stratus
#

where you're dming the user

earnest phoenix
#
 
  client.on('guildMemberAdd', member => {
       member.send(`Welcome to the server, ${member}!`);
       console.log(`${member.user.username} has joined`);
});
  
#

Doesn't even log it

wheat mesa
#

Try enabling the DIRECT_MESSAGES intent

#

(Along with your other intents)

#

Wait I’m big dumb you need to enable the GUILD_MEMBERS intent

#

(Thanks @earnest phoenix)

near stratus
earnest phoenix
#

It already is.

#
/rbd/pnpm-volume/cf881cdc-642a-4e14-bf0e-3c1abb6f6bf1/node_modules/discord.js/src/util/BitField.js:152
    throw new RangeError('BITFIELD_INVALID', bit);
    ^
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.
    at Function.resolve (/rbd/pnpm-volume/cf881cdc-642a-4e14-bf0e-3c1abb6f6bf1/node_modules/discord.js/src/util/BitField.js:152:11)
    at /rbd/pnpm-volume/cf881cdc-642a-4e14-bf0e-3c1abb6f6bf1/node_modules/discord.js/src/util/BitField.js:147:54
    at Array.map (<anonymous>)
    at Function.resolve (/rbd/pnpm-volume/cf881cdc-642a-4e14-bf0e-3c1abb6f6bf1/node_modules/discord.js/src/util/BitField.js:147:40)
    at Client._validateOptions (/rbd/pnpm-volume/cf881cdc-642a-4e14-bf0e-3c1abb6f6bf1/node_modules/discord.js/src/client/Client.js:546:33)
    at new Client (/rbd/pnpm-volume/cf881cdc-642a-4e14-bf0e-3c1abb6f6bf1/node_modules/discord.js/src/client/Client.js:73:10)
at Object.<anonymous> (/app/index.js:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  [Symbol(code)]: 'BITFIELD_INVALID'
}```
#
onst Discord = require("discord.js");
const { Client, Intents } = require('discord.js')
const client = new Client({
  intents: [
    Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_MEMBER_ADD
  ]
});```
near stratus
#

I'm sure guild member add isn't a thing

wheat mesa
#

Get rid of Intents.FLAGS.GUILD_MEMBER_ADD

#

it’s a partial

latent heron
#

this might work

wheat mesa
#

You already have GUILD_MEMBERS, so you don’t need the partial

latent heron
#
intents: [Intents.FLAGS.GUILDS_MEMBERS | Intents.FLAGS.DIRECT_MESSAGES]
#

are you guys allowed to do this in JS?

earnest phoenix
wheat mesa
#

Uhhh

latent heron
#

its a combiner term

#

| acts as a way to conjoin

#

works at least on ints from what i remember

near stratus
#

@earnest phoenix
Wait a minute
Have you created the dm before sending the message ?

wheat mesa
#

His problem is that GUILD_MEMBER_ADD is not an intent

latent heron
#

isn't that a partial intent

near stratus
#

Also The event isn't firing at all

latent heron
#

he needs the typing intents iirc

#

GUILD_MESSAGE_TYPING | DIRECT_MESSAGE_TYPING

#

although that might be triggering the typing state of the application instead of reading for the typing

near stratus
wheat mesa
#

I don’t believe he needs those lol

earnest phoenix
near stratus
#

So I tried with my bot only with "GUILD_MEMBERS" intent and it's working

#

I'm just logging the members rn

earnest phoenix
#

Whats a more "updated" command handler? As mine may just be the issue.

wheat mesa
#

Your command handler shouldn’t matter if it’s just an event firing or not

#

The user isn’t using a command, so nothing should be passing through your command handler

#

And you’re not using an event handler from what I saw

#

You need the channel partial enabled

#

In theory that’s the issue @earnest phoenix

earnest phoenix
#

I don't have a general event handler no.

wheat mesa
earnest phoenix
#

Oh, okay.

#

const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES"], partials: ["CHANNEL"] });

#

This should work, correct?

mild agate
#

probably

earnest phoenix
#

It works, for commands

#

it didnt before

#

now just the event isn't working

#

im trying to make my bot respond to a dm but none of the intents seem to be working

#

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES] });

earnest phoenix
wheat mesa
#

Uh

wheat mesa
earnest phoenix
wheat mesa
#

Oh whoops I responded to the wrong message

earnest phoenix
#

The event still doesn't work @wheat mesa

wheat mesa
#

Show your exact code

#

For the event and the client

earnest phoenix
#
const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES", "GUILD_MEMBERS"], partials: ["CHANNEL"]  });

const http = require("http");
const express = require("express");
const app = express();
const fs = require("graceful-fs");
const config = require("./config.json");

/*
 app.get("/", (request, response) => {
  console.log(Date.now() + " Ping Received");
  response.sendStatus(200);
});
*/

var server = require("http").createServer(app);
const listener = server.listen(process.env.PORT, function() {
  console.log("Your app is listening on port " + listener.address().port);
});

client.on("ready", async () => {
  client.user.setActivity(`Alena Staff`, {
    type: "WATCHING"
  });
  console.log(`logged in as ${client.user.tag}`);
});

client.commands = new Discord.Collection();

const commandFiles = fs
  .readdirSync("./commands")
  .filter(file => file.endsWith(".js"));

for (const file of commandFiles) {
  const command = require(`./commands/${file}`);
  client.commands.set(command.name, command);
}

const cooldowns = new Discord.Collection();



client.on("messageCreate", message => {
  let prefix = config.prefix; 
 
    
  if (message.content.indexOf(prefix) !== 0) return;
  
  const args = message.content.slice(prefix.length).split(/ +/);
  const commandName = args.shift().toLowerCase();

  const command =
    client.commands.get(commandName) ||
    client.commands.find(
      cmd => cmd.aliases && cmd.aliases.includes(commandName)
    );

  if (!command) return;

  if (command.guildOnly && message.channel.type !== "text") {
    return message.reply("I can't execute that command inside DMs!");
  }

  if (command.admin && !config.administrators.includes(message.author.id)) {
    return message.reply("You must be an administrator to run this command!");
  }
  if (command.args && !args.length) {
    let reply = `You didn't provide any arguments, ${message.author}!`;

    if (command.usage) {
      reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;
    }

    return message.channel.send(reply);
  }

  if (!cooldowns.has(command.name)) {
    cooldowns.set(command.name, new Discord.Collection());
  }

  const now = Date.now();
  const timestamps = cooldowns.get(command.name);
  const cooldownAmount = (command.cooldown || 3) * 1000;

  if (timestamps.has(message.author.id)) {
    const expirationTime = timestamps.get(message.author.id) + cooldownAmount;

    if (now < expirationTime) {
      const timeLeft = (expirationTime - now) / 1000;
      return message.reply(
        `please wait ${timeLeft.toFixed(
          1
        )} more second(s) before reusing the \`${command.name}\` command.`
      );
    }
  }

  timestamps.set(message.author.id, now);
  setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);

  try {
    command.execute(message, args, client);
  } catch (error) {
    console.error(error);
    message.reply("there was an error trying to execute that command!");
  }
  
  client.on('guildMemberAdd', member => {
       member.send(`Welcome to the server, ${member}!`);
       console.log(`${member.user.username} has joined`);
});
  
  
 
  
});

wheat mesa
#

I didn’t mean the whole thing but that works I guess

#

Makes sense why it’s not working now

#

You have your guildMemberAdd event inside of your messageCreate event

#

Which is not correct

civic scroll
#

var

#

@clear marlin

#

but i can't snap the triangle onto the right of the box

#

:(

wheat mesa
civic scroll
#

the SVG doesn't have extra space for it

#

idk why

earnest phoenix
#

I'd think something like; client.guilds.cache.get('').then( client.on('guildMemberAdd) )

#

or something of the sort.

wheat mesa
#

Uh

#

No

civic scroll
wheat mesa
#

^^

earnest phoenix
#

pfft lol

#

pffft whaat

wheat mesa
#

Pseudocode

earnest phoenix
#

Whaaat

civic scroll
#

it's more like an idea

wheat mesa
#

Yeah

earnest phoenix
#
Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. The rules of Pseudocode are reasonably straightforward. All statements showing "dependency" are to be indented. These include while, do, for, if, switch.
civic scroll
#

first off you need a config contains a list of notify servers

earnest phoenix
#

Okay.

civic scroll
#

so we have a list: Array<String>

#

then on guildMemberAdd event (async member)

earnest phoenix
#

Alright

wheat mesa
#

Another seasoned Array<T> user and not T[]

civic scroll
#

if list contains guild.id of member

#

member send dms

earnest phoenix
#

?

civic scroll
earnest phoenix
#
client.on("guildMemberAdd", (member) => {
  member.send("message")
})
civic scroll
#

that throws a ReferenceError

earnest phoenix
#

I am deceased

#

is that what you want

wheat mesa
#

The .includes() method is for arrays, to see if an array contains a specific entry

earnest phoenix
earnest phoenix
civic scroll
#

@earnest phoenix alright so

on event 'guildMemberAdd' func (async member)
    const targetServerList = getIDSomewhere() // array
    if (targetServerList.includes(member.guid.id))
        return // send dms
#

this is peudocode btw

#

you have to implement it yourself

earnest phoenix
#

So

#

client.on('guildMemberAdd', member => {
  const targetServerList = ['878722964428816474']
       if (targetServerList.includes(member.guid.id))
        return
       console.log(`${member.user.username} has joined`);
});```
#

?

wheat mesa
#

Seems about right

earnest phoenix
#

WAit

#

oh, nvm

#

Yep

#

Lemme try it

wheat mesa
#

Make sure to take your guild member add event out of your message event if you haven’t already btw

civic scroll
#

also

#

get the array somewhere

#

instead of static definition like that

wheat mesa
#

^^

#

If it’s for like a couple servers that’s fine, but more than that and it gets messy

civic scroll
wheat mesa
#

Oh god

civic scroll
#

i honestly dk what to start with

wheat mesa
#

Honestly web dev hurts me

civic scroll
#

i know nothing about CSS

wheat mesa
#

I know the very basics of CSS

#

I struggle with HTML

#

I need to learn web dev eventually though

earnest phoenix
#

Doesnt work @wheat mesa @civic scroll

wheat mesa
#

What specifically doesn’t work

earnest phoenix
#

The DM

#

client.on('guildMemberAdd', member => {
  const targetServerList = ['878722964428816474']
       if (targetServerList.includes(member.guid.id))
        return
  member.send(`Are you getting this?`)
 
  });```
#

No error

#

no

#

dm

wheat mesa
#

You didn’t spell member.guild.id correctly

earnest phoenix
#

lmao, I didn't spell ittt

wheat mesa
#

Unless my discord mobile is cutting it off somehow

earnest phoenix
#

LMAO

#

Waffle, im full of your jokes lol

#

Get it

#

nvm

#

To hard of a joke to explain

#

Lmao, ill go try it now

#

Still doesn't work.

civic scroll
#

this is why you use typescript to code

wheat mesa
#

Lmao true

#

But VSC still would’ve caught that even for js

earnest phoenix
#

No error, just doesn't DM.

civic scroll
#

also don't leave / join manually

#

you can emulate the events

earnest phoenix
#

huh?

wheat mesa
#

Show your full code again

earnest phoenix
wheat mesa
#

Oh

#

Glitch

earnest phoenix
#

});

client.on('guildMemberAdd', member => {
  const targetServerList = ['878722964428816474']
       if (targetServerList.includes(member.guild.id))
        return
  member.send(`Are you getting this?`)
 
  });
civic scroll
wheat mesa
#

You’re sure your guild members intent is on on the dev dashboard?

earnest phoenix
wheat mesa
#

And you moved the guildMemberAdd event outside of your messageCreate event, right?

earnest phoenix
#

Yep

#

Thats the }); at the top lol

wheat mesa
#

Try logging something at the very top of the guildMemberAdd event just to see if it even fires

civic scroll
#

debugger 👏 breakpoints 👏

wheat mesa
#

He’s using glitch

#

I don’t think that has a debugger

#

Does it?

civic scroll
#

glitch had breakpoints

wheat mesa
#

Ah ok

civic scroll
#

just as not as powerful

wheat mesa
#

Btw, glitch doesn’t want you to host discord bots on their site

#

iirc

#

Can get you API banned

earnest phoenix
wheat mesa
#

From discord

earnest phoenix
#

o-o

#

how?

vivid fulcrum
#

well

#

it can get the ip banned

#

not the actual account

unreal compass
earnest phoenix
#

o-o

#

Wym by that @unreal compass ?

unreal compass
#

lol i just wanted to add on because i have researched on it before 🙂

earnest phoenix
#

Oh, I have glitch premium-

unreal compass
earnest phoenix
#

Yep

unreal compass
#

nice

earnest phoenix
#

So not against ToS nor is it going "off/on/off/on"

unreal compass
#

yesh

#

it's always on so yeah

#

cool

earnest phoenix
#

Yep! 👍

#

Sooo, any help wit my situation?

wheat mesa
#

Have you tried logging to see if the event fires?

#

(I would suggest the debugger, but that’s a lesson for a different time)

earnest phoenix
#

Okay.

wheat mesa
#

If the event triggers and doesn’t dm the member, then something is wrong with your code logic, but if it doesn’t fire then it’s a different issue

earnest phoenix
#

Didn't fire @wheat mesa

wheat mesa
#

Show your intents again

earnest phoenix
#
const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES", "GUILD_MEMBERS"], partials: ["CHANNEL"]  });

const http = require("http");
const express = require("express");
const app = express();
const fs = require("graceful-fs");
const config = require("./config.json");

/*
 app.get("/", (request, response) => {
  console.log(Date.now() + " Ping Received");
  response.sendStatus(200);
});
*/

var server = require("http").createServer(app);
const listener = server.listen(process.env.PORT, function() {
  console.log("Your app is listening on port " + listener.address().port);
});

client.on("ready", async () => {
  client.user.setActivity(`Alena Staff`, {
    type: "WATCHING"
  });
  console.log(`logged in as ${client.user.tag}`);
});

client.commands = new Discord.Collection();

const commandFiles = fs
  .readdirSync("./commands")
  .filter(file => file.endsWith(".js"));

for (const file of commandFiles) {
  const command = require(`./commands/${file}`);
  client.commands.set(command.name, command);
}

const cooldowns = new Discord.Collection();



client.on("messageCreate", message => {
  let prefix = config.prefix; 
 
    
  if (message.content.indexOf(prefix) !== 0) return;
  
  const args = message.content.slice(prefix.length).split(/ +/);
  const commandName = args.shift().toLowerCase();

  const command =
    client.commands.get(commandName) ||
    client.commands.find(
      cmd => cmd.aliases && cmd.aliases.includes(commandName)
    );

  if (!command) return;

  if (command.guildOnly && message.channel.type !== "text") {
    return message.reply("I can't execute that command inside DMs!");
  }

  if (command.admin && !config.administrators.includes(message.author.id)) {
    return message.reply("You must be an administrator to run this command!");
  }
  if (command.args && !args.length) {
    let reply = `You didn't provide any arguments, ${message.author}!`;

    if (command.usage) {
      reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;
    }

    return message.channel.send(reply);
  }

  if (!cooldowns.has(command.name)) {
    cooldowns.set(command.name, new Discord.Collection());
  }

  const now = Date.now();
  const timestamps = cooldowns.get(command.name);
  const cooldownAmount = (command.cooldown || 3) * 1000;

  if (timestamps.has(message.author.id)) {
    const expirationTime = timestamps.get(message.author.id) + cooldownAmount;

    if (now < expirationTime) {
      const timeLeft = (expirationTime - now) / 1000;
      return message.reply(
        `please wait ${timeLeft.toFixed(
          1
        )} more second(s) before reusing the \`${command.name}\` command.`
      );
    }
  }

  timestamps.set(message.author.id, now);
  setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);

  try {
    command.execute(message, args, client);
  } catch (error) {
    console.error(error);
    message.reply("there was an error trying to execute that command!");
  }

});

client.on('guildMemberAdd', member => {
  const targetServerList = ['878722964428816474']
       if (targetServerList.includes(member.guild.id))
        return
  member.send(`Are you getting this?`)
 console.log(`I'm receiving you houston.`)
  });```
#

Literally the full thing, there ya are.

wheat mesa
#

I’m gonna assume there’s something wrong with your intents

earnest phoenix
#

Such as?

wheat mesa
#

I’m not sure, I haven’t tested intents all that much in djs

#

Try just using all intents

#

I believe you should just be able to do “ALL”

earnest phoenix
#

Nope

wheat mesa
#

I’m out of ideas

#

Precisely why I don’t use djs KEKW

slender thistle
#

Nah you just dum

wheat mesa
#

Probably

#

It’s probably an intents issue if the event isn’t being fired

earnest phoenix
slender thistle
#

I wasn't reading this convo before Waffle's message about djs

#

Have you logged a member/user under the specified ID?

wheat mesa
#

His guildMemberAdd event isn’t firing entirely

earnest phoenix
#

It's not firing at all 🤣

slender thistle
#

Ah right

#

Is the members intent enabled on dev portal?

#

I would assume it is

#

Because it wouldn't run otherwise

#

Dumbass me

earnest phoenix
#

Yep

#

It is

slender thistle
#

One sec

#

I wonder if we have d.js to blame or Discord

earnest phoenix
#

Alright, if thats the case, Im getting my lawyers READYYYY

#

jkjk

#

but erm

slender thistle
#

🤣

earnest phoenix
#

Ill try enabling pnpm

slender thistle
#

Try only setting the members intent

earnest phoenix
#

Not restricted to a server?

worn sonnet
#

is anyone familiar with argparse python?

slender thistle
#

Wdym restricted to a server

wheat mesa
#

Didn’t v12 have a bug where guildMemberAdd didn’t work?

worn sonnet
#

I'm trying to create a simple command line script

pale vessel
#

Why use V12?

worn sonnet
#
python search.py --twitter "Hello"```
wheat mesa
worn sonnet
#
parser = argparse.ArgumentParser()

    twitter = parser.add_argument_group(title="Twitter", description="Search for twitter tweets retweet")
    # twitter.add_argument("-t", "--twitter")
    twitter.add_argument("-q", "--query", type=str, help="Query for to search for", required=False)
    twitter.add_argument("-c", "--count", type=int, help="The number of tweets to look for", default=100,
                         required=False)

    discord = parser.add_argument_group(title="Discord",
                                        description="Searches for messages in a channel for a Discord username")
    discord.add_argument("-d", "--discord", type=str, help="Search for Discord member messages in particular channel",
                         required=False)
    discord.add_argument("-u", "--username", type=str, help="Discord username whose messages to be searched",
                         required=False)
    discord.add_argument("-ch", "--channel", type=int, help="The number of tweets to look for",
                         required=False)

    cli_args = parser.parse_args()```
#

What is the correct way to do it?

earnest phoenix
#

my code is above^

pale vessel
#

It's either -t or --twitter, -twitter isn't valid

worn sonnet
#

typo there

pale vessel
#

Isn't -twitter "Hello" same as -t -w -i -t -t -e -r "Hello"?

#

Ah

slender thistle
#

You've tried so hard

pale vessel
slender thistle
#

And got so far...

worn sonnet
#

There are two commands

vivid fulcrum
#

so my permissions checking suddenly broke and i had been debugging for 4 hours just to realize that the permissions int overflows on gateway v9

worn sonnet
vivid fulcrum
#

and that now i have to use ulongs

pale vessel
#

What problem do you have with it

vivid fulcrum
#

so that's fun

pale vessel
#

Aren't permission ints in strings now?

vivid fulcrum
#

yup

#

ulongs are native to c# though so the string is converted to a number again

#

and i overlooked that change

#

left the type as int32

#

when i should've updated it to u_int64

pale vessel
#

Did they not include that change in the changelog

vivid fulcrum
#

they probably did i'm just blind as shit

earnest phoenix
#

React 18 question:
I want to lazily render a component that fetches data from the server and display a fallback component while it's loading.
What's the best way of doing it?

I'm thinking of this:
A useEffect callback that fetches data and re renders the component when mounted. Then I can display a fallback from the component's render function itself.

opaque sentinel
#

how do i make my leave a server? (js)

near stratus
near stratus
earnest phoenix
near stratus
vivid fulcrum
#

it's been fairly stable for me