#development

1 messages · Page 1689 of 1

earnest phoenix
#

I hope to see you again

drifting wedge
#

feel free to ping me

#

or dm me

earnest phoenix
#
from discord.ext import commands, tasks

import dbl

import os

from setuptools import find_packages, setup



class TopGG(commands.Cog):
    """
    This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
    """

    def __init__(self, bot):
        self.bot = bot
        self.token = os.environ.get("dbl_token")  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)
        self.update_stats.start()

    def cog_unload(self):
        self.update_stats.cancel()

    @tasks.loop(minutes=30)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count."""
        await self.bot.wait_until_ready()
        try:
            server_count = len(self.bot.guilds)
            await self.dblpy.post_guild_count(server_count)
            print('Posted server count ({})'.format(server_count))
        except Exception as e:
            print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))


def setup(bot):
    bot.add_cog(TopGG(bot))
drifting wedge
#

youre welcome to friend be but like theyres a 99% chance ill decline it

#

so i dont recommend that

earnest phoenix
#

Lol

thick nexus
#

uh

earnest phoenix
#

Well I got 1% of destiny on my side

quartz kindle
#

"i hope to see you again" doesnt exist in programming and tech support. what you want is "i hope i never see you again", because it means it worked

earnest phoenix
#

I'll take my chances

quartz kindle
#

if you have to see the person again it means something went wrong

#

xD

drifting wedge
#

not really

#

bc i see tim all the time

earnest phoenix
#

so

#

Lol

#

someone fix my code>

drifting wedge
#

when hes helping nerds

unreal estuary
earnest phoenix
#

I'm sure I'll have some error

drifting wedge
#

and im making fun of them

earnest phoenix
#

Thank you again

drifting wedge
#

np

earnest phoenix
#

nothign happens

#

You are all so awesome

#

and no errors are raised

drifting wedge
#

dm me if u need anything

#

dm me if u get it working too kek

earnest phoenix
#

I am not.worthy of your presence

drifting wedge
#

i want updates!

earnest phoenix
#

I will

#

I'm sad i gotta trash what I made tho

#

But alas...thus is life

#

The wheel turns

drifting wedge
#

this lie button seems cool

earnest phoenix
drifting wedge
#

i wonder if it pretends i friended them

#

ok bye

#

go watch the video

earnest phoenix
#

Ok I had to stop and come back for a sec

#

Ty again

earnest phoenix
#

Hello I'm back

#

Os.chdir(mybot)

#

Where do I find the right words to replace mybot

drifting wedge
#

how do i use @tasks.loop?

#

got it

slim stag
#

btw who gone check the test bot

old cliff
#

ok wtf

#

wtf php

#

how does 4096 exceed 268343.....

misty sigil
#

php™️

drifting wedge
#

i have a txt file, with a bunch of words, each one in a line, how can i check if a string has any of those words?

#

py

placid meadow
#

where does this happen ?

old cliff
#

Found a fix.... on 256mb ram allocation it showed the incorrect bytes used.... fixed the code

placid meadow
#

i think i start to understand ya

#

is it reserving within a frame

earnest phoenix
placid meadow
#

@drifting wedge u could use regex

drifting wedge
#

i should be good

#

but i need regex for a link thingy

dusky sundial
#

You could probably do the check in one line using any()

drifting wedge
#

basically i need to check if a string is a url/website

placid meadow
#

oh i can hook ya up with that exe

#

i have one in my bot that is almost perfect

drifting wedge
#

pls do shiv isnt here and i dont feel like coding

#

so pls do it for me

#

jkjk

#

but if you do have something

#

id love to use it

#

but explain how it works lol

placid meadow
#

((http|ftp|wss|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)

drifting wedge
#

explain pls

placid meadow
#

thats the pattern

drifting wedge
#

ive NEVER done regex

placid meadow
#

oh ok

drifting wedge
#

so idk ANYTHING

placid meadow
#

calm down

#

lol

drifting wedge
#

im not not claim

#

calm

#

i am calm boi

placid meadow
#

use that knowledge and use the pattern i gave ya

earnest phoenix
drifting wedge
#

ty

#

ill watch a yt explanation on regex

#

first

snow urchin
#

https://i.callumdev.pw/sjfrz.png
since I prevent the default action on the submit form (to stop the redirect and use a custom post request)
how can I still make sure it checks that all required fields have an input?

earnest phoenix
#

If you're sure the url will only be in the beginning, use re.match, otherwise use re.search

drifting wedge
#

k cool

#

ty

#

re.search("((http|ftp|wss|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)", content): so like this?

earnest phoenix
#

try that, but I think you should use raw string

drifting wedge
#

wdym?

#

content is just the raw string but all lowercase

#

shouldnt affect anything

earnest phoenix
#

No, I mean the pattern, since you don't wanna escape the backslash, but idk try it

drifting wedge
#

OHHHH

#

elif re.search("""((http|ftp|wss|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)""", content):

#

should this work?

placid meadow
#

yeah sorry, this pattern comes from dotnet regex

#

i dont know for sure it js takes it like that

earnest phoenix
#

that's just multiline strings, not a raw string

drifting wedge
#

(im doing py)

placid meadow
#

double quote ?

sudden geyser
#

Why are you trying to write your own URL validator anyway

drifting wedge
#

how do i do a raw string?

earnest phoenix
#

I just tried it using general string, it works dw

placid meadow
#

'

earnest phoenix
#

r""

drifting wedge
#

i mean its giving me 15 errors lmfao

#

r"" works fine tho

earnest phoenix
#

what error?

drifting wedge
#

not errors

#

alerts

#

can be ignored

#

it was bc of escape \

#

what string types are there?

#

f and r?

earnest phoenix
#

there are binary literals and unicode literals as well

#

b"" and u"", you can combine those ig

drifting wedge
#

doesnt appear to work

#

only with actual https://

#

if its only for https links i can just use if https:// or http://

earnest phoenix
#

What are the inputs?

drifting wedge
#

what i put?

#

i tried

#
earnest phoenix
#

ah, the scheme is required, you can make it optional

#

but that might lead to false-positive ig not sure

drifting wedge
#

i dont know that much advanced shit lol

#

what is a scheme?

#

also whats a kwarg lol

earnest phoenix
#

scheme is like ftp, http, wss

drifting wedge
#

wss?

earnest phoenix
earnest phoenix
drifting wedge
#

oh

earnest phoenix
#

these are schemes

drifting wedge
#

i know whats a kwarg

#

just not by the name

earnest phoenix
drifting wedge
#

im making a anti link thingy

#

should i block https / http or just ANY url?

earnest phoenix
#

But the clickable ones are the ones with the scheme, aren't they?

drifting wedge
#

i mean the question isnt neccessarily about if i should use regex

#

but how i should deal with links

#

like should i block the clickable links

#

or just ALL links

#

wss://google.com

#

thats not clickable?

earnest phoenix
#

Seems only https? clickable, not sure

drifting wedge
#

and http

#

so ill just block those

#

ez

earnest phoenix
#

that's why I put a question mark, the s is optional

drifting wedge
#

OOHH

#

thats a tihng

#

lol i havent looked into advanced stuff yet lol

#

how would that work?

#

https? in message.content?

#

in a string?

earnest phoenix
#

it's a regex pattern

drifting wedge
#

oh

#

ill just do "https://" or "http://"

#

easier

lyric mountain
#

? means "match 0 or 1 of the preceding token"

#

regex is not hard at all

#

you just need to understand what each thing is

drifting wedge
#

says the person who knows regex

earnest phoenix
#

Just need some time and effort lol

lyric mountain
#

and most importantly, don't try to read other people's regex

#

it's impossible

earnest phoenix
#

yeah that site is cool, it breaks down the pattern for ya

drifting wedge
#

ok

#

ALSO unrelated to regex

lyric mountain
#

I'd say regex is easier than programming

drifting wedge
#
        self.antispam.append(message.author.id)
        counter = 0
        for i in self.antispam:
            if (i == message.author.id):
                counter += 1
                await sleep(5)
                self.antispam.remove(message.author.id)

        if counter >= 4:
            await message.delete()
            await message.channel.send(f"Hey {message.author.mention}! Please don't spam!", delete_after=10)``` any ideas to make this work better / any ideas to fix it?
lyric mountain
#

is that supposed to be ran on each message?

drifting wedge
#

yes

#

content is the message content but lowercase btw

#

not useful here

#

but its just easier

lyric mountain
#

await in events is kinda bad

drifting wedge
#

how so?

lyric mountain
#

"busy waiting"

#

you could use a self-expiring collection

drifting wedge
#

wait wot

lyric mountain
#

then check if the id is in that collection

#

if it is, user is ratelimited

#

else it's not

drifting wedge
#

wait explain in dumb wordsd

earnest phoenix
#

Someone spams, sleeps for 5 seconds to delete the id of them, same guy just spams 4 seconds after, the id is removed a second after, the remove line raised ValueError 4 seconds after lol

lyric mountain
#

it doubles as a handy cache

drifting wedge
#

wait wdym?

lyric mountain
#

basically entries expire after a set amount of time

#

imagine a market

drifting wedge
#

k

lyric mountain
#

each time someone enters the building, you put a cucumber in the stand

#

all cucumbers will expire after 5 seconds from being put in the stand

earnest phoenix
#

is redis overkill for this? lol

drifting wedge
#

expire as in go away

#

like fall over

lyric mountain
#

if the person re-enters the building while its cucumber hasn't expired, you kick the person out of the place

drifting wedge
#

ok

#

well that makes it easy

drifting wedge
#

but the person can have 4 cucumbers

#

at the same time

lyric mountain
#

then store a relation of id-count

#

like ```json
{
"id": "123456789",
"count": 1
}

drifting wedge
#

so store a list of dicts

lyric mountain
#

then check if the user is in the cache, if it exists, check the count

drifting wedge
#

uhh

lyric mountain
#

if the count is below 5, increase and save

drifting wedge
#

ur way is overly complicated

#

i think

lyric mountain
#

I'm bad at putting it in words

drifting wedge
#

i could store each user as a dcict

#

dict

#

in the list

#

on message

#

the dict counter goes up

#

but i need to after 5 seconds make the dict counter go down 1

#

which is the await

lyric mountain
#

work with 0

drifting wedge
#

?

lyric mountain
#

if the user isn't in the cache, then consider it to be 0

#

(or 1 if you REALLY want to use 1)

#

basically:

drifting wedge
#

why cant i just use sleep blob_cry

#

so complicated 😦

lyric mountain
#

busy waiting

drifting wedge
#

i mean i can just make it wait last?

earnest phoenix
#

If that's a separate listener, does it really matter?

drifting wedge
#

so it wouldnt be "busy"?

#

and yeah it would be separate

lyric mountain
#

try using the wait method, if you face issues try using the self-expiring dict

drifting wedge
#

ok thank

#

tysm @lyric mountain and @earnest phoenix

earnest phoenix
#

np

#

you know, you could've used collections.Counter

#

instead of a list

drifting wedge
#

ty tho

sly grotto
#

where do you all host your discord bots ?

shut drum
#

i host mine on an old laptop that i always keep on

#

but you can use heroku since its free and easy

sick blaze
#

Uptime Monitor,Heroku Etc.

ruby flame
#
Task was destroyed but it is pending!
task: <ClientEventTask state=pending event=on_message coro=<bound method BotBase.on_message of <discord.ext.commands.bot.Bot object at 0x7fe16116d850>>>

Anyone?

earnest phoenix
#

the heck is this

mighty ember
#

how do i run a C++ file in VS code?

dusky sundial
#

You need a C++ compiler installed, and the code runner extension

sand seal
#

Hi, pls tell me the command which sends dm to voter after voting the bot.

opal plank
#

you need a webhook first

snow urchin
#

tried with "body" and "data"

#

nvm brruuuh ofc contentType was needed

copper cradle
#

Hi Nederlands, I'm zsnails

#

good for you

stuck pike
#

what event is used to check if a attachment was sent?

copper cradle
#

the message event

stuck pike
#

wait what

copper cradle
#

check if the message contains an attachment

stuck pike
#

oki got it

spare robin
#

hello i just wanna know about the error of api of my bot can i know why discord is banning my applications api

earnest phoenix
#

Hello. I don't know if You can help with this, but I'm trying to create a simple bot for one server, and idk how to.

cinder patio
#

Do you know how bots are made?

earnest phoenix
#

Not very

cinder patio
#

You should start with that then, and then decide if you're willing to learn

earnest phoenix
#

You mean watch YouTube videos?

cinder patio
#

Not only watching youtube videos

dusky sundial
earnest phoenix
#

What is other way to learn?😁

cinder patio
#

Reading

azure walrus
earnest phoenix
#

Like - Moderation, leveling and some custom commands.

misty egret
#

i want to learn something

azure walrus
azure walrus
earnest phoenix
#

Okay

#

Ty

#

how to solve this

copper cradle
#

solve what

earnest phoenix
#

log spam

#

1 vote = 10 msg

cold sun
copper cradle
#

We're not magical creatures, ya know

sacred juniper
#

How can i dlete it

#

I can see it only on mobile

#

Since 1 day

earnest phoenix
#
    let auth = req.headers['authorization'];
    if(!auth) return res.json({status: "Failed", message: `You didn't provide a 'Authorization' header!`});
    if(auth !== process.env.Auth) return res.json({status: "Failed", message: `You didn't provide the correct authorization key!`});
    if(!req.body) return res.json({status: "Failed", message: `You didn't provide any data!`});
    if(!process.env.dbl) {
      console.log(`You didn't add your dbl api key in the .env file.. smh`)
      return res.status(401).json({status: false, message: `Unauthorized`})
    }
    let bot = req.body.bot;
      let {body: user} = await get(`https://top.gg/api/users/${req.body.user}`).set("Authorization", process.env.dbl);
     post(process.env.Webhook)
      .send({embeds: [{
        title: `Vote Here`,
            color: 0xbc00ff,
            url: `https://top.gg/bot/${bot}/vote`,
        timestamp: new Date(),
            author: {
                name: `New Vote by: ${user.username}#${user.discriminator}`,
          icon_url: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}${user.avatar.toString().startsWith("a_") ? ".gif" : ".png"}`
            },
            footer: {
                text: `Discord Bot List`, 
                icon_url: `https://i.imgur.com/78Hl85r.gif`
            }
      }]}).catch(console.error)
});
app.listen(4000, () => console.log(`Website is up and running`));```
dusky sundial
#

up to 10 times

burnt quarry
#

@dusky sundial bro how much time will it take for verify

dusky sundial
#

about a week

burnt quarry
dusky sundial
#

You added your bot 2 days ago, so that's not true

frigid mountain
cinder patio
#

You don't close the string literal

#

your editor should be able to catch that

rose warren
#

.setAuthor(`${user.user.username}`, avatar)

earnest phoenix
#

Does anyone know a npm package which plays audio files

#

mp3/m4a

old cliff
#

plays audio for what?

earnest phoenix
#

In discord vcs

rose warren
old cliff
#

@frigid mountain u forgot closing the string

#

first line

frigid mountain
#

Oh

old cliff
#

of image

frigid mountain
#

Thx

old cliff
#

just give path to File or

earnest phoenix
old cliff
#

use ytdl or stuff

#

or a voice stream or buffer

rose warren
lunar patio
#
       setTimeout(function(){ 
    //Code
 }, 5000); //time in milliseconds
 message.channel.send('') 
    }```
rose warren
opal plank
#

you cant send empty messages

#

send('') will error

lunar patio
#

help me ):

opal plank
#

you havent asked what you need help with

rose warren
opal plank
#

you just threw code here

lunar patio
frigid mountain
rose warren
opal plank
#

check that

lunar patio
#
        message.channel.send('setTimeout(function(){ 
            //Code
         }, 5000); //time in milliseconds') 
    }```
#

like this?

rose warren
#

No

#

Read the docs erwin sent

lunar patio
#

ok

frigid mountain
# rose warren My bad. I edited! 14 is good

So like these

const Discord = require('discord.js')

module.exports = {
    name: 'mute'
    run: async (message, args)  => { 
if (!message.member.permissions.has("MANAGE_ROLES")) return message.reply("You don't have enough perms")
   const user = message.mentions.members.first()
   const sayMessage = args.join(" ")
   const say = `${sayMessage}`
   const avatar = `${user.user.displayAvatarURL({dynamic: true})}`
   const embed = new Discord.MessageEmbed()
   
    .setAuthor(`${user.user.username}`, avatar)
    .setDescription(`${user.user.username} You were muted because your actions inside ${message.guild.name} server`)
    .setColor("F73272")
    .addField("\u200b", "\u200b")
    .addField("**Moderator**", `${message.author.username}`, true)
    .addField("**Reason**", say, true)
    .setTimestamp()
    .setFooter("Mute Case#0356")
    
       user.send(embed)
       
  const embed2 = new Discord.MessageEmbed()
  
   .setAuthor(`${user.user.username}`, 'Mute case#0356')
   .setDescription(`${user.user.username} has been muted by ${message.author.username}`)
   .addField("\u200b", "\u200b")
   .addField("Reason", say, true)
   .setTimestamp()
   .setFooter("🌴Justice has been served", avatar)  
   
      message.reply(embed2) 
    }
}
rose warren
#

Looks better but I'm on my phone

#

Try it and see

#

Check your logs. It'll tell you where the errors are if there are any.

frigid mountain
#

IconURL

rose warren
#

There's your answer in the logs

lunar patio
#
const Discord = require('discord.js');
const { prefix, token } = require('./config.json');

const client = new Discord.Client();

client.once('ready', () => {
    console.log('Ready!');
});


client.on('message', message => {
    if (!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).trim().split(/ +/);
    const command = args.shift().toLowerCase();

    if (command === 'cd') {
        message.channel.send('') 
    }
    // other commands...

});

client.login(token);```
rose warren
#

Replace mute case#0356 with avatar

lunar patio
#

tell me now

opal plank
#

we arent going to spoonfeed you

#

its the 5th time you post this without listening to our answers

lunar patio
#

ya ik you dont spoonfeed

#

):

rose warren
# lunar patio tell me now

You literally just copied another piece of code you found online and now you want us to write your command for you.

silver lintel
#

so im using mongodb, and i have this code

let res = await Guilds.findOneAndUpdate({ id: "test" }, { $set: { hmm: "dgisdfjdsf" } }, { returnNewDocument: true });
``` but res.value is showing the old version of the doc even tho i have `{ returnNewDocument: true}`, ive tried `{ new: true }` but that doesnt work either
opal plank
#

@lunar patio Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

frigid mountain
#

@rose warren Thank you so much I fixed it now it works

rose warren
#

👍

rose warren
frigid mountain
rose warren
#

That's the fun part

frigid mountain
#

I'll tell you when I'm done♡

rose warren
#

Use the docs they'll be helpful when finding out how to give a member a role

frigid mountain
#

K

frigid mountain
lusty quest
woeful pike
#

why even bother writing code if you're going to treat it like a homework assignment to get an A on

rose warren
#

Lol his bot literally requires all the perms + admin

crystal wigeon
#

hi umm

#

anyone knows form data?

#
  fd.append("name", files[i])
}```
This only appends 3 items into the "name" array for some reason when i have 5 items. (ignore the syntax, just an example)
cinder patio
#

Form data is basically query params

#

?param=value&param1=value1

crystal wigeon
#

yeah, but i should be able to append as many

#

as i want

cinder patio
#

that's not how a for loop works

crystal wigeon
#

i know...

#

that was just for faster reference for what im doing

#

anyway. on the server side i receive only 3

#

name: [ 'yuno gasai', 'amano yukiteru', 'akise aru' ],

#

but i have 5 and when i check fd.entries()

#

it shows me all 5

quartz kindle
#

there is no official standard for arrays in query params

#

better code it yourself

cinder patio
#

Or don't use query params, send the array as the body of the request

eternal osprey
#

hey

#

so i have made a bot that actually triggers on certain words being used

#

it works for the description

#

but not for the title of the embed.

#

The trigger word had to be Donate.

#

but it didn't trigger.

#
 const fake = message.content || message.embeds[0].description || message.embeds[0].footer || message.embeds[0].title
    let m = final.filter(a => fake.includes(a))
    let z = final.some(a => fake.includes(a))```
slender thistle
#

Technically you'd need to check for the word in all of those instead of relying on absence of others

eternal osprey
#

nvm i found out that || can only hold 2 options

#

now i've made a fucking necklace of ||.

#

my bad.

earnest phoenix
#

this line deleted all my channels somehow

#

its not even in a loop

#

oof

#

good its a test server ey

#

lol

#

what command

cinder patio
#

The description of one of the commands is either too long or too short

#

it's in the error message

copper sage
#

Is it recommended to use guild based Slash commands instead of global Slash commands? Not Just for Testing...

sacred juniper
#

Can i use PYTHON for discord bots

vivid fulcrum
#

sure

#

there's a few python libraries

pale vessel
#

you don't need permission to create them, you just need the applications.commands scope to be able to use them

crimson vapor
#

cringe tbh

drifting wedge
near stratus
#

I don't think so
Get an option to get the text after

earnest phoenix
#

@drifting wedge atom dark+

#

Or just atom dark

earnest phoenix
#

In ts typedef how do you specify an array with a length from 1 - N

cinder patio
#

you can't, typescript doesn't keep track of array length. You could use a tuple though

unreal estuary
#

can someone help me

earnest phoenix
#

im doing this:

unreal estuary
#

url = "https://discord.com/api/v8/applications/ID/commands"

json = {
    "name": "ping",
    "description": "pong",
    "options": []
}


headers = {
    "Authorization": "Bot TOKEN"
}


r = requests.post(url, headers=headers, json=json)
#

why is this not working?

earnest phoenix
#

interface h { hh: number[length from 1 to 25] }

#

(cant use line breaks because im using discord in the browser on mobile)

earnest phoenix
unreal estuary
#

i obviously chanegd it lmao

#

i didnt actually put ID

cinder patio
earnest phoenix
#

but that would mean i cant do an array with length smaller than that

cinder patio
#

yeah

#

well

unreal estuary
cinder patio
#

[number, number, number|undefined]

earnest phoenix
#

W H A T

cinder patio
#

but you have to use undefined

#

yea why bother type that

unreal estuary
#

anyone know why its not working?

cinder patio
#

Actually

#

[number, number, number?]

#

this works

unreal estuary
earnest phoenix
#

why is your options array empty

#

you could just leave it out

#

and also have you authorized your app to your server with applications.commands scope

unreal estuary
#

i dont think so

#

w8

earnest phoenix
#

you never know that might be the problem ¯_(ツ)_/¯

unreal estuary
#

ill check

#

ty

#

doing it

#

ughhhhhh

waxen bough
#

guys can I ask do you guys have an insight on when we can have the discord.js full support for discord slash commands?

pale vessel
#

as soon as possible

waxen bough
#

i hope so

vivid fulcrum
waxen bough
#

is there people who proposed different versions about this too?

vivid fulcrum
#

that is the only pr open

#

regarding interactions

earnest phoenix
#

hello

#

how to find the the ids of the emojis /

#

?

meager dome
placid meadow
#

sup ppls

earnest phoenix
#

\🍰

near stratus
earnest phoenix
#

\🍰

#

🍰

vivid fulcrum
#

normal emojis that are in the client are unicode emojis and they don't have an id

earnest phoenix
#

see

near stratus
meager dome
#

yeah

earnest phoenix
#

ohh okay

meager dome
#

\🍆

near stratus
#

it doesn't have id use unicode

earnest phoenix
#

𓀂

earnest phoenix
#

🔴 🟠 🟡 🟢 🔵 🟣 ⚫️ ⚪️ 🟤

#

Poggers

waxen bough
pale vessel
#

node.ts

waxen bough
#

because I found a javascript library for emojis

waxen bough
#

hold on...

#

it does have declarations

npm install -S emoji-js
npm install -D @types/emoji-js
earnest phoenix
#

What this does?

pale vessel
#

what

earnest phoenix
#

Boys should not use girl animes \😳

cinder patio
#

how do you know they're boys

earnest phoenix
#

Ik

cinder patio
#

and also what's wrong with that

waxen bough
waxen bough
earnest phoenix
#

maby it's your mom's face?

#

\😂

waxen bough
pale vessel
earnest phoenix
#

Noice

#

@pale vessel @waxen bough u bOtH aRe AnImE lOvErS

#

@cinder patio u too lol

waxen bough
#

...

crimson vapor
#

huh

cinder patio
#

I'm a dog

earnest phoenix
#

See how I'll put a anime pfp

#

:)

#

Noice

pale vessel
#

...ok?

earnest phoenix
#

Not ok

#

I'll kick the anime out

pale vessel
#

look, we don't really care

earnest phoenix
#

Noice

#

Bye

waxen bough
#

i was just trying to help someone and the next thing i know ...this

crimson vapor
rustic nova
earnest phoenix
#

𓀂

pale vessel
#

yes and they don't even know what ddlc is smfh

earnest phoenix
rustic nova
#

@earnest phoenix can you stop being a nuisance in development if you both don't want to help and/or need help, thanks

earnest phoenix
#

Oh sorry I thought I'm in chats Such A Great Dumb That's What Everyone calls me

#

great dumb...

feral aspen
#

Hi

#
await message.channel.clone()
earnest phoenix
#

it means ?

lusty quest
#

did you store data, like Guild IDs for Per Guild configs

feral aspen
#

Adding an option in the clone() method which is the reason makes the bot not allowing anything to run meaning not allowing the channel to be nuked. (Not raiding) Making a nuke command, not used incorrectly, no hurt pls

feral aspen
earnest phoenix
#

no

feral aspen
#

Say that you don't store any user data.

#

Since 100 characters is the minimum limit

#

You can write I believe that my answer to the following question is no as I don't store any user or server data from users or servers.

river panther
river panther
#

xD

earnest phoenix
#

ty all

river panther
#

exdi

earnest phoenix
#

Lel

river panther
#

i read that

feral aspen
#

😉

feral aspen
#

😂

stuck crag
#

lol

river panther
#

what do i help with?

dire gull
#

Hi

waxen bough
#

question, how do you guys store data for your bot? do you guys use database or just save them in json file?

river panther
#

idk, i never made the nuke command

umbral zealot
stuck crag
#

um why json is bad?

earnest phoenix
feral aspen
earnest phoenix
feral aspen
#

😂

umbral zealot
feral aspen
umbral zealot
earnest phoenix
#

what can i do now ;-;

waxen bough
earnest phoenix
#

i need help

#

my meme command isnt working

umbral zealot
#

they're super easy

earnest phoenix
#

can someone explain why

waxen bough
#

are they available in npm?

umbral zealot
#

yes, all 3 of them are.

umbral zealot
earnest phoenix
#

@river panther pls help again

stuck crag
#

oki but is there a way i can use mongodb in my 32bit pc? (i cant install their applications :v)

river panther
#

umm, fill it with since the reply to the previous question was no henceforth i would like to say no to this too, which means i am not using any user data

umbral zealot
earnest phoenix
umbral zealot
umbral zealot
stuck crag
#

hmm ok

earnest phoenix
umbral zealot
earnest phoenix
#

at FOR WHAT PROCESS

river panther
umbral zealot
#

Also you didn't actually answer my question

earnest phoenix
#

ok

umbral zealot
#

What is the error yo'ure getting?

earnest phoenix
umbral zealot
#

Do you not have a console output

#

you know the terminal

#

where you start your bot

earnest phoenix
#

second 1

#

I use glitch

#

so

#

FOR HOW LONG DO YOU STORE IT?

umbral zealot
#

First, glitch actually has a terminal

earnest phoenix
#

I know

umbral zealot
#

ok so go look at it

#

geeze

earnest phoenix
#

alright

#

@umbral zealot pls tell FOR HOW LONG DO YOU STORE IT?

#

this one

river panther
umbral zealot
#

That's... pretty simple english man

pale vessel
#

yo'ure
do'nt
mmLol

earnest phoenix
#

WHAT IS THE PROCESS FOR USERS TO REQUEST DELETION OF THEIR DATA?

umbral zealot
#

Are you really expecting us to know the answers to these very simple questions? You're the dev, if you don't actually know whether you store data, that's bad.

earnest phoenix
#

im at the terminal

river panther
#

no u

pale vessel
#

DM, emails, however you do it?

earnest phoenix
#

what next

umbral zealot
earnest phoenix
#

LMAO

umbral zealot
earnest phoenix
#

nothing

umbral zealot
#

run your command again

earnest phoenix
#

command still isnt working

#

@umbral zealot

umbral zealot
#

yeah I know it's not working we didnt fix it

waxen bough
#

I assume it's not bad if your gonna use json files for long term data storage.

vivid fulcrum
#

debug it

umbral zealot
#

I want to know if anything actually see anything in the console log when you run it

#

like, basic debugging

waxen bough
waxen bough
umbral zealot
#

IF you're not actively changing or modifying the file during runtime, yes json is fine

#

But then that's not a database those are just config files or backup files.

waxen bough
#

i want to use database that doesn't need remote server. because apparently a lot do

earnest phoenix
umbral zealot
#

Hey remember earlier I suggested 3 different databases you could use

waxen bough
#

ohh

#

yes

placid meadow
#

sup hind 😉

sterile lantern
umbral zealot
sterile lantern
#

if you are, do not use file-based DBs

#

they corrupt very easily

#

and loose data all the time

placid meadow
#

noever happend to me tho samm

sterile lantern
earnest phoenix
placid meadow
#

no i use a serializer from google

#

protobuffer

sterile lantern
#

thats fine

placid meadow
#

i see

umbral zealot
earnest phoenix
#

let me refresh it

umbral zealot
#

oh that's right you're on glitch MarioFP

#

fucking glitch, man. such a bait & switch

earnest phoenix
#

refreshed it

crimson vapor
#

I don't really understand the use of glitch for discord bots

umbral zealot
#

Because it used to be the one good free option

#

before repl.it got known for "replacing" them

crimson vapor
#

oh

umbral zealot
#

I literally had a guide on AIG where I posted how to use it because heroku was shit and too hard for people and repl.it was a bit of an unknown at that time

earnest phoenix
#

still isnt working

umbral zealot
#

now that guide says "don't use this it's not good for hosting"

#

but people just don't want to listen

pale vessel
#

Heroku is super easy and fast though

umbral zealot
#

It really isn't as easy as any other service.

pale vessel
#

If you don't know how to use git

umbral zealot
#

Also Heroku's now even more locked down and useless than glitch from what I understand?

pale vessel
#

Nope, you can install ffmpeg, Puppeteer, ImageMagick, anything

#

Used it for my bot

umbral zealot
#

Might just be people that didn't have a CC or know how to use workerfile or whatever

earnest phoenix
#

@umbral zealot yeah it aint working

#

after refreshing

umbral zealot
#

add more console logs

#

add more debugging

#

figure it out

latent heron
#

i think the thing about hosting bots on heroku is a little stretched imo

crimson vapor
#

or install vsc and use the debug features

latent heron
#

there's nothing preventing you from doing it, it's just discouraged on

#

if you have a bot that's minimal on processing or memory usage, then go for it, but a bot that's intensive and requires things like constant database changes, massive-scale API calls, and etc. is probably not a good idea to host on heroku at all

waxen bough
umbral zealot
#

Ok well hold up

#

why is sync a problem? That's usually a benefit

#

also the path is optional in every enmap feature 😛

pale vessel
#

looks like a mongodb clone

waxen bough
umbral zealot
#

it doesn't because it's pretty much instantaneous, it's the fastest database interaction you can find

umbral zealot
#

better-sqlite3 (which both enmap and quickdb use) is blocking but also something like 500% faster than async dbs

#

On those tiny-ass interactions you're going to be doing it doesn't matter at all

earnest phoenix
#

Hi

waxen bough
umbral zealot
#

Both these modules have over 2 million downloads and not once in the entire existence of enmap has anyone ever complained about process blocking having been problematic for them.

final bobcat
#

Hello I would like your help, I am looking to create a command with my bot that sends a first embed and adds arrows emotes below and make sure I can navigate in my menu as long as a cross emote is not put . But I have no idea how to do this can you help me?

waxen bough
#

man i have troubles installing enmap

#

apparently it can't cd to my directory

#

probably because it has space

umbral zealot
#

yes, remove spaces and special characters from your path

waxen bough
umbral zealot
#

yeah that sounds like a massive pain in the ass and also you aiming a shotgun straight at your foot with a twitchy finger on the trigger.

waxen bough
#

hahah yes

umbral zealot
#

also how does dual booting affect folder names though

waxen bough
#

and it's symlinked to my documents folderi in ubuntu

umbral zealot
#

ah well surely there's a wya to get a path without, like, y'know, D:/devel/bots/mybot 😛

waxen bough
#

I can't switch it around because windows can't access ext partitions

#

I got no time to deal with it right now. I guess tomorrow..

#

i'll just sleep i guess

#

bye

umbral zealot
#

good thinking! tired programmers are dumbass programmers 😉

#

enjoy the sleep!

glad ruin
#

i tried everything but how to DM the user when they vote

#

Using js

umbral zealot
#

what "everything" have you tried and how didn't it work?

glad ruin
#

Breh

#

Like Different ways to get the user object

umbral zealot
#

ok so first, what do you mean by "when they vote"

#

when they vote where

glad ruin
#

whn they vote the bot

umbral zealot
#

so on top.gg using the api then

glad ruin
#

ye

umbral zealot
#

the api gives you the ID of the user

glad ruin
#

yes

umbral zealot
#

just get them from client.users.cache.get("user id here")

glad ruin
#

Yeah i tried it... Lemme try again ig :?/

umbral zealot
#

yeah sure

#

then if it doesn't work show us your code

glad ruin
#

oki

vivid fulcrum
#

the user might be uncached

#

which is more than likely the problem

glad ruin
#

Yeah

umbral zealot
#

possible, but one thing at a time, yeh?

#

first we look at the code, then the error

glad ruin
#

But it said bot.users.chache.get isn't a function last time i tested... But how to test it i've already voted...

umbral zealot
#

right, try it now, and show us

#

isn't there a test webhook feature

glad ruin
#

Oh right!

#

Is it my id which comes when i test? @umbral zealot

umbral zealot
#

I think, yes

glad ruin
#

okok

#

So

#
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  console.log(req.vote.user)

  bot.users.cache.get(req.vote.user).send("Thank you for voting me in top.gg!")
})```
#

code

#

Cannot read the property of send

#

is the error

umbral zealot
#

and what does it log

#

in the console.log

glad ruin
#

TypeError: Cannot read property 'send' of undefined

#

But it console logs the id

umbral zealot
#

console.log(req.vote.user) <---- this logs something. what does it log

#

ok good

#

and it's your ID?

glad ruin
#

Ye

#

it is

umbral zealot
#

Great. So it is a question of your user being uncached

glad ruin
#

Hmm yeah

umbral zealot
#

you'll need to fetch them instead. bot.users.fetch(req.vote.user) but note that you'll have to await this because it returns a promise, it's not synchronous.

glad ruin
#

hmm

#

lemme try

#

await bot.users.fetch(req.vote.user).send("Thank you for voting me in top.gg!") not work

umbral zealot
#

no you ca'nt await like that exactly

#

as in you can't chain them

glad ruin
#

SyntaxError: await is only valid in async function

#

ok

umbral zealot
#

and also that

glad ruin
#

So what can i doo?

umbral zealot
glad ruin
#

hmm k

#
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
  console.log(req.vote.user)

  await bot.users.fetch(req.vote.user).send("Thank you for voting me in top.gg!")
})```How to add async in this function @umbral zealot
umbral zealot
#

read the page I Sent

#

please.

glad ruin
#

i meant where

umbral zealot
#

don't make me repeat everythign that's on that page. Read it, learn, understand.

glad ruin
#

Oki

#

ty

#
app.post('/dblwebhook', webhook.middleware(), async (req, res) => {
  console.log(req.vote.user)

  await bot.users.fetch(req.vote.user).send("Thank you for voting me in top.gg!")
})```Now it says `TypeError: bot.users.fetch(...).send is not a function`
pale vessel
#

it's (await fetch()).send()

#

wrap the promise with parentheses

opal plank
#

also it may return undefined

#

dont chain promises without catching them if they fail

glad ruin
#

ok

opal plank
#

imagine handling promise rejections

pale vessel
#

you mean DiscordAPIError?

opal plank
#

not only that

#

but that too

#

handle ur promises

pale vessel
#

that's what users.fetch() throws

#

I think

opal plank
glad ruin
#

ok

pale vessel
#

(await users.fetch(id).catch(() => null))?.send()

#

Br

glad ruin
#

So this would fix it?```js
app.post('/dblwebhook', webhook.middleware(), async (req, res) => {
console.log(req.vote.user)

(await users.fetch(req.cote.user).catch(() => null))?.send("My message")
})```

pale vessel
#

Yes

glad ruin
#

ohk

#

lemme try

pale vessel
#

are you on node v14+?

glad ruin
#

yes

pale vessel
#

Ah, nice

glad ruin
#

Oh wait

#

no

pale vessel
#

change users to <client>.users

glad ruin
#

node v12.16.1

pale vessel
#

oh, then you can't use optional chaining

glad ruin
#

Well how to update

#

I use repl

#

lol

pale vessel
#

you can't update then

glad ruin
#

Oof

#

ok'

glad ruin
#

So what is it

pale vessel
#

just do js const user = await client.users.fetch(id).catch(() => null); if (user) user.send();

glad ruin
#

mh

#

mk

pale vessel
#

if you still want one line then you can do js (await client.users.fetch(id).catch(() => ({ send() {} }))).send("something");

glad ruin
#

ok

#

Twerked TYSM

#

Worked*

#

U are a life saver

vivid fulcrum
#

sending can also fail so you should probably handle that too

glad ruin
#

Yeah i thought of it

#

But

earnest phoenix
#

is there any way to easy up?

let {textcolor} = req.body
await db.set(req.params.id,{
textcolor:textcolor,
})```
pale vessel
#

use void (await client.users.fetch(id).catch(() => ({ send() {} }))).send("something"); unless you want the sent message, use catch()

glad ruin
# vivid fulcrum sending can also fail so you should probably handle that too
app.post('/dblwebhook', webhook.middleware(), async (req, res) => {
  console.log(req.vote.user)

  const user = await bot.users.fetch(req.vote.user).catch(() => null);
  if (user) {
    try {
      user.send("Thank you for voting me in top.gg!");
    } catch (err) {
      if (err) return;
    }
  }
})
```This will remove those errors right?
cinder patio
#

What's the point of void there

pale vessel
#

await it

cinder patio
final bobcat
#

Hello, would you know how to delete all the reactions of a message except that of my bot (for an embed pages)

pale vessel
#

just voids the send() promise

#

so it won't error if it's rejected

pale vessel
vivid fulcrum
pale vessel
#

add await

glad ruin
#

Oki

vivid fulcrum
#

the error will always be defined if the code jumps to the catch clause

glad ruin
#
app.post('/dblwebhook', webhook.middleware(), async (req, res) => {
  console.log(req.vote.user)

  const user = await bot.users.fetch(req.vote.user).catch(() => null);
  if (user) {
    try {
      await user.send("Thank you for voting me in top.gg!");
    } catch (err) {
      if (err) return;
    }
  }
})
```Now?
pale vessel
#

good enough

glad ruin
#

Oki

#

Tysm

#

Ill test rq

pale vessel
#

i'd use user.send().catch(() => null); or try { await user.send(); } catch {} or void user.send();

glad ruin
#

But still now it works right?

pale vessel
#

yeah

earnest phoenix
#

ofc

glad ruin
#

ested and it worked

pale vessel
#

you don't need thatif (err) return; like cry said, it's redundant

#

err will always exist in catch

glad ruin
#

Lol

#

ok

#
app.post('/dblwebhook', webhook.middleware(), async (req, res) => {
  console.log(req.vote.user)

  const user = await bot.users.fetch(req.vote.user).catch(() => null);
  if (user) {
    try {
      await user.send("Thank you for voting me in top.gg!");
    } catch (err) {
      return;
    }
  }
})
```Ye ty
cinder patio
#

Also you need to send 204

glad ruin
#

Wuz tha

#

that*

final bobcat
#

can someone help me now sad

cinder patio
#

A status code

glad ruin
#

oH LIKE 404

cinder patio
#

to let top.gg know that you received the event

glad ruin
cinder patio
#

res.sendStatus(204);

glad ruin
#

keklmfao im sry not that good coder

#

Ok i'll try

#
app.post('/dblwebhook', webhook.middleware(), async (req, res) => {
  res.sendStatus(204);
  console.log(req.vote.user)

  const user = await bot.users.fetch(req.vote.user).catch(() => null);
  if (user) {
    try {
      await user.send("Thank you for voting me in top.gg!");
    } catch (err) {
      return;
    }
  }
})
#

done?

cinder patio
#

I suppose

glad ruin
#

Oki!

#

Ty

pale vessel
#

you don't need to do that, the middleware does it for you @glad ruin

#

it's redundant

cinder patio
#

it does?

pale vessel
#

yeah

glad ruin
#

Oh

#

lol

pale vessel
glad ruin
#

Ohk!

#

So ig i'll remove it

cinder patio
#

that's kinda stupid

#

it shouldn't call next() then

#

oh then the function isn't gonna get called I guess

earnest phoenix
#

How can I do file directories in repl? Lets say I wanted to do like.. image manipulation

opal plank
#

repl is simply a hosting service

#

imagine manipulation you do with your own code

earnest phoenix
#

python

#

I cant use the code in repl

opal plank
#

gotta wait for someone who knows py to let you know

earnest phoenix
#

for image manipulation

opal plank
#

im mostly js/ts

#

wdym you cant?

earnest phoenix
#

Like

opal plank
#

surely python has memory buffers

earnest phoenix
#

this part

#
image = Image.open('C://Users//User//Desktop//wantedposter.jpg')```
#

i cant do that on repl

#

since

opal plank
delicate shore
#

Hey there

opal plank
#

if your wantedposter.jpg is on your project, it should be able to open

#

just use a proper path

earnest phoenix
#

the path works

#

i just cant use it on repl

#

oh i have an idea

opal plank
#

not on repl

delicate shore
#

I have an api and I want to implement an API key system
I have everything set up
User can request a key and I will approve it manually.
The problem is, where can and how can I add the api key in existing list of api keys so I don't have to restart api again and again

what's the best database to use for this
Thanks in advance

opal plank
#

use relative path

#

surely python has such thing

#

i'd be surprised if it didnt

delicate shore
#

My api is made using express package

earnest phoenix
opal plank
earnest phoenix
#

i got it working @opal plank tysm

#

i wathced a yt vid about relative paths

#

and boom

#

ty

quaint wasp
#

How do I find MY port?

vivid fulcrum
#

um

#

it's your butthole probably? don't know

#

or am i thinking of the wrong port

near stratus
#

it'll show all the ports currently served

#

both internal and public

earnest phoenix
#

how can i find the amount of users using my bot, or in a server with it.. like yk sometimes people put in their status "watching 1000 members"

#

ITS ALIVE

sudden geyser
#

now it's dead

quaint wasp
#

or is there a specific one

restive furnace
#

no use the one whats not listed there

quartz kindle
#

you dont "find your port", you have 64k different ports, you chose one to run a server in

#

unless you're using an app hosting like glitch/heroku/repl.it in which case they chose which ports you are allowed to use

earnest phoenix
opal plank
#

right

#

erm

#

yes

restive furnace
#

python is the language but what about the library H5_Thonk

cinder patio
#

come on now

#

that'd be an ok question to ask if the language was js cause there are hundreds of discord libs

restive furnace
#

python has other libs than dpy too, well not hundreds though

quartz kindle
#

xd

opal plank
#

in the bad sense of the word

quartz kindle
#

speshul

restive furnace
#

does it count if i don't even do my bot in js?

opal plank
#

spechul

opal plank
restive furnace
#

i am; holy C

opal plank
#

you are either a Haskell Dev or you're bunched with the rest of the js/py members

restive furnace
#

let me manage my own memory

#

and dangling pointers are nice

#

but true, i should probably learn haskell

sacred juniper
#

Hello

#

I have an question

opal plank
#

i probably have an answer

sacred juniper
#

I have 1GB vram can i play teardown

quartz kindle
#

use the force, thats the answer

opal plank
opal plank
sacred juniper
#

Yes

opal plank
quartz kindle
#

the amount of ram on your gpu is not all that matters, processing power and memory bandwidth matter too

sacred juniper
#

You can check on the steam

opal plank
#

no, i know

#

im wondering what is that related to here tho