#development

1 messages · Page 1825 of 1

nimble kiln
#

mhm

#

Well then i dont know an easy way to test if it auto restarts 😛

wheat mesa
#

Yeah there's no real good way to crash it

#

Thankfully haha

nimble kiln
#

That's what an eval command is good for

#

eval process.exit(1) :]

wheat mesa
#

I'll add one in the future

#

For now though, it happens to be 3:08am for me

nimble kiln
#

You should limit that command only to you tho

wheat mesa
#

Yeah

nimble kiln
#

ok good 😄

wheat mesa
#

I'm gonna head to bed

#

Thank you so so much for helping me get my bot working 🙂

nimble kiln
#

Alright gn 🙂

rocky hearth
#

does mongodb supports typescript?

sly sierra
wheat mesa
#

Okay I can’t sleep so I’m back to ask some more questions

#

Does anyone know the bandwidth limit for the free tier of AWS EC2?

#

And/or any sort of hidden fees/charges I might run into while hosting a bot on it

jade epoch
#
var findTargetQuery = `SELECT mtg_user.mtg_userID, mtg_user.mtg_health, mtg_user.mtg_guilds, mtg_gamedata.mtg_currentBattlefield, mtg_gamedata.mtg_currentHand FROM mtg_user, mtg_gamedata WHERE mtg_user.mtg_userID NOT IN (${commandRequestsString}) AND mtg_user.mtg_userID <> '${callerId}' AND JSON_EXTRACT(mtg_user.mtg_guilds, '$.${Constants.guildPrefix}${guildID}.optedInToServer') > 0 AND mtg_user.mtg_health > 0 GROUP BY mtg_user.mtg_userID, mtg_gamedata.mtg_userID order by rand() LIMIT 30;`;

Does anyone know why this would be returning the same id, but different column data for all rows?

earnest phoenix
#

هذا ايش

rocky hearth
#

should I use mongodb or mongoose?
I had very hard time with mongoose in working with ts

errant flax
#

quick question what are version?
like the numbers? 1.2.3 what does it do/what does it means

small tangle
#

MAJOR 1 = big changes, most likely breaking changes
MINOR 2 = added features
PATCH 3 = bugfixes

#

oh nvm thats german LULW

errant flax
#

i dont understand a singl thing from that pic

#

lul

small tangle
#

wait

#

there we go

#

called semantic versioning btw

errant flax
#

the only thing i dont understand is the minor version

small tangle
#

API-compatible new features

errant flax
#

I'm not using/building an api
(or that's just a reference)

small tangle
#

like you added the feature to search a user by name

errant flax
#

r minor version is like a smol update?

small tangle
#

which doesnt break anything

small tangle
#

and its not only bugfixes

errant flax
#

oh now i understand

errant flax
small tangle
#

would say so yes

errant flax
#

and the last one is just bug fixes bonk

small tangle
#

yes

errant flax
#

noted e_takenotes

#

ty!

small tangle
#

AlpakaSweet youre welcome

rocky hearth
#

can I write embed description as a js code?

#

just like this

console.log("CAN I?")
pale vessel
#

Yes

rocky hearth
#

and for field values?

cinder patio
#

wait what do you mean?

rocky hearth
#

ik, I could make a text for description and field values of an embed as a block text

cinder patio
#

ah

#

yeah you can

rocky hearth
#

what is guildMemberAvailable event. I didnt got the docs
Emitted whenever a member becomes available in a large guild.

errant flax
#

well u just said what it does e_nom

small tangle
#

since in big servers (should be 1000+) offline members arent displayed and when a offline member comes online this event should trigger

limpid herald
near stratus
#

@solemn latch you mind telling this guy to stop

#

he was posting these in #general a while back

solemn latch
near stratus
azure ore
#

I'm having this trouble, any help?

#

sorry guys, wrong screen 1st

near stratus
#

moshi moshi

#

you there ?

azure ore
#

yeah sorry, the problem is the users count

#

it isn't quite correct

near stratus
#

do a loop and get memberCount of all servers

azure ore
#

there is a users cache

#

all the server's users are working, the total one's aren't tho

sudden geyser
#

that does not store all users

sly sierra
#

thats only the cache users

sudden geyser
#

that just stores all cached users

near stratus
sudden geyser
#

You need to add up the total .memberCount of each guild your bot is in (with reduce, for example)

azure ore
#

oh ok, ty guys!

near stratus
#

you really don't need parseInt

sudden geyser
#

You don't need to parse the member count into an integer btw

sly sierra
#

true

near stratus
#

Here fixed it

let totalMembers = 0
client.guilds.cache.forEach(g => totalMembers +=  g.memberCount)
sudden geyser
#

or just

client.guilds.cache.reduce((total, guild) => total + guild.memberCount, 0);
pale vessel
#

Someone had to say it

sudden geyser
#

reduce power 💪

pale vessel
#

😎

cinder patio
#

How about

azure ore
#

that sounds amazing, thanks you all

slender thistle
#

forEach

#

Yeah

cinder patio
#

Nobody cares about that

slender thistle
#

I do

#

As non-JS dev

sudden geyser
#

forEach is nice

[1, 2, 3, 4, 5]
  .map((num) => num * num)
  .forEach((num) => console.log(num));
// vs.
for (const numbers of [1, 2, 3, 4, 5]) {
  console.log(num * num);
}
pale vessel
#

Map 🩴

eternal osprey
#

how do i get the id by pinging a role?

#

was it like @role?

#

\

#

@role

pale vessel
#

Or right click the role on desktop with developer mode on

eternal osprey
#

yeah, but i don't want to ping all those users

#

i am certain that there was like a syntax for it

pale vessel
#

You don't need to

slender wagon
#

i'm doing a genius move, connecting my router to a battery

#

so when no energy

pale vessel
#

You can do \ @ Role but it will still ping

slender wagon
#

still internet

quartz kindle
#

i always did that back in brazil

#

i had an UPS for the modem and router

slender wagon
#

i'll just get a small 9v battery

quartz kindle
#

oh lmao

slender wagon
#

with 500mA

quartz kindle
#

how long will that last?

slender wagon
#

idk i'll have to test

#

just did some research

#

it's about 1 hour

#

so when lights on the battery will charge

#

when off it will spend it's energy

quartz kindle
#

this thing ?

#

hour?

slender wagon
#

yep

quartz kindle
#

x doubt

slender wagon
#

BATTERY ALKALINE 9V LONGLIFE POWER VARTA

#

found this one

#

gotta test it tho

#

i got like a few routers laying around

quartz kindle
#

my ups had dual 12v 1.2ah batteries an hardly lasted 2 hours

slender wagon
#

😂

#

A standard 9V battery has about 400-600 mAh capacity. In the most basic terms, these batteries can supply about 500 milliamps for one hour before being "dead".

#

my router needs 500ma

#

i am unsureeee

quartz kindle
#

xD

slender wagon
#

i think i can do it

#

the max my energy goes off is like 30 - 40 minutes

split hazel
#

just hook up a fucking car battery

#

problem solved you can game for days

slender wagon
split hazel
#

lol

slender wagon
#

the router will go pooof

quartz kindle
#

nah you just need to regulate the voltage

split hazel
#

get a voltage limiter

slender wagon
#

my friend tried a drill battery and ended the routers life within seconds

#

😂

quartz kindle
#

lmao

split hazel
#

good question how long would a car battery last

slender wagon
#

WAITTT

#

i am on development?

split hazel
#

yes

slender wagon
#

BRUHH

quartz kindle
#

yes

slender wagon
#

is this wrong

quartz kindle
#

is it tho? its pretty much development lel

slender wagon
#

yeahh

slender wagon
#

like even if u get a real big one, it can handle a few computers but still will go dead in a few hours

split hazel
#

though how long are usual power outages

#

not longer than a few hours

slender wagon
#

yeah

lethal trout
#
const canvas = require('discord-canvas'),
    welcomeCanvas = new canvas.Welcome(),
    leaveCanvas = new canvas.Goodbye()
const Discord = require('discord.js')
const client = require('../index')

client.on('guildMemberAdd', async member => {
const guildq = client.guilds.cache.member.guild.id

const Schema = require("../models/joinchannel")
 Schema.findOne({ guild: guildq.id }, async (err, data) => {
if (!data) return;
                if(!data.channel) return;
    let image = await welcomeCanvas
        .setUsername(member.user.username)
        .setDiscriminator(member.user.discriminator)
        .setMemberCount(member.guild.memberCount)
        .setGuildName(member.guild.name)
        .setAvatar(member.user.displayAvatarURL({
            format: 'png'
        }))
        .setColor("border", 'BLUE')
        .setColor("username-box", 'RED')
        .setColor("discriminator-box", 'GREEN')
        .setColor("message-box", 'BLACK')
        .setColor("title", 'YELLOW')
        .setColor("avatar", 'PINK')
        .setBackground('https://media.discordapp.net/attachments/847794443180048394/863973336035885056/wallpaper.jpg?width=1178&height=662')
        .toAttachment()


    let attachment = new Discord.MessageAttachment(image.toBuffer(), "welcome-image.png");

guildq.channels.cache.get(data.channel).send(attachment)
 })
})```
TypeError: Cannot read property 'guild' of undefined
quartz kindle
#

no

slender wagon
#

ok no

quartz kindle
#

cache.member is not athing

pale vessel
#

member.guild?

#

But member.guild is a thing

quartz kindle
#

member.guild yes

slender wagon
lethal trout
quartz kindle
#

member.guild

lethal trout
quartz kindle
#

yes

lethal trout
#

ok

#

@quartz kindle

const canvas = require('discord-canvas'),
    welcomeCanvas = new canvas.Welcome(),
    leaveCanvas = new canvas.Goodbye()
const Discord = require('discord.js')
const client = require('../index')

client.on('guildMemberAdd', async member => {
const guildq = member.guild.id

const Schema = require("../models/joinchannel")
 Schema.findOne({ guild: guildq.id }, async (err, data) => {
if (!data) return;
                if(!data.channel) return;
    let image = await welcomeCanvas
        .setUsername(member.user.username)
        .setDiscriminator(member.user.discriminator)
        .setMemberCount(member.guild.memberCount)
        .setGuildName(member.guild.name)
        .setAvatar(member.user.displayAvatarURL({
            format: 'png'
        }))
        .setColor("border", 'BLUE')
        .setColor("username-box", 'RED')
        .setColor("discriminator-box", 'GREEN')
        .setColor("message-box", 'BLACK')
        .setColor("title", 'YELLOW')
        .setColor("avatar", 'PINK')
        .setBackground('https://media.discordapp.net/attachments/847794443180048394/863973336035885056/wallpaper.jpg?width=1178&height=662')
        .toAttachment()


    let attachment = new Discord.MessageAttachment(image.toBuffer(), "welcome-image.png");

guildq.channels.cache.get(data.channel).send(attachment)
 })
})```

it is not sending the attachement when member joins the guild
earnest phoenix
#
def addUpvoteRecord(userid):
  with open("vote.json") as f:
      vote_list = json.load(f)

  if not userid in vote_list:
      vote_list[userid] = []

  with open("vote.json", "w+") as f:
      json.dump(vote_list, f)

@client.event
async def on_message(message) :

    if message.channel.id == 870147153706750022 :
        data = message.content.split(" ")
        user = re.sub("\D", "", data[5])
        addUpvoteRecord(user)
    
    await client.process_commands(message) 

i am getting this error TypeError: list indices must be integers or slices, not str

can anyone help me??

quartz kindle
lethal trout
#

so i need guild id to find guild then i did cache.get(data.channel).send

#

to send it

#

so i am not sure why is it not sending

quartz kindle
#

because guildq is not a guild

#

its a guild ID, aka, a string

summer torrent
#

you are trying to get id of id

#

guildq is already an id. You don't need guildq.id

tulip ledge
#

You know what would be pog

#

A way to sort slashcommands

#

with like categories or something

summer torrent
cinder patio
#

sub-commands exist

lament rock
#

You can only have 5 sub commands?

tulip ledge
#

Why is my github webhook giving me {"message": "Cannot send an empty message", "code": 50006}

lament rock
#

That's an error returned by Discord

tulip ledge
#

How do I fix tho?

lament rock
#

Send content in the message

tulip ledge
#

its a

#

github webhook

lament rock
#

did you add /github to the end of the webhook url

tulip ledge
#

oh ye fuck I forgot to that

lament rock
tulip ledge
#

my bad

lament rock
#

Common mistake. All good

tulip ledge
#

{"_misc": ["Expected \"Content-Type\" header to be one of {'application/json'}."]} thinkLul

lament rock
#

In github, set the send type as json

tulip ledge
#

Alright

#

lets try

#

Alright it worked

eternal osprey
#

Hey! How would i get a random element from this array?

lament rock
#

What language are you using

eternal osprey
#

js

tulip ledge
#

array[Math.floor(Math.random() * array.length)]

eternal osprey
valid frigate
lament rock
#

yes

#

it's just array.length

valid frigate
#

really

tulip ledge
#

no

lament rock
#

no - 1 necessary

tulip ledge
#

Math.random is from 0 - 0.9999999999999999

valid frigate
#

LAL ive been using -1 for years

#

inclusive?

#

oh

#

i legit did not know it was not 0 - 0.99

#

repeating

eternal osprey
lament rock
#

That's the only way how to

restive furnace
lament rock
#

the precision doesn't matter here

#

regardless of the float value, it'll always be in bounds of the Array

tulip ledge
#

Ye

#

Its an "example"

eternal osprey
#

alright, i've made the request and got what i needed using response.body. However, how would i know reach that items array?

#

respose.body.Items?

long crow
#

if you using firefox developer edition, sometime it show how the structure is, very good for making api wrapper kinda stuff

quartz kindle
#

depending on how you made the request, you may need to parse it first

#

because by default you are getting pure text, not an object

twilit hawk
# long crow

if you use libraries like express it can format it when sending a response actually

#

but thats even more neat

quartz kindle
#

you shouldnt send formatted json

#

its a waste of bandwidth

twilit hawk
#

i do for debugging

#

because my prying eyes

quartz kindle
#

i just use a json extension for chrome

twilit hawk
#

but that firefox thing is very interesting

#

i would use an extension but, i already have alot of those

quartz kindle
twilit hawk
#

is it collapsible?

quartz kindle
#

ye

twilit hawk
#

oooh whats it called?

#

i have to try that

quartz kindle
#

there are many of them

#

this one is JSONView

twilit hawk
#

thank you

open flicker
#

I can ask a question about rest api here?

twilit hawk
#

that looks awesome

twilit hawk
open flicker
#

is it worth using OOP for rest api?

quartz kindle
#

you also have right click options

twilit hawk
open flicker
#

okey

twilit hawk
open flicker
#

thanks

twilit hawk
#

but depends if your gonna have like, a big api i suppose

#

something small could be functional programming if you use something like javascript

#

(express)

quartz kindle
#

and a very simple style editor

twilit hawk
#

oh my lord

#

thats nice

#

this is beautiful

twilit hawk
#

thank you

twilit hawk
#

once it gets bigger, may i ask what library you use?

open flicker
#

express

twilit hawk
#

if you use express, routers are awesome

#

ok great

#

using routers and splitting your code base makes a huge difference

long crow
dusk matrix
#

I have a doubt

it's ok if I make my own module to post the information on topgg (servers and shard quantity)

why the ones on npm don't work for me because my bot uses a CLUSTER system that I made

eternal osprey
#

hey! how would i enter array items? I tried response.body.RandL[0].items, but it didn't really work.

#

idk, this reponse confuses me for some reason

quartz kindle
long crow
#

kekw, way better

timber fractal
wary flame
#

What's the error

valid frigate
#

when syncing threads from the thread list sync event, am i required to clear out ALL threads under the parent channel ids or only active threads?

timber fractal
#

@wary flame ^

wary flame
# timber fractal

I wouldn't see an issue either tbh, are you sure it's not vscode bugging out? Does it error when you require the file?

timber fractal
#

i will try

#

yep when i start the bot

#

wait damn i forgot a )

cinder stratus
#

hey anyone knows how do I update a array inside a nested object in mongodb using mongodb official package for nodejs?

timber fractal
#

fixed , batman

#

thx for trying to help

wary flame
#

That is if you are sure response.body is the parsed json response body

timber fractal
#

why isn't message.guild.members.forEach() a function?

wary flame
#

Because message.guild.members is a GuildMemberManager (assuming d.js v13). Did you mean message.guild.members.cache.forEach?

quartz kindle
#

^ applies to djs v12 as well

timber fractal
#

i use V12 but right, that changed there thx

cinder stratus
#

Is there any way I could modify djs caching like I don't want to cache everything like every voice state. Is there any way I could modify that?

timber fractal
wary flame
quartz kindle
cinder stratus
#

sorry replied to wrong message

quartz kindle
#

then you can turn the caches off

cinder stratus
#

but then how will I get voice states data?

long crow
#

There is <client>.sweepMessage() method too

quartz kindle
#
const client = new Discord.Client({
    intents: [ /* your intents here */ ],
    // set to 0 to disable
    makeCache: Discord.Options.cacheWithLimits({
        ApplicationCommandManager: 0,
        BaseGuildEmojiManager: 0,
        ChannelManager: 0,
        GuildBanManager: 0,
        GuildChannelManager: 0,
        GuildInviteManager: 0,
        GuildManager: 0,
        GuildMemberManager: 0,
        GuildStickerManager: 0,
        MessageManager: 0,
        PermissionOverwriteManager: 0,
        PresenceManager: 0,
        ReactionManager: 0,
        ReactionUserManager: 0,
        RoleManager: 0,
        StageInstanceManager: 0,
        ThreadManager: 0,
        ThreadMemberManager: 0,
        UserManager: 0,
        VoiceStateManager: 0
    });
});
#

this is for djs v13

#

all the caches you can disable

cinder stratus
#

oh

#

I see

#

thanks

quartz kindle
#

only some of them if you enable partials

lyric mountain
#

tim tim

quartz kindle
#

but most will not

cinder stratus
lyric mountain
#

big intellij update, they did it again

quartz kindle
#

im woring on discord.js-light for v13 to make them still fire even if disabled

lyric mountain
#

wtf is happening to the gif

cinder stratus
#

I want to do like I don't want voice states of bots, and fetch a voice state when a user uses join command

quartz kindle
#

you cannot fetch voice states

cinder stratus
#

hmm

flat copper
#

Why this error

timber fractal
quartz kindle
quartz kindle
timber fractal
modest maple
#

life

timber fractal
#

haha funny

flat copper
quartz kindle
#

admin doesnt magically fix all permissions

flat copper
#

Oooo

quartz kindle
#

it can still be overriden by channel permissions and by roles higher than your bots role

keen hare
quartz kindle
#

what is the purpose of the update function?

#

i dont see it being used anywhere

lyric mountain
#

it's got so many QoL features

timber fractal
lyric mountain
#

including screenshare during code with me

slender thistle
quartz kindle
#

you dont need both

#

also, you're not passing any arguments to the anon function

timber fractal
#

wait user isnt defined

quartz kindle
#
            ((user,xp) => { // function arguments
              if (!leaderboard[0]) return leaderboard.push([user,xp])
              if (xp >= leaderboard[0][1]) return leaderboard.splice(0,0,[user,xp]);
              if (!leaderboard[1]) return leaderboard.push([user,xp])
              if (xp >= leaderboard[1][1]) return leaderboard.splice(1,0,[user,xp]);
              if (!leaderboard[2]) return leaderboard.push([user,xp])
              if (xp >= leaderboard[2][1]) return leaderboard.splice(2,0,[user,xp]);
            })() // <- missing function parameters
keen hare
slender thistle
#

embed.add_field

#

I'm not sure which language is used in the codeblock

quartz kindle
#

thats markdown

slender thistle
#

Oh those timestamps too

quartz kindle
#
# 07:52 PM
keen hare
#

i even noticed that the time shown there is accurate and is like a real time

#

but tbh i don't know how to do that

slender thistle
keen hare
#

but i mean, those ones doesn't refresh to show actual time

quartz kindle
#

<t:1627567995:R>

keen hare
#

wait, let me share the code i had rn

quartz kindle
#

they refresh if you go to another channel and come back

long crow
#

any idea why that error sometime pop up?

#

I even excluded node_modules

keen hare
#
@bot.command(name = 'time')
async def _time(ctx):
  embed=discord.Embed(title="Timers:", color=0x8fc4ca)
  embed.add_field(name="EU", value=f"<t:{int(time.time()+1*60*60)}:t>\n<t:{int(time.time()+1*60*60)}:R>", inline=False)
  await ctx.send(embed=embed)
  await ctx.message.delete()
#

kinda want a format like the image i provided, but tbh i'm still not that good at discord.py

quartz kindle
#

i dont think you can put that inside code blocks

#

for the blue time, you have to parse the time yourself

#

using pythons own time functions

keen hare
#

oh....

#

is there any example on how to do that?

quartz kindle
#
# <t:1627567995:R>
#

see

keen hare
#

and how should i add that into the code?

quartz kindle
#

the blue color is code blocks with markdown as a language

#

the rule is "blue for lines starting with #"

keen hare
#

yup, but how should i add that code block into the code i provided above?

tulip ledge
#

just

#

liek

#

in text

#

with `

quartz kindle
#

i think py has functions for that, but you can literally type it into the value field

keen hare
#

oh

spare badger
#

Guys what permission does a Discord bot need normally to do the emoji reaction navigation thing?

#

Manage Messages?

keen hare
#

Sooo... should be like this?

embed.add_field(name="EU", value=f"# <t:1627567995:R>", inline=False)
quartz kindle
#

you dont need manage messages

spare badger
quartz kindle
#

reactions and external emojis

tulip ledge
#

you n eed the 3x ` too

keen hare
#

oh i see, let me test

quartz kindle
#

but at this point, nobody uses emoji navigation anymore

#

use button navigation instead

tulip ledge
#

buttons are so much better

keen hare
#

i think i did something wrong

quartz kindle
#

i told you it wouldnt work

tulip ledge
#

you can't have that inside of code blocks

keen hare
#

oh

tulip ledge
#

It's same as doing bold text inside code blocks, doesn't work:

# **BOLD**
keen hare
#

then i'm lost on how to do that... lol

lyric mountain
#

it's bold for me oddly

tulip ledge
#

It's cuz of # I'm pretty sure lol

#

its md

quartz kindle
#

as i said, you have to use python's date time functions to turn your date into the text you want

lyric mountain
#

ah

quartz kindle
#

and then put the text inside the code blocks

keen hare
#

have an example?

quartz kindle
#

i dont use python

#

just google python datetime

keen hare
#

i see i see

eternal osprey
#

Hey i actually tried this out:``const oldStream = oldPresence.activities.find((a) => a.type === "STREAMING");
^

TypeError: Cannot read property 'activities' of undefined``

#

Why is that?

#

is it because people already went live before the bot was in the server?

quartz kindle
#

oldPresence should not be undefined

#

which version of discord.js are you using?

eternal osprey
#

"discord.js": "^12.5.3",

eternal osprey
#

so it couldn't detect their older presences

quartz kindle
#

even so, discord.js creates a blank presence when it doesnt have an old one

eternal osprey
#

strange!

#
client.on("presenceUpdate", (oldPresence, newPresence) => {
  const guild = client.guilds.cache.get("814452880584474664");
  const oldStream = oldPresence.activities.find((a) => a.type === "STREAMING");
  const newStream = newPresence.activities.find((a) => a.type === "STREAMING");
  if (oldStream && !newStream) {
    // user stopped streaming
}
``` this is my code
quartz kindle
#

if you're on node 14+ you can simply add ? to it

#

oldPresence?.activities.find()

eternal osprey
eternal osprey
quartz kindle
#

?. is optional chaining

eternal osprey
#

oldPresence?.activities.find((a) => a.type === "STREAMING"); Basically like this.

quartz kindle
#

yes

#

its a shortcut for oldPresence ? oldPresence.activities.find(...) : undefined

eternal osprey
#

i will try it out and let you know

slender wagon
#

is it a good idea to work on a project for ecommerce with mern

eternal osprey
#

tim you are the best man! It actually worked!

quartz kindle
#

of course it worked, programming is science, not magic xD

pale vessel
eternal osprey
#

hey @quartz kindle how would i update my node on my vps to v14?

quartz kindle
#

i use nvm (node version manager)

eternal osprey
#

sudo apt update && sudo apt install nodejs npm this right??

quartz kindle
#

no, apt updates very slowly

#

it always has old node versions

eternal osprey
#

alrighty, will use nvm then,

#

i gotta rebuild all my scripts that are running on node right?

#

after updating

lofty cedar
#

With socket how could I make that when the server stops it doesn't stop the process but tryes to reconnect every 5 seconds until it reconnect
(python)

valid frigate
#

what is ?? in typescript

eternal osprey
#

how do i only show the logs of 1 directory on my ubuntu vps

#

cuz now it;'s a cluster fuck of pm2 logs

valid frigate
#

but can someone show an example of how its used

timber fractal
#

why does this code try to delete the message twice and send the author a message twice while the censored word is only in censorList.autoModTrigger https://srcb.in/pvYt1ZcS3n edit: added all the code

split hazel
earnest phoenix
lofty cedar
#

With socket how could I make that when the server stops it doesn't stop the process but tryes to reconnect every 5 seconds until it reconnect
(python)

valid frigate
#

ahh

#

is there a name for this operand

split hazel
#

dont even try to remember it

earnest phoenix
#

It has the same left-right operand behavior as || but it checks if the value is either null or undefined

earnest phoenix
#

The name of the ?? operator is the nullish coalescing operator

valid frigate
#

i see

split hazel
#

not gonna remember that anytime soon

valid frigate
#

its in the name

#

thank you kind sir

split hazel
#

is that actually a word

valid frigate
#

voltrex u got a lot smarter while i was gone

#

nice job

split hazel
#

coalescing

valid frigate
long crow
#

"Rate limiting is currently set to 90 requests per minute". For discord bot, is this quite restricting?

split hazel
#

by the way that code is very inefficient

timber fractal
timber fractal
split hazel
#

could you try adding break at the end of each message.author.send and see if it happens again

timber fractal
split hazel
#

the thing is

#

what you're doing right now is iterating over the whole censor list to check

#

if it's large it could get quite slow

timber fractal
#

466 lines

#

with on each line one word

timber fractal
split hazel
#

i'd advise you iterate over the words in the message instead

#

but it shouldn't matter that much with a small bot

timber fractal
#

its a private bot for one server so

split hazel
#

yeah you shouldn't worry about that too much then

timber fractal
#

ok

split hazel
#

especially if you're still learning

quartz kindle
#

is that for the global rate limit?

quartz kindle
#

ah, anilist

#

not discord

long crow
#

for specific IP

latent heron
#

i've rarely used ?? before ngl

crimson vapor
#

?? Is pog

long crow
#
  {
    id: 131518,
    title: {
      userPreferred: 'Dr. STONE 3',
      native: 'Dr.STONE 3',
      english: null
    },
    coverImage: {
      extraLarge: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx131518-GVBd1Eh5gC3p.png',
      large: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx131518-GVBd1Eh5gC3p.png'
    },
    startDate: { year: null, month: null, day: null },
    endDate: { year: null, month: null, day: null },
    bannerImage: null,
    season: null,
    description: 'The third season of <i>Dr. STONE</i>.',
    type: 'ANIME',
    format: 'TV',
    status: 'NOT_YET_RELEASED',
    episodes: null,
    duration: null,
    genres: [ 'Action', 'Adventure', 'Comedy', 'Sci-Fi' ],
    isAdult: false,
    averageScore: null,
    popularity: 26415,
    nextAiringEpisode: null,
    studios: { edges: [] }
  },``` Good for something like this
#

I mean the nullish

split hazel
#

|| = "=="
?? = "==="

woeful pike
#

is that the anilist api

long crow
#

yeah, anilist api

woeful pike
#

make sure you learn how to use it properly cuz top.gg is gonna use the same graphql api Hehe

split hazel
#

that's cringe

pale vessel
#

Tfw you set the description html parameter to false but it still sends html

woeful pike
#

that's not how you spell gamer

split hazel
#

is it just me or do i see graphql hyped everywhere but rarely see any apis actually use it

crimson vapor
#

Idek what graphql is

split hazel
#

apparently it lets you specify what data you want in the request to reduce the unnecessary data sent back from an api

pale vessel
#

And what's ungamer about it

split hazel
#

it lets you build responses in a language called graphql

pale vessel
#

Sounds gamer to me

long crow
#

Firefox dev edition really help me with it

split hazel
#

yeah it sound good but i dont see many apis use it

pale vessel
#

That's very true

#

Out of all APIs I worked with the only one I used that uses GraphQL was AniList

pale vessel
#

It's useful

split hazel
#

same fuck csgo

#

rainbow is where its at

timber fractal
#
message.channel.send(`${message.author}, watch your language.`).setTimeout(() =>{m => m.delete}, 3000);``` why `TypeError: message.channel.send(...).setTimeout is not a function`
split hazel
#

wait cod thats garbage

#

anyways

long crow
split hazel
timber fractal
split hazel
#

they have an example on their docs on how to delete messages based on time

timber fractal
#

is this abt V13?

#

cuz im still on V12

split hazel
#

no v12

timber fractal
#

o

split hazel
#

but you should be using the new things anyways

pale vessel
#

IIRC they're removing the timeout option in v13 and force you to use setTimeout() directly

split hazel
#

actually no they still have it

pale vessel
#

In v13?

split hazel
#

idk

#

yeah just use

#

im on v12 master and i dont have it

#

maybe they added it back

#

i added it back by extending the message structure

timber fractal
#

well lets test this then .then(msg => {setTimeout(() => msg.delete(), 3000)});

split hazel
#

should work

timber fractal
#

works

#

what should be first cache or channels

pale vessel
#

Yes

crimson vapor
#

Huh

pale vessel
#

Aka read docs

timber fractal
#

like msg.guild.cache.channel or msg.guild.channels.cache

pale vessel
#

You tell me

timber fractal
#

ill just try second one

lofty cedar
#

With socket how could I make that when the server stops it doesn't stop the process but tryes to reconnect every 5 seconds until it reconnect
(python)

pale vessel
#

You guessed right

timber fractal
#

i just forgot it for 1 sec

pale vessel
#

But read docs

#

Discord.js has such a wonderful docs

#

It's a shame that some people don't use them

#

You can even download it for offline use

split hazel
#

it's even a pwa lmao

pale vessel
#

Yeas

#

Jshdd

long crow
#

the old doc site is easier to navigate imo, but I get used to new one

pale vessel
#

I don't like the fact that the branch dropdown is hidden under another dropdown

#

Well whatever it's not like I use the lib

#

But I need it to help people

crude stirrup
#

guys help pls

#

why is replit offloading installed packages after inactivity

#

im having to download tons of packages repeatedly

#

pls help

earnest phoenix
split hazel
#

it's a trade off

crude stirrup
#

what should i use then?

split hazel
#

you either pay or use it for free

crude stirrup
#

and im running my bot 24/7

#

i think replit does that using flask or sumn

earnest phoenix
near stratus
earnest phoenix
#

Use a VPS instead

split hazel
crude stirrup
split hazel
#

im on a year free tier credit card

crude stirrup
split hazel
#

yeah big hosting companies wont give you access to their infrastructure without a card

near stratus
split hazel
#

yes

crude stirrup
#

well i cant use my mom's

near stratus
split hazel
#

idk what im waiting for tbh

amber wagon
#

My bot is restarting on its own what could be the reason of it

split hazel
#

i'll give it a try

near stratus
#

Unless you've used up free tier like me

split hazel
#

yeah i did that

crude stirrup
#

i can send code here right?

split hazel
#

but i dont see them on the gh student page

split hazel
crude stirrup
#

from flask import Flask
from threading import Thread
from discord.ext import commands,tasks
from itertools import cycle
from discoIPC import ipc
from discord import Client
from discord.ext import commands
from discord.ext.commands import Bot as BotBase
from discord.ext.commands import Cog
import discord
app = Flask('')


@app.route('/')
def home():
    return "Hello. I am alive!"
    


def run():
    app.run(host='0.0.0.0', port=8080)


def keep_alive():
    t = Thread(target=run)
    t.start()
``` this is for the thing thats keeping it running
crude stirrup
#
token= os.environ.get('Token')
keep_alive()
bot.run
``` this is the last part of my code
#

so can pycharm do these things?

#

like

#

after running im just closing the replit window

#

its keeping the code running but if i close pycharm it will terminate the process

lyric mountain
#

you're running the code on pycharm

crude stirrup
#

no

#

replit

near stratus
#

Caught in 4k

crude stirrup
#

w a t

pale vessel
#

Do you know what a pycharm is

crude stirrup
#

yes

#

i have pycharm and i use it

pale vessel
#

Well I sure don't

crude stirrup
#

im asking for comparison

#

ive run this code on both

#

im asking what will give me a better result

lyric mountain
#

pycharm is an ide, it doesn't affect how good the code will run

crude stirrup
pale vessel
#

And obviously it stops working when you close the ide

crude stirrup
lyric mountain
#

well, obviously

crude stirrup
#

yes

#

i dont want that

lyric mountain
#

then buy a vps

near stratus
crude stirrup
#

its not happening with replit

lyric mountain
#

because replit never closes

#

it keeps the code running on the cloud

crude stirrup
#

but its offloading the packages

#

after inactivity

lyric mountain
#

yes

near stratus
lyric mountain
#

because replit isn't made for long-lasting processes (aka is made for websites)

#

that's why it goes off after inactivity period

crude stirrup
#

then what are the alternatives that doesnt require a credit card

#

ie free

near stratus
#

Isn't replit supposed to be an ide ?

lyric mountain
#

it "is"

lyric mountain
#

you need to keep pinging it to prevent inactivity shutdown

crude stirrup
#

credit card
heroku asks for credit card doesnt it?

lyric mountain
#

like uptime robot

lyric mountain
#

well, it kinda does

crude stirrup
#

oh

crude stirrup
lyric mountain
#

without credit card you won't be able to keep bot online 24/7

crude stirrup
#

i dont have one

lyric mountain
#

like, you'll be able to keep at most 20/7

crude stirrup
#

my mom wont give me hers

lyric mountain
#

which sucks ik

pale vessel
#

Switch between two accounts near the end of the month wesmart

#

Or obviously steal dad's card

near stratus
# crude stirrup ie free

Free tires:

AWS 1 or 2 YEARS
GCP 1 year
Azure 1 year
Heroku Forever
DO a few months
Vultr 10 months

pale vessel
#

Car tires

crude stirrup
#

haha

near stratus
pale vessel
lyric mountain
split hazel
#

gcp has a free tier?

pale vessel
#

Yes

split hazel
#

why am i hearing about this just now

pale vessel
#

Micro F1 or whatever the fuck it's called

sudden geyser
#

unless you're negating the term

near stratus
pale vessel
#

Yeah that one is free forever IIRC

#

Just needs a card

split hazel
#

yeah i used up all my credits by accident so im guessing i have access to the free instances

crude stirrup
#

i can ask my mother

#

but shell prolly say no

near stratus
split hazel
#

my mother would spank me until there is no more skin left if i asked her that

pale vessel
#

IIRC Tim could use it for his bot fine

#

So skull issue

split hazel
#

tim is special everything works for him so he doesnt count

lyric mountain
#

just remember that "free" means either "shitty performance", "heavy limitations" or "gotta rely on life hacks"

split hazel
#

life hack: refresh your uptime page every 5 minutes

lyric mountain
#

what was that old saying? "you don't judge a free horse by its teeth"?

pale vessel
#

A free horse tf

split hazel
#

quirky

pale vessel
#

I'd love to have one

split hazel
#

same

#

even if it has no teeth left

#

i would feed it myself

pale vessel
#

As long as it's free

near stratus
crude stirrup
pale vessel
#

Don't judge a quirky book by its teeth

split hazel
#

that sounds wrong

near stratus
split hazel
#

got a bit deep

crude stirrup
near stratus
pale vessel
#

My condolences

#

One day you'll move out

#

Don't worry

crude stirrup
#

ok that was not cool

near stratus
split hazel
#

to get a good job and move out

#

a dream

brave garnet
#

someone know how to use beta version of d.py ? normal seems broken at me...

split hazel
#

beta means its going to be even more broken

#

whats wrong with it

brave garnet
#

i was trying to use stickers feature from "stable" version but idle thrown TypeError: 'use_external_stickers' is not a valid permission name.

#

•~•

#

(copied right from docs ofc)

split hazel
#

you sure you're completely up to date?

brave garnet
#

i just imported discord

#

and tried to use "stable" instead of "latest"

#

•~•

#

and wat now? im banned on official server BTW

pale vessel
#

Speedy has stopped working

brave garnet
#

means? powered off?

pale vessel
#

Yeah

brave garnet
#

lmfao

pale vessel
#

Gotta wait until it responds back or close and open it again

brave garnet
#

means? how close and open?

pale vessel
#

Get the knife.

brave garnet
#

?

split hazel
#

how do you get banned from their server

brave garnet
#

ping to admin where others were swearing in general

split hazel
#

and i thought discord js admins thought highly of themselves

crude stirrup
#

this is correct right?

brave garnet
#

NOT JS, PYTHON U DUMB

split hazel
#

i know

#

i think you're the dumb

brave garnet
#

:|

crude stirrup
split hazel
brave garnet
split hazel
#

you said you took the code from the documentation? can you show it

brave garnet
#

gimme a moment

split hazel
#

the people in the discord.py server look a bit intimidating i think i'll stick with the js community

brave garnet
#

i know but what if i use pyton?

split hazel
#

i never told you to use anything else

brave garnet
#

ik but smh i cant yet understand js 😂

#

not for my head 😂

#

anyways - i know - they didnt added stickers in both versions - ill rerun and check other perms =p

#

worked

#

sry for msgs

split hazel
#

yeah i thought there was something wrong with your syntax

brave garnet
#

ye XD

#

maybe not syntax but with lib

wheat mesa
#

How much bandwidth would I be using if I were sending videos (of up to 8mb) on my bot fairly frequently? Would I need more than the AWS free tier bandwidth limit (1GB per month out)?

split hazel
#

i mean you can do some math

wheat mesa
#

Yeah I was just wondering if there’s anything weird with it

split hazel
#

figure out your average bandwidth usage per hour or day or whatever

wheat mesa
#

Because 1GB seems like nothing

split hazel
#

actually good point

#

thats a little low

#

you'll probably run out quickly doing that + other things

wheat mesa
#

I read it online, I haven’t looked at the actual AWS limit

split hazel
#

well then you should look at that

#

they could be talking about something else

wheat mesa
#

So I’m not sure if 1GB per month is credible or not

#

Yeah, I’m gonna do that when I have access to my computer later today

split hazel
#

what instance are you running

wheat mesa
#

Navigating on the mobile version of their website is impossible

#

EC2

split hazel
#

one sec i'll try check on the website if i manage to login

#

i dont actually see any bandwidth limit

#

i only see "low to moderate"

wheat mesa
#

Yeah

split hazel
#

in network performance

wheat mesa
#

I guess they’ve changed it then?

#

I read this on a third party site

#

I’m just making sure I don’t get like a billion dollar surprise bill at the end of the month

split hazel
#

on the official website i dont see anything

#
#

i only see gbps not per month

wheat mesa
#

If that’s the case then that’s perfect

split hazel
#

you should ask them though just in case

wheat mesa
#

I’ll monitor the free tier limits carefully as well

split hazel
#

make sure to set spending limits if you havent already

wheat mesa
#

Having a 50 cent bill at the end of the month isn’t gonna be bad, but I just wanna make sure I’m not having like a 20 dollar bill etc

#

Yeah I’ll set those when I get home

#

I swapped to AWS from Heroku because Heroku was shitting itself in performance (to be expected)

#

Plus it was only like 550 dyno hours per month

split hazel
#

yeah can't expect much with their free dynos

#

you're supposed to be hosting websites there anyways

wheat mesa
#

Yeah

split hazel
#

been waiting about 4 months and still counting for them to let me into their github student program

wheat mesa
#

Lol

split hazel
#

had to link a card and all to even apply

wheat mesa
#

Might have to go back to Heroku free tier if this AWS thing turns out to have additional charges I didn’t know about

#

But we’ll see

split hazel
#

they'll most likely refund any charges you weren't aware of either way if the bill is large enough

#

unless they treat free tier users differently

wheat mesa
#

Amazon is a corporate conglomerate worth over a trillion dollars so I highly doubt that they wouldn’t give someone a refund on their first overage

modest maple
#

EC2 follows aws' standard bandwidth pricing model

lyric mountain
#

if you're tranferring over 150TB per month I don't think money's an issue at all

modest maple
#

Sip yeah, if only they started changing at that much usage lol

rocky hearth
#

I want to use json files as a database, for small project.
Which is the best package out there?

modest maple
#

dont

#

problem solved mmLol

#

if you want a small db for a small project use sqlite

#

👌 Glad i awnsered your question

#

your welcome

lyric mountain
#

json is never the answer

#

it's a question and the answer is no

rocky hearth
#

but still, 😢
I'll not use it that much, I promise

lyric mountain
#

if you use it only once it's still too much

rocky hearth
#

0.1% 👍 promise

lyric mountain
#

too much

sinful sonnet
#

have this error (node:10224) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voice' of undefined and this code

crimson vapor
wheat mesa
#

Where did you get that screenshot from? AWS is really really vague on pricing specifics, I assume it's because they want to slam you with a hidden bill at the end of the month

modest maple
#

seems they have really tried to high the bandwidth usage costs now lol

wheat mesa
#

Yeah

#

I literally can't find straightforward information on bandwidth limits on their site. It's like they're trying to hide it (which I don't doubt)

summer torrent
#

finally

wheat mesa
#

All I know is that 1Gb per month seems like absolutely nothing

#

I think I'll just verify a payment method with Heroku to get more free hours per month. They have a 2tb soft bandwidth limit which is a vast amount that I will certainly not run out of.

modest maple
summer torrent
#

they have 9 months 🤷‍♂️

#

@pale vessel 👀

modest maple
summer torrent
#

yes

modest maple
#

any bot that's commands could be on slash commands instead of traditional methods, are gonna be told "use slash commands" i feel

summer torrent
#

you can't access content, attachments, embeds and components btw

modest maple
#

ofc we'll have to wait and see

summer torrent
#

but you can access author etc

modest maple
#

but that's what I think is gonna happen

quartz kindle
#

im gonna have to migrate mine, the only reason i didnt yet is because slash commands are gay

modest maple
#

same

#

just

#

It's gonna suck

#

if you think of some servers having like 50 bots

#

all using slash commands

#

and constantly having to scroll through etc..

summer torrent
#

i love slash commands because it does everthing for you: handling arguments, forcing to use required arguments, showing description of each parameter

quartz kindle
#

wdym without npm

#

you have to install it some way

#

how does it not work?

#

so?

#

the npm website is not the only place where npm can install from

#

npm can install directly from github

summer torrent
#

npm i clashperk/quickchart

amber wagon
#

one of my bot's command is forcing the bot to restart sometimes it worked normally most time it restarts the bot anybody know what could be causing it (was working fine before today)
and command is a leaderboard command which gets data from db and make list

quartz kindle
rigid shadow
quartz kindle
#

what are the last logs before it restarts?

amber wagon
#

no errors jsut restart

#

no changes in logs

summer torrent
#

show code

amber wagon
#

ok

modest maple
#

blobpain Man just realised that all of my time spend working on command aliases is out the window now

amber wagon
#

shall i paste it here or screenshot ?

#

no change in code is made

#

u guys here ?

last tapir
#

what the fuk is this new update

#

i dont understand why they did this

quartz kindle
#

its the fuk

last tapir
#

i dont understand why

quartz kindle
#

the fuk has come to discord

last tapir
#

DUDE THEIR ASSES

quartz kindle
#

are on fire

last tapir
#

are they out of their mind???

#

i legit didnt finish the update

#

9 MONTHS?

#

TF IS 9 MONTHS,

#

i didnt understand what will happen in 9 months

wheat mesa
#

In 9 months it'll require an application for content intents

last tapir
#

i have a normal bot.. legit a moderation bot

#

what am i supposed to do in summary

quartz kindle
#

you apply for the intent once applications open

#

if you are approved, you dont need to do anything

#

if you are denied, you get fucked

rigid shadow
#

I guess moderation bots will be approved, at least some of them

last tapir
#

but what do i do in this 9 months?

rigid shadow
#

I mean moderation without message content is interesting though

rigid shadow
#

and wait for more details

quartz kindle
#

they gave us 9 months to update our bots to slash commands, if they dont have any good reason for reading people messages

#

does your bot need to read peoples messages for some reason other than listening to commands? wait and apply

#

otherwise, start working on moving to slash commands

amber wagon
#

will it count messages like yes and no or only the ones starting from prefix ?

compact jay
#

Idk

quartz kindle
#

they are working on ways to accept followup messages

#

they said slash commands will improve a lot in the next 9 months

feral aspen
#

Wait.. basically I have a moderation bot that does absolutely nothing but listen to commands.. I have to switch to slash commands and apply for that message content thing?

quartz kindle
#

to make more people interested in using them

feral aspen
#

.. and what if I don't?

quartz kindle
#

you have to do one of the two

#

either use slash commands, or apply for the intent

feral aspen
#

OH.

summer torrent
#

they will add something for taking user input

feral aspen
#

.. and if I get denied in the intent.. im fucked.

#

.. and to use slash commands.. do I need the intent?

quartz kindle
#

no

summer torrent
#

no

cinder patio
#

you have almost a full year

#

they're giving you more than enough time

summer torrent
#

-3 months

quartz kindle
#

0.75 years

wintry wing
#

what discord api library do you all think is good for nodejs? (better than discord.js)

summer torrent
#

nothing

quartz kindle
#

most people will say detritus

#

you can also try berry's lib: discord-rose

#

btw what happened to ourcord?

#

xD

cinder patio
#

🗑️

turbid spruce
vivid fulcrum
#

and jeff bezos is an empathetic human who cares for his employees :D

#

two lies and no truth

compact jay
#

Xd

wintry wing
cinder patio
#

you can use the dev version tho

#

also v13 will be released very soon apparently

feral aspen
#

Well..

#

Imma just stay in my current state.

summer torrent
#

npm i discord.js@dev

#

here you go

feral aspen
#

.. I'll eventually rewrite to slash commands soon.. but I'm 70% confident I'll get approved since they approve moderation bots.

#

.. IF IM LUCKY ENOUGH.

#

Meanwhile.. doesn't hurt to create a new application about slash commands to gain knowledge. 🤷‍♂️

sudden geyser
#

First rule: there is no such thing as luck.

feral aspen
#

If I get denied in Fall.. well sh*t is sh*t.. I'm dead. 😂

#

😂 😦

west spoke
thorny flume
#

I'm creating a level system in my bot and I'm trying to put a system in to add roles when a person reaches a certain level, but I don't know how to do it without "ifs" or if I can add "ifs" with base date. Can someone help me ?

quartz kindle
#

what are your current ifs?

thorny flume
fair axle
#

How can I take the specified part of a json? For example I want to splice it 3 to 4.

const list = {
  1: "test",
  2: "test2",
  3: "test3",
  4: "test4",
  5: "test5",
}

Expected Output:

{
  "3": "test3",
  "4": "test4"
}
quartz kindle
quartz kindle
#

so you cant really splice them by index numbers

#

you can convert it to an array of keys or array or values and splice that

#

but once again, order is not guaranteed

thorny flume
quartz kindle
#

then on level up, check if the new level exists in the database

#

if it exists, get its role id and add it

thorny flume
#

ok

crimson vapor
sudden geyser
#

communism didn't spread fast enough

eternal osprey
#

hey, does anyone know how i would get the refresh and access tokens of my twitch client?

#

Their docs just confuse me even more

boreal iron
#

Huh message content will get a privileged intent… wow

crimson vapor
#

completely fair imo

boreal iron
#

Hmm somehow yes and no, sure you actually dunno if a BOT listens or logs any of your messages which is a privacy concern BUT bots need to be invited, can’t join by themselves and they are marked as bot which means server owners are aware of the privacy "issues"

#

It’s just a lot of work to verify all the bots which aren’t transiting to slash commands/interactions but wanna get verified

#

Or to edit/recode the bots

crimson vapor
#

To be fair tho it forces developers to use a standard command system therefore making it easier for users
Bots won’t have access to content if they don’t need it which is a plus
there also aren’t many issues with rewriting a bot or two, or at least the command handler to register them as slash commands

eternal osprey
#

How do I check if a new line is added to a txt file?

#

( its a txt file full with names) from a website

#

And I want to know when a new name is being added basically

quartz kindle
#

download the new one and compare both

boreal iron
#

But regarding privacy concerns I wanna say I’m more concerned about discord than their bots, but that’s my opinion of course

#

Doesn’t mean it’s a bad step overall

split hazel
#

some people have like 200 commands all in a single index file

#

(i did that with my first ever bot)

#

that may be quite difficult to rewrite

#

meh actually now that i think about it you can replace a few variables and do a couple regex searches

long crow
#

My / still working it seem even without the GUILD_MESSAGE was scared it will affect some of my command

grim sundial
#

your / ?