#development

1 messages · Page 1506 of 1

slender hamlet
#

so the req.body is just the message object

digital ibex
#

no

#

req.body = { nickname: 'whatever' }

slender hamlet
#

you might want to use a more unique identifier for your bot, like its id

digital ibex
#

what?

#

im not using that to identify my bot

slender hamlet
#

then what's the if statement for?

digital ibex
#

which one

slender hamlet
#

it checks if the username is the bot's username, doesn't it?

digital ibex
#

if

tribal siren
#

how to make a mass-role command?

#

i have this code

#
let members = message.guild.members.cache.filter(m => !m.user.bot)
members.roles.add('763358178049261658')
#

i obv know it's incorrect but i don't know other way :(

slender hamlet
#

do members.forEach((m) =>{})

#

yeah

opal plank
#

no

tribal siren
#

oh ok thanks

opal plank
#

dont use forEach

slender hamlet
#

why not

opal plank
#

use a for loop

#

cuz forEach is unoptimzed as fuck

slender hamlet
#

it returns a collection

#

you cannot iterate over it

#

with a for

opal plank
#

it creates an anon function internally

#

of course you can

#

and forEach doesnt return a collection

slender hamlet
#

cache.filter returns a collection of users mapped to something

#

not foreach

opal plank
#

correct

digital ibex
#

i put the bots nickname in the input on my website, it checks if it is the nickname in a discord server is what i put in the input

opal plank
#

and after that you run a for loop

digital ibex
#

that was so hard to word

#

idk y

slender hamlet
#

you cant iterate over a collection with a vanilla for loop, because they are key-value pairs

#

unless i'm missing something

opal plank
#

of course you can

digital ibex
#

u r

opal plank
#

im not gonna give the full code, but here

digital ibex
#

so do u know why? or

opal plank
#
for(let [k,v] of new Map().entries())

#

that should give out a rough idea of what i mean without spoonfeeding it too much

digital ibex
#

@slender hamlet ?

opal plank
#

you can either use entries or deconstruct it

#

deconstruction might be better, or use values()

#

since you dont care about the key either way

#

collections arent native to js

#

its implemented by discord.js, its an extension of maps

#
slender hamlet
#

hopefully someone else can help

digital ibex
#

i worded it bad

opal plank
#

actually

#

@tribal siren everything i said above was for you btw

slender hamlet
#

or pair them up in the for of

opal plank
#

theres 5 ways you can do it , from the back of my head, all of them will accomplish the same goal

digital ibex
#

if that makes more sense idk

opal plank
#
for(let e of new Map().values())
for(let [k, v] of new Map().entries())
for(let e of new Map().keys()) Map.get(e) //do stuff
for(let [k,v] of [...new Map()])
for(let v of [...new Map().values()])

@slender hamlet and all of those without using unoptimzied forEach

slender hamlet
pale vessel
#

for(let e of new Map().keys()) Map[e] //do stuff what is this

slender hamlet
#

(sorry for making you repeat)

digital ibex
#

the embed gets sent twice as seperate messages

pale vessel
#

you can't access properties like that in map, iirc

#

you need to use .get()

digital ibex
#

it isnt in a loop or anything

opal plank
#

iirc you can, let me check rq

digital ibex
pale vessel
opal plank
#

yeah my bad, i was thinking of an object

#

there we go, fixed

slender hamlet
#

alright let me think about this for a sec

digital ibex
#

does anyone know how to fix my issue?

slender hamlet
#

so when you execute that, does it run twice or just the message gets sent twice?

digital ibex
#

it runs twice

slender hamlet
#

ok

digital ibex
#

so i added a if (client.nick !== nickname) { to stop it but it didnt work

slender hamlet
#

it might have to do with your network request, not 100% sure

#

if its getting called twice

pale vessel
#

what's client

slender hamlet
#

the bot client i assume

digital ibex
#

it gets called twice because the input's text didnt go

digital ibex
#

wait no

#

its just the member object of my bot

pale vessel
#

the member yes ah

digital ibex
#

mb

slender hamlet
#

ok

digital ibex
#

my english is 100 today

slender hamlet
digital ibex
#

no

#

im using ajax

slender hamlet
#

you can manually clear it

digital ibex
#

so it doesnt reload, and i'd prefer to not make it change so they can see

#

ik

earnest phoenix
slender hamlet
#

make sure you require fs as a module

digital ibex
#

like if u enter text in this input, on discord and go to another channel / server, and u come back here to this channel, the text stays if u've not sent it

#

its not the exact same but similar

#

if im making any sense

tribal siren
slender hamlet
#

i see what you mean, but how does that cause it to send a request twice? man I'm sorry for all the questions

digital ibex
#

lets say

#

i update my nickname

opal plank
slender hamlet
digital ibex
#

and press save

slender hamlet
#

yeah

digital ibex
#

the text in the input thing doesnt go away

#

now i wanna change my prefix

slender hamlet
#

yes

tribal siren
#

oh ok\

digital ibex
#

so i change the prefix, and press save

#

and because theres text in the nickname input

#

it sends that to my backend

slender hamlet
#

ah

#

ok

digital ibex
#

so it sends, nickname and prefix in req.body

slender hamlet
#

could it have to do with the fact that you're using === and !== as opposed to == and !=?

#

a shot in the dark, but a shot

digital ibex
#

they r the same, both r strings

#

but i'll try it

slender hamlet
#

yeah, just wondering if it has any impact

#

probably not

digital ibex
#

doesnt do anything

slender hamlet
#

ok

earnest phoenix
#

Ok so I wanna make my bot leave a server each time it reaches the max of discord. I'll base this on member count, and I'm thinking how can i do that the best? I use discord.js

#

(My bot got capped on 250 servers, and will be stuck soon)

digital ibex
#

"max of discord" ?

earnest phoenix
#

ye 250

#

till you verified

digital ibex
#

what is 250

earnest phoenix
#

i could better say

#

250 servers

#

omg

#

dont act dumb

digital ibex
#

whats a server

slender hamlet
#

lmao

earnest phoenix
#

ok man i blocked you

digital ibex
#

whats discord.js

umbral zealot
#

guild.memberCount will give you the amount of members on that guild object

digital ibex
#

oh no!

earnest phoenix
#

yeah

#

I'll make it choose the one with 2-3 members

#

aka test servers

harsh blade
#

My bot only sends this but it should also have pics? (1s sending code)

umbral zealot
#

unfortunately that doesn't give you the number of bots so you can't really check for shitty bot farms

harsh blade
#
client.on('guildMemberAdd', async member => {
let a = client.channels.cache.get("765885272092180483");
  let embed = new Discord.MessageEmbed()
  .setTitle("Welcome")
  .setAuthor(`${member.user.tag} Has Joined.`, member.user.displayAvatarURL,)
  .setThumbnail(member.user.displayAvatarURL)
  .addField('Date Joined', member.user.createdAt, true)
  .addField('Total Members', member.guild.memberCount, true);

    a.send(embed);
digital ibex
#

displayAvatarURL is a function i think

quartz kindle
#

displayAvatarURL is a function

digital ibex
#

and remove the comma at the end of setAuthor, in the parenthesis

slender hamlet
quartz kindle
#

the indentation

slender hamlet
slender hamlet
digital ibex
#

there r other stuff around it thats y its so indented lol

digital ibex
#

its {{{ the code here }}}

#

yes

harsh blade
#

alr

#

what do i do with the function? i thought it worked like that :/

slender hamlet
#

the main thing is he's trying to make it so that the createmessage thing only gets called if the member's username is not already equal to the provided 'nickname' value

pale vessel
#

you need to execute it

#

displayAvatarURL()

slender hamlet
#

so call the method

digital ibex
#

a function is like bob(), bob is not a function, bob() is

quartz kindle
digital ibex
#

the whole thing

slender hamlet
earnest phoenix
#
  client.on('guildCreate', async(guild) => {
    if(client.guilds.cache.size > 240){
      client.guilds.cache.forEach(guild => {
        if(guild.memberCount < 10) {
          guild.owner.send(`I'm sorry, but your server is smaller than 10 members, and this bot is maxed on 250 servers. I'll have to leave! You can invite me later, if I'm verified`)
         await guild.leave()
        }
      });
    }
})```
#

will this work?

quartz kindle
#

then i'd need to see more code

digital ibex
#

like, createMessage, and it logs twice

earnest phoenix
#

it'll check each time it gets added, if there are small servers

#

right?

umbral zealot
#

That should work fine, yes.

digital ibex
umbral zealot
#

though guild.owner might be undefined actually

harsh blade
umbral zealot
#

It's a member, so it's not automatically cached.

digital ibex
#

the () is the function

slender hamlet
digital ibex
#

not the stuff inside the parenthesis

earnest phoenix
#

Oh... I'll have to make it fetch it then ig

#

or something

#

a random channel

umbral zealot
#

yeah probably

slender hamlet
#

displayAvatarURL is a method

harsh blade
#

bruh

digital ibex
umbral zealot
#

thing.property
thing.method()
@harsh blade

digital ibex
#

and just checking if the server's id actually exist

quartz kindle
#

what is lost.changeNick?

digital ibex
#

a method changing a users nickname

#

so in this case, it changes my bots nickname in my discord server

#

@quartz kindle

quartz kindle
#

do you always want to change it?

#

or only if dashboard is enabled?

digital ibex
#

always change it

quartz kindle
#

well, still not enough code

#

theres nothing in there that suggests it being executed multiple times

digital ibex
#

it’s cuz it gets sent back

#

if I change the nickname, and press save. It works fine, if I then change the prefix, bc the text is still in the input, it sends the same thing again, and it gets sent twice

#

I’m using ajax so it doesn’t clear and I’m not manually clearing the input thing

quartz kindle
#

ok so you have 2 input fields, and when you press save, both input fields are sent

#

is that right?

digital ibex
#

I have 3, but was using prefix as an example

#

so kinda ye

quartz kindle
#

so option 1: make a separate save button for each field
option 2: clear all fields after pressing save

digital ibex
#

isn’t there another way?

earnest phoenix
#

orrrr switch to something like react and then you'll have proper state management

digital ibex
#

I’m not at my pc atm

#

when I get to it I’ll show u it all

quartz kindle
#

what kind of other way are you expecting?

lusty quest
#

i still suck with React but its really nice and relatively easy to use

digital ibex
#

idk

quartz kindle
#

check if the values are the same, and dont do anything if they are

untold cargo
#

@crude mantle

digital ibex
#

yeah I’m checking that

#

I have an else which logs nickname is the same

quartz kindle
#

and? is it working?

digital ibex
#

nope

shrewd creek
#

submission = reddit.subreddit("memes").random()
is working

submission = reddit.subreddit("memes").hot()
but this not working ??

#

i get r/memes/hot

lusty quest
#

did you use some sort of api client?

shrewd creek
#

yea

#

praw

lusty quest
#

name of the client? or just use direct api calls

glad violet
#

pls help stop music bot command not working
but saying in chat Leaving..

                case 'stop':
                  var server = servers[message.guild.id];
                  if(message.guild.voice.connection){
                      for(var i = server.queue.length -1; i >=0; i--){
                          server.queue.splice(i, 1);
                 } 
               if(server.dispatcher) server.dispatcher.end();
               message.channel.send("Leaving...")
                      console.log('Leaved Succes')

                 }
                 
                 if(message.guild.connection) message.guild.voice.connection.disconnect();
              break;
#

and DO NOT SAY ABOUT server.dispatcher

earnest phoenix
#

STOP SHOUTING AT ME 😭

glad violet
#

who shouted at u

lusty quest
shrewd creek
#

oh..thx for trying

glad violet
#

can anyone help me pls

lusty quest
#

i stay as far away from Music bots as possible

#

they are a pain in the ass to maintain

lusty quest
# shrewd creek oh..thx for trying

i would just make a direct call to the Reddit API tbh https://www.reddit.com/r/memes.json?sort=hot this one will give you the first 100 posts iirc

shrewd creek
earnest phoenix
#

praw is sync, blocking

shrewd creek
#

reddit meme

shrewd creek
#

random meme is geting generated

earnest phoenix
#

Doesn't change the fact it's blocking

earnest phoenix
deft lark
#

a

earnest phoenix
#

you can't indent like that

humble rock
humble rock
earnest phoenix
#

but this work

#

it doesn't

#

you're missing a comma

#

it isn't valid json

pure lion
#

I'm getting something from an api and it replaces all 's with '. How can I parse these back to punctuation?

earnest phoenix
earnest phoenix
#

it's erroring because you indented it

lusty quest
#

then 2nd answer looks promising

pure lion
#

just gonna install he

earnest phoenix
#

oh also, in JSON all field names need to be encased in quotes too @earnest phoenix

#

so it would be "obje": true

earnest phoenix
summer torrent
#

have you tried to search on google?

earnest phoenix
#

I already found it

feral aspen
#

Hello

#

Basically I have a messageDelete event with a MongoDB database

#
const Server = require("../../models/guilds/server.js");

module.exports = async (bot, message, guild) => {

    Server.findOne({
        serverID: guild.id
    },

// some other code..... 
lusty quest
#

what did you want to do?

feral aspen
#

(node:14656) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined at serverID: guild.id

mellow kelp
#

messageDelete doesn't have a guild argument

lusty quest
#

just get the guild id from the message?

harsh blade
#

Hey uhh, how do i set a author avatar in a embed? V12

feral aspen
tribal siren
#
let member = message.guild.members.cache.filter(m => m.user.roles.cache.some(role));```
#

why it no work :(

lusty quest
#

bcs you try to get a role from a user

gritty bolt
#

how do I make a bot commands banlist?

tribal siren
#

TypeError: Cannot read property "cache" of undefined

gritty bolt
#

with the new / cmd system?

#

discord.js?

misty sigil
#

if you're gonna be fetching that often

feral aspen
#

By?

tribal siren
gritty bolt
#

like when a specific user runs a command, it doesn't work

opal plank
gritty bolt
#

no thats what I want to happen

opal plank
#

im not sure if d.js already released an update for slash commands support

gritty bolt
#

I just don

#

I have it raw coded

harsh blade
#
  .setAuthor(`${member.user.tag} Has Joined the server!`, member.user.displayAvatarURL("png"))

How do i set the author avatar to be the BOTS avatar?

gritty bolt
#

I don't know how to get a uID from it

opal plank
#

what you got rn?

gritty bolt
#
client.ws.on('INTERACTION_CREATE', async interaction => {
const command = interaction.data.name.toLowerCase();
const args = interaction.data.options;
if(command == "start") {
client.api.interactions(interaction.id, interaction.token).callback.post({
    data: {
      type: 4,
      data: {
        content: "Test"
      }
    }
  })
}````
opal plank
#

at first glance i dont see anything particularly jumping out

#

though at the same time i havent played with slash commands

#

well, that explains it

gritty bolt
#

I don't understand

#

how to get the uID

opal plank
#

you copied from here didnt you?

gritty bolt
#

haha yup

#

it's a bot for my personal use

#

it's all temporary right now but I need to limit a specific person from using it

opal plank
#

did you set a command first?

gritty bolt
#

yes the commands work

#

I just don't want them to work for a specific user

#

who's been messing with it

turbid falcon
#

What's the work of @gilded plank ?

#

What's the prefix?

gritty bolt
#

I was thinking of a banlist.json and then checking if the uIDs math any of them, but I have no idea how to grab the uIDs from this

#

and I can't find anything explaining how to

turbid falcon
opal plank
#

on member @gritty bolt

#

im not sure if dj.s resolves that to user

#

but regardless it gets an id

gritty bolt
#

OHH THIS IS EXACTLY WHAT I'VE BEEN LOOKING FOR

#

thanks so much

opal plank
#

np

crystal wigeon
#

hey guys

#

so ummm

#

my bot hit around 100 servers today

#

i got the verification DM from discord

#

but it says suspecisions growth like wtf? i mean yeah players did flood in like 30 mins

#

i was at 15 servers around 6om and around 6:30pm 7pm my bot went viral

#

now i have like 200 players and 100 servers

#

i verified my drivers liscense ID

#

but discord says sus growth like lmao

#

what do i do

mellow kelp
#

probably join the dev server for support

#

i don't remember the invite link tho

solemn latch
#

suspicous growth is just very fast growth. you should wait a few weeks before submitting your bot again

#

i got it

earnest phoenix
#

it can also mean that a lot of your bots guilds come from the same user

solemn latch
#

thats inorganic no?

earnest phoenix
#

oh

#

no idea

solemn latch
earnest phoenix
#

You don't have access to this link moment

solemn latch
#

you have to join the support server.

earnest phoenix
#

I know, cba

crystal wigeon
#

yeah i did

#

btw discordjs returns the first user if they have the same username

#

is there a workaround for this?

#

this is a major issue

solemn latch
#

you mean using fetch?

crystal wigeon
#

because my bot will thikn its alwayus the first guy

#

yeah

solemn latch
#

is there a reason your using usernames not ids to fetch?

crystal wigeon
#

for example if there's another guy with "hoax" if i type in something like "hoax" my bot will detect the first guy

#

because i wanted it to work even with username/nicnnames

#

not mentioning them

#

like "battle username"

#

not "battle @mention"

#

its a pain if he has to mention everytime

solemn latch
#

well, discord cant know specific context like that. your best bet is filtering to make sure the user is in the same guild, but even that it cant be 100%

#

since nicknames and usernames are not unique its really hard to tell who you mean

finite stirrup
#

yo guys is it real that discord ain't giving verified bot dev badge no more?

opal plank
#

yes

crimson vapor
#

yep

solemn latch
#

yeah, too many people made bots to get the badge

finite stirrup
#

lol thanks

opal plank
#

shitty bots*

lusty quest
#

and then everyone told me to wait with verifying my bot, while i where doing it relatively early

opal plank
#

F

lusty quest
#

nah got the badge bcs i dont give a fuck about other peoples think about it.

finite stirrup
#

i got the verification message today from discord

opal plank
#

im not gonna lie, my code needs some SERIOUS optimization

finite stirrup
#

but applications are opening on 11

opal plank
lusty quest
#

i think about recoding my entire Bot. but im not sure if i should Learn Rust or C# and then recode in it

opal plank
#

thats seem way too much

lusty quest
#

wtf

#

i use 80-100MB for 300 Guilds

finite stirrup
opal plank
#

i have my own stuff mixed in too, its not raw d.js

#

thats my dashboard

lusty quest
#

looks like Grafana

opal plank
#

ye

#

look at all those curves and shapes

finite stirrup
#

so good

#

how did you integrate the bot with that

lusty quest
#

had the plan to make a Grafana Dashboard for my bot, looked into Time Series Databases and then decided its not worth for the moment

opal plank
#

with a lot of coding

#

grafana is literally just a display, everything backend you need to code

#

you need to feed grafana all this data, which isnt easy at all

finite stirrup
#

oh ok

solemn latch
#

it actually is super confusing then its all super simple.
I dont know why someone hasnt made a simple explanation of how it works.

opal plank
#

cuz there isnt a simple explanation

#

grafana ISNT easy to fuck with

#

for simple stuff? sure

#

for this sort of stuff? absolutely not

swift cloak
opal plank
#

each panel for the SQL queries is about 41 lines long

solemn latch
#

wow, i didnt have to do that at all Thonk

drifting wedge
#

document.getElementById("status").innerHTML = "Error - Ratelimited"; its saying, can not set to null

#

wat

solemn latch
#

i just used an off the shelf panel

#

since there are hundreds of them pre made

opal plank
#

not only do you need to know grafana, you need to know how macros, SQL, elk, Postgres, Prom and some other stuff

#

the pre-made ones will simply use a node-exporter

#

it'll tell you ram usage and traffic, thats about it

#

i've seen em'

solemn latch
#

then you just add your own queries on top.

opal plank
#

you making it too simple dude

solemn latch
#

my bots been shut down, but i had most the metrics you have

#

🤔

opal plank
#

grafana is easy for some stuff, for this kind? not really

heavy anchor
#

Bruh idk wtf I'm doing lol

const express = require('express')
const fetch = require('node-fetch')
const app = express()
const port = 3000

app.get('/:site', (req, res) => {
    fetch(req.params.site)
        .then(res => res.text())
        .then(body => {
            res.send(body);
        });

});

app.listen(port, () => {
    console.log(`app listening at http://localhost:${port}`)
})
stark abyss
#

is it api spam to give 30-50 people a role? Or would it be okay if I give someone a role every second

solemn latch
#

generally you shouldnt mass give roles.

opal plank
#

^^

solemn latch
#

or mass do anything.

stark abyss
#

okay well the max it would is 50 members not like entire guild

#

most of the time it would be around 20-30

solemn latch
#

its not about the number of people, its the fact its done in mass

dusky sundial
#

That's still a lot of actions in a tiny amount of time

stark abyss
#

i see

#

what if i make the gap larger like 10 secs

opal plank
#

woo, this btw

#

those 2

#

one panel

#
{
  "fieldConfig": {
    "defaults": {
      "custom": {},
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "dark-green",
            "value": 10
          },
          {
            "color": "super-light-yellow",
            "value": 20
          },
          {
            "color": "semi-dark-yellow",
            "value": 40
          },
          {
            "color": "light-orange",
            "value": 60
          },
          {
            "color": "dark-orange",
            "value": 80
          },
          {
            "color": "light-red",
            "value": 100
          },
          {
            "color": "dark-red",
            "value": 140
          }
        ]
      },
      "mappings": []
    },
    "overrides": []
  },
  "gridPos": {
    "h": 3,
    "w": 4,
    "x": 20,
    "y": 3
  },
  "id": 10,
  "options": {
    "reduceOptions": {
      "values": false,
      "calcs": [
        "mean"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "area",
    "justifyMode": "auto"
  },
  "pluginVersion": "7.1.4",
  "targets": [
    {
      "expr": "rate(genshin_discord_ws_guild_member_add[1h]) * 60 * 60",
      "interval": "",
      "legendFormat": "Members Join/h",
      "refId": "B"
    },
    {
      "expr": "rate(genshin_discord_ws_guild_member_remove[1h]) * 60 * 60",
      "interval": "",
      "legendFormat": "Members Left/h",
      "refId": "C"
    }
  ],
  "timeFrom": null,
  "timeShift": null,
  "title": "",
  "transparent": true,
  "type": "stat",
  "datasource": null
}```
drifting wedge
opal plank
drifting wedge
#

wdym?

opal plank
#

that whole thing is for that single panel

solemn latch
#

isnt that just a tsdb with basic math at each point 🤔

drifting wedge
#

like the server staff, gets the graph?

earnest phoenix
#

yo guys would there be a problem if i use 2 command handlers

solemn latch
#

graphana has something built in for those things

opal plank
#

ignore the grid and the post, those are autogenerated

drifting wedge
#

oh and also, how do you display like text, and logs in grafana?

opal plank
#

not the majority of it

#

you're trying toi display static data

drifting wedge
#

i use it for graphs, but i wanna have like join/leave logs etc

opal plank
#

not dynamic

earnest phoenix
#

yo guys would there be a problem if i use 2 command handlers?

opal plank
#

SQL raw requeries, grafana isnt meant to be a log, you'd use an elk stack for that

#

i do it cuz i dont want to use another panel

drifting wedge
#

ye, how do u get the like guid logs and the other types of graphs?

#

oh

#

so super complicated?

opal plank
#

basically, yeah

#

i can list all you need to know, but its one hell of a curve to learn

drifting wedge
#

fuck

#

alr

#

nah im good lmfao

opal plank
#

oke

drifting wedge
#

ill do later

#

ty

#

tho

opal plank
#

np

drifting wedge
#

document.getElementById("status").innerHTML = "Error - Ratelimited"; its saying, can not set to null

pale vessel
#

did you put it on the bottom of the page

cinder patio
#

or in the body.onload event

drifting wedge
#

yes

cinder patio
#

is there an element with the status id

#

id, not class

drifting wedge
#

yes

#

wait

#

omg gimme a min

#

either im dumb or i cant read

solemn latch
#

@opal plank is it because you use sql and i used Prometheus queries our experience was so different?

opal plank
#

i also use prom

solemn latch
#

so do you use their graphing queries?

opal plank
#

prom cant query strings or display it

opal plank
#

you need value for querying prom

#

not strings

solemn latch
#

why are you querying strings for join and leave rates

opal plank
#

not for that

#

thats using prom

solemn latch
#

but that was the hard one Thonk

opal plank
#

yes, prom you need to setup on your bot, set the tresholds and set the rates with the proper value measurements

solemn latch
#

did you not use the prom lib?

opal plank
#

yes?

#

but like i said, thats not all of it

solemn latch
#

my rates where one line

opal plank
#

for logs you'd use kibana

#

not grafana

#

im abusing SQL to use string based grafs

solemn latch
#

ohhh he wants logs

opal plank
#

and tables

crystal wigeon
#

how do you disable bot's invite link?

opal plank
#

the queries for my sql are 40 lines long

crystal wigeon
#

like people are flooding lol

drifting wedge
solemn latch
#

i thought you where saying grafana is hard for basic rates and stuff.

opal plank
#

and thats PRECISELY why you need rates and setup stuff like that

#

otherwise it looks that fonky

drifting wedge
#

its not that

drifting wedge
#

its cuz im not updating it / running it

#

dw

opal plank
#

rates and macros

#

those are possibly the most annoying to setup

drifting wedge
#

HOW DO YOU DO THAT THOHOHOOH

#

iTS SO NICE

opal plank
#

cuz half of the time when you use the query helper it wont do what you need

#

its too basic

#

the helper is fine for simple stuff, but past a point it cant help you and you need to use raw SQL to parse it

drifting wedge
opal plank
#

like i mentioned, you are NOT suppose to use grafana for logs, you'd use kibana

drifting wedge
#

alr

solemn latch
#

grafana

eternal osprey
#

hey

solemn latch
#

graphing tool for graphing any metric

eternal osprey
#

is there a function called: if (message.member.hasPermission("OWNER"))

#

As i only want owners to use a command

#

couldn't find it in the docs

earnest phoenix
#

quite literally just compare ids

#

lol

eternal osprey
earnest phoenix
#

you're thinking too far into it

#

there aren't multiple owners

eternal osprey
earnest phoenix
#

...get the guild from the message?

eternal osprey
#

People can join a server...

#

add the bot to their own

#

and use the !server command as owner

#

idk what their server ids are.

earnest phoenix
#

what in the literal fuck are you trying to do

eternal osprey
#

what i said, does that work?

eternal osprey
solemn latch
#

are you saying you want anyone who owns any discord server should be able to do this command?

eternal osprey
#

Only the owners of their servers.

solemn latch
#

then compare ids?

winged tapir
#

Huh

gilded olive
#

all of their servers?

eternal osprey
gilded olive
#

Oh

eternal osprey
#

i cannot compare ids as i don't know their ids yet.

earnest phoenix
#

IS IT FINE IF I HAVE 2 COMMAND HANDLER NO 9NE ANSWERED MY QUESTION

solemn latch
#

sure

earnest phoenix
#

no

gilded olive
#

(woo help him cuz idk js)

eternal osprey
#

is there a function called: if (message.member.hasPermission("OWNER")) would this work?

solemn latch
#

no

eternal osprey
solemn latch
earnest phoenix
#

no to both of you

#

literally what are you trying to do

#

@earnest phoenix why can’t I have 2 command handlers?

pastel horizon
#

0

eternal osprey
#

Okay i am just going to check on administrators than.

solemn latch
#

you can have two command handlers, its a terrible idea, but you can have two.

earnest phoenix
#

@solemn latch all good thanks

#

best practice is to keep everything contained to a single event, otherwise you're just wasting cpu power

#

cache.get returned undefined

#

find out why

earnest phoenix
lusty quest
#

look into the caching behavior of Discord just as a tip

solemn latch
#

im so confused what is going on in this 🤔

lusty quest
#

he trys to get a uncached channel

earnest phoenix
#

channels should be cached at all times

#

it's probably the value they're passing into get

#

that's why i said find out why

lusty quest
#

possible, but you dont know if he runs normal d.js or something else

#

d.js-light as example dont cache channels by default

eternal osprey
#

hey guys another question. How would i get the server id of the server a message was sent in>

lusty quest
solemn latch
#

this actually looks like api abuse, looks like he is trying to mass send messages to many guilds right?

lusty quest
#

the snippet above

eternal osprey
solemn latch
#

the one who is mass sending messages to many guilds lol

eternal osprey
#

yeah this is a channel spammer.

lusty quest
#

well he will end up here crying that his bot got Locked for atleast 24 Hours by the API

feral aspen
#

A user is deleting another user's message in messageDelete event, how can I get that user who deleted the other user?
message.author.username will just show who sent the message, but not who deleted it.
How can I get the user who deleted it?

solemn latch
#

I dont think the user who deleted it is given in that event.

feral aspen
#

Aww, that is unfortunate.

#

Alright.

#

Is there another thing I could do to get the user?

lusty quest
#

i think you could get it over the Audit logs

solemn latch
#

i thought audit logs only log bulk deletes

lusty quest
#

but this would be some stupid code tbh

#

idk where just an idea

feral aspen
#

Well, not gonna put my self in situations, just gonna remove it and make it slide for now.

gilded olive
#

Audit logs yes

#

But they arent highly reliable cuz not every message shows up

solemn latch
#

🤔

#

oh heck it does do any deleted message

#

i thought it was just bulk deletes

gilded olive
#

So you could do it, but not every messsge would be logged

#

I believe dyno does this as well

feral aspen
#

I'll make it slide for now.

harsh blade
#
client.on('guildMemberAdd',  member => {
  let embed = new Discord.MessageEmbed()
  .setColor('#ff00e0')
  .setAuthor("Just before we get started..."), client.user.displayAvatarURL()
  .setThumbnail("ddmegadoodoo.png")
  .addField('Please read the #〔💌〕rules!')
  .addField('By being in this discord, you automatically agree to these rules.')
  .addField('**Leaving this discord at any point will get your services with us suspended!**');
member.send(embed);
});
#

i cant figure this out

tired panther
#

my reaction role is not working
but I added partial

#

Do you need Intent?

harsh blade
#

?

ancient nova
#

I don't think you can do , on that

#

I think that's the issue there

harsh blade
#

Hm

#

Yup

#

thanks

ancient nova
#

no worries

solemn latch
pliant elbow
#

Just to help if anyone would need it, this regex can be used if you want your bot to check if an argument is an image URL: ```js
var regex =
message.content.match(new RegExp(https?:\/\/.*(?:png|jpg), 'i'));
if(!regex){
console.log('Invalid URL')

sudden geyser
#

There are a million ways to match URLs. I'm surprised JS doesn't feature a class to parse a URL and see if it's valid.

mellow kelp
#

maybe the url node module works

pliant elbow
#

I find using a rational expression easier

#

And only posted it cuz this regex is acc quite useful

sudden geyser
mellow kelp
#

poggers

pliant elbow
#

Thats an exact url tho

mellow kelp
#

you might also want to check the url extension

sudden geyser
#

You're matching an exact URL though

pliant elbow
#

Nope

#

The regex checks to see if the url is of an image

#

like if you type youtube.com

#

it will say invalid

sudden geyser
#

But I can write https://.png and it'll work

pliant elbow
#

since it isnt an image url

pliant elbow
#

it doesnt just check for png maybe if you added something else to it then again, it will check

sudden geyser
earnest phoenix
#

this might help

pliant elbow
#

Wait lemme just test if https://.png works

#

Yea so it would accept that

sudden geyser
#

In general I prefer an implementation in the standard library of a language/library/framework over regex matching when what to match can be complicated, like URLs. Like in another language, I can just do URL(string: "https://google.com/") and it'll return an URL? so it tells me if the URL is correct. There's no need for action from there unless I want to look at the contents, like the host, scheme, endpoint, etc.

and urlregex.com is useful

pliant elbow
#

right, but again, in this case you dont wanna check for an exact url you wanna check the TYPE of url. And this is when you mostly need to use a regex

earnest phoenix
#

oh

#

your goal is to check if the url is an image url?

pliant elbow
#

Yea, and i already got it, i just put it here in case anyone else would need it

earnest phoenix
#

well

#

sorry to break it to you

#

but you have to make a request to the url and check the content mime type

#

it's not 1995 anymore, images can be served from any path, with or without the extension

#

even checking the mime type is not enough in some cases, for example, discord

#

discord sets the mime type to whatever the extension is

#

but someone can rename an .mp4 file to a .png

#

and it'll get served as a png, when it in fact isn't

pliant elbow
#

Oh truee

mellow kelp
#

dang

#

this sure has gotten complicated

earnest phoenix
#

which leaves you with the final option: download the first few bytes of the file and check the file header (magic number)

pliant elbow
#

right

earnest phoenix
solemn latch
#

its so magical

crimson vapor
#

smh ghost ping?

shut spear
#

hey

#

wanna send a text message to a channel if sending embed messages are disabled like this

#
        message.channel.send(helpEmbed);
    } catch(err){
        console.log("catch");
        msg.channel.send("Can not send an embed message, make sure that I have permission to send embed messages");
    }```
#

but it doesnt fire the catch somehow

earnest phoenix
#

because you aren't awaiting send - why not just check for permissions before sending the message?

#

that way you don't waste a request

crimson vapor
#

what does it mean when a shard closes without a reason nor a code?

shut spear
#

if its latter its ok

#

but if bot has no role and channel's send embed is disabled, checking permission makes no sense

hoary delta
#

Can anyone test their own bot commands in #commands ?

earnest phoenix
#

i need help my brain frozed i need make: A code is a code that can close a vulnerability called anti-raid what it does if a bot or someone tries to create or delete channels between 1 and 5 seconds, the code will re-create/ delete channels and alert the server constructor with dm

#

who can help me

#

@ornate otter

ornate otter
#

I honestly dont know cus im kinda tired and im not the best dev when im not tired either

earnest phoenix
#

😭

ornate otter
#

im sure someone will be willing to help just rn im frazalled cus @languid dragon be playing good music and it making me tired

earnest phoenix
#

i make music bot too :d

#

@bronze summit

ornate otter
#

no its not a music bot

#

its him just playing his music on guitar

earnest phoenix
#

oh

shrewd creek
#

intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=["#","# ","goji ","Goji "], description='gojiraaaa!!!',intents=intents)
bot.add_cog(Music(bot))

how to add more cogs

#

i hv two more cogs but if i add those commands in that cog are not working

#

@earnest phoenix

#

?

#

??

pearl coral
#

some know why my bot don't show my information when i write the command on pc but when i write the command on mobilphone its showing?

earnest phoenix
#

give context with your question

#

it's as if you asked me "why does my washing machine work but my grandma's doesn't?"

pearl coral
#

xd

#

ok sorry

#

i should said better my question xd

#

my bot doesn't work when i write from computer, but he works when i write from mobilphone

earnest phoenix
#

yeah it's fine, just gotta give more context

shrewd creek
#

yo how to add multiple cogs?

gilded olive
#

you make them a list

#

and you load them like that

#
initial_extensions = []
for extension in initial_extensions:
  bot.load_extension(extension)```
shrewd creek
#

so inside those brackets i put my cog names?

gilded olive
#

yes

shrewd creek
#

initial_extensions = [music,genral,fun]
for extension in initial_extensions:
bot.load_extension(extension)

?

gilded olive
#

no

shrewd creek
#

lik this

gilded olive
#

they are strings

#

first of all

pearl coral
#

some has any idea about my problem? 😦

gilded olive
#

and they must represent your file path

shrewd creek
#

lol i put all cogs in same file "
so now i hv to distribute those classes and

#

get those in this

gilded olive
#

example, if one of your cogs were cogs/music.py, you would do

initial_extensions = ['cogs.music']```
shrewd creek
#

ok thx bro

shrewd creek
pearl coral
#

okey

earnest phoenix
#

i need free node.js developer

#

to help me cause my brain frozed

sudden geyser
#

Explain what you need help with

mellow kelp
#

yea

pearl coral
#

if i call my bot on private msg he works

#

but he doesnt work in general channel

#

in computer

sudden geyser
#

You need to provide more details. What isn't working when you call your bot in a server? What's the code being run that's failing? Are you getting any errors?

earnest phoenix
#

Why collector.on('collect'); dont work?

        const collector = new Eris.MessageCollector(message.channel, { filter: () => true, timeout: 10000, count: 5 })
        collector.on('collect', res => {
            console.log(res);
        });```
#

The message collector constructor doesn't take an option called filter

#

It takes 3 parameters

#

channel, filter, options

#

So the filter should be there

#

🗿 Wait you using eris?

#

Yes

#

Lmao i didn't realize

#

Damn, that's kinda a bruh moment

half surge
#

is json bad?

earnest phoenix
#

JSON is good for only read purposes, it's bad for read and write purposes since it can be corrupted

solemn latch
#

json is fantastic for what it is intended to be used for.

mellow kelp
#

yeah

#
  • human-readable
#
  • machine-readable
#
  • can be minified
#
  • simple syntax
earnest phoenix
#

Now we talked about the pros

#

Lemme get the huge list of cons

mellow kelp
#

aight imma head out

quartz kindle
#

json is great to transfer data between things

marble juniper
crimson vapor
quartz kindle
#

jason db voorhees will hunt you down

solemn leaf
#

can I get help with mobile exports

solemn latch
#

mobile exports?

#

trying to export some cell phones? KEKW

solemn leaf
#

exporting data from one file to another

solemn latch
#

do you mean module exports?

mellow kelp
#

use module.exports

solemn leaf
#

yeah that

urban olive
#

hey quick question

solemn latch
#

do you have a specific question, or just generic "help me"?

#

yo

urban olive
#

you know how some bots create small disposable bot accounts?

mellow kelp
#

those are probably just webhooks

urban olive
#

oh webhooks?

mellow kelp
#

yea

#

try clicking on the profile pic

solemn latch
mellow kelp
#

webhooks don't have notes, roles and some other stuff

solemn leaf
#

how do I export soemthing?

solemn latch
#

theres several ways of using module exports

solemn leaf
#

I want to export 2 strings

urban olive
#

ooh, guess i need to look into webhoooks then

stark abyss
#

How can I use data outside .then() or an await function while resolving a promise?

#

maybe I am being dumb, but everything I tried failed

solemn latch
#

you mean awaiting it?

stark abyss
#

yeah

solemn latch
#

just use await on the promise

summer torrent
#

use async/await

urban olive
#

alright thanks for the help 👍

stark abyss
#

but i would have to put await in an async function

#

and that's where i am having bit of trouble, i can't use the data freely outside of that function

mellow kelp
#

you're not supposed to use .then with async/await i think

#

except in some cases

stark abyss
#

i am not

mellow kelp
#

o

earnest phoenix
#

what are you actually trying to do

stark abyss
#

hold on let me show code

#
let player1 = drawCards('id', 1)
console.log(player1) 
async function drawCards(deckid, countNum){
  player1 = await fetch(`https://deckofcardsapi.com/api/deck/${deckid}/draw/?count=${countNum}`)
})```
and this console logs promise pending
earnest phoenix
#

...await drawCards?

stark abyss
#

am I not supposed to do this?

wise hawk
#
await drawCards('id', 1)
earnest phoenix
#

or then pattern

solemn latch
#

im kind of confused why you need an api for a deck of cards

earnest phoenix
#

that pattern seems super weird overall

solemn latch
#

isnt that like one of the first things you learn to program

stark abyss
wise hawk
#

yep

earnest phoenix
#

this pattern makes no sense whatsoever

stark abyss
#

well i didn't AHWeirdChamp and it's very convenient especially because it also has images

solemn latch
#

there are tons of royalty free decks online

#

making decks is like day one programming.

solemn leaf
#
            exports = {
                value: () => {
                    return value;
                },
                value: () => {
                    return value;
                }
           }
const value = require("./file.js")

Cosnole.log(value)
#

@solemn latch ?

earnest phoenix
#

const player1 = await drawCards(...);
//or
drawCards().then((result) => {
  //do whatever
});

function drawCards(...) {
  return fetch(....);
}

this is the pattern you should use

stark abyss
#

okay cry ty

#

and this is more about the learning process of promises weird

earnest phoenix
#

keep in mind

#

fetch returns the request, not the response

solemn leaf
#

cry

#

how do I use module.exports

stark abyss
#

okay

earnest phoenix
#

if you want the response (presuming it's in json) you should turn drawCards into

async function drawCards(...) {
  const response = await fetch(...);
  return await response.json();
}
solemn leaf
#

cry

earnest phoenix
#

i saw your question

#

i don't know

solemn latch
#

did you read the article i posted

solemn leaf
#

oh

#

yea

solemn latch
#

then whats the issue

solemn leaf
#

module is always undenifed

#

removing it

#

it doesnt do anything

molten yarrow
solemn leaf
#

basicly it

#
            exports = {
                value: () => {
                    return value;
                },
                value: () => {
                    return value;
                }
           }
const { value, value } = require("./file.js")

console.log(value)
mellow kelp
#

um what

solemn latch
#

Cosnole.log(value)

#

🤔

solemn leaf
#

its just an example

#

of what I have

limpid bear
#

i am having a hard time to get my bot to react to its own message

earnest phoenix
#

...okay? what have you done so far

limpid bear
#

i am back at square 1.

earnest phoenix
#

don't spoonfeed

#

🙄

stark abyss
#

ok

solemn leaf
#

you are also spoonfeeding bad practices

stark abyss
#

I was trying to help but sorry

earnest phoenix
#

guide them to the solution instead of feeding them the code

solemn leaf
#

((msg) => ())

#

@mellow kelp yo

mellow kelp
#

what

solemn leaf
#

did I do it right?

mellow kelp
#

what?

solemn leaf
#

the export

molten yarrow
#

use module.exports

mellow kelp
solemn leaf
#

okay

mellow kelp
#

-at least if that's exactly what you have

solemn leaf
#

ReferenceError: module is not defined

mellow kelp
#

you running your file as a commonjs module?

solemn leaf
#

?

mellow kelp
#

how are you running your file

solemn leaf
#

node

#

html

mellow kelp
#

um

limpid bear
#

i am just as confused as i was when i started. no i am more confused

mellow kelp
#

javascript in the browser doesn't use modules

solemn leaf
#

so I cant export?
\

mellow kelp
#

not in the browser

#

modules work with node

solemn latch
#

pretty sure the article i linked goes over that

earnest phoenix
#

you theoretically can

#

you just have to webpack your code

mellow kelp
#

well yea

#

but not with vanilla

earnest phoenix
#

and optionally babel it

mellow kelp
#

and you can define your script tag with type="module" and use import/export

#

but those are weird when used with browsers so i dont use them

earnest phoenix
#

i'm pretty sure very few browsers are compatible with import/export

sage bobcat
#

One message removed from a suspended account.

mellow kelp
#

hm yes

#

5/5

earnest phoenix
#

👁️ 👄 👁️

solemn leaf
#

all do but mobile browsers

#

an internet explorer

solemn latch
#

better use pm2 with it, just in case it goes down.

sage bobcat
#

One message removed from a suspended account.

mellow kelp
#

true tho

#

i don't really like using require on the whole discord module lmao

earnest phoenix
#

import + tree shaking

mellow kelp
#

i guess most people who use const Discord = require('discord.js') are just following tutorials

#

how hard is it to use const { Client } = require('discord.js')

honest perch
#

Both do the same thing ¯\_(ツ)_/¯

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

mellow kelp
#

wait really

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

🤢

sage bobcat
#

One message removed from a suspended account.

honest perch
#

C#?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

dnet is an absolute shitshow

sage bobcat
#

One message removed from a suspended account.

solemn leaf
#

How would I sent values to my main handler

earnest phoenix
#

the difference between dsp and dnet is like heaven and hell

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

they work similarly but dsp exposes the type as a property instead of using polymorphism

#

kind of like djs

sage bobcat
#

One message removed from a suspended account.

crimson vapor
#

Is there any real reason to not do const Discord = require(‘discord.js’)

earnest phoenix
#

unless you bundle your app into something

#

nope

#

just readability

crimson vapor
#

What do you mean by bundle your app into something?

earnest phoenix
#

you might also save some time by not doing that but we're talking like 800ns to a few ms

earnest phoenix
crimson vapor
#

Oh

earnest phoenix
#

because by not doing that you reduce the amount of modules that need to be in the actual code

#

so logically, you wouldn't do it if your goal is to reduce your bundle size

mellow kelp
#

yeah with require there's little to no difference

#

i think it matters with import/export tho, doesn't it?

ionic dawn
#

How can I check if a user have a specific role in a specific guild?

#

cant I make: <Guild>.members.cache.get(message.author.id) and the x.roles.cache.has("roleid")?

lyric mountain
#

Roles collection will contain roles not ids

#

You'll need to use find

ionic dawn
#

just did members.fetch instead

ionic dawn
umbral zealot
#

Well that's the first part, and you can use the second as you have it

#

Safer to fetch, for members, you're right.

lyric mountain
ionic dawn
#

just blocking some commands from my bot so only people with a role in the support guild can use them

#

"Bot admins" etc

lyric mountain
#

You can't search if an id is withing a role collection

#

I mean, directly

ionic dawn
#

@lyric mountain check the x.

umbral zealot
lyric mountain
#

Nvm then

umbral zealot
#

smh people talking out of their ass with such confidence. Great example of Dunning Kruger.

ionic dawn
#

im not talking with confidence

#

im just saying it, it does have them whut

#

if Im askin questions here its because im no expert

umbral zealot
#

No I meant KuuHaKu. Lol.

ionic dawn
lyric mountain
#

Well, sorry for thinking it returned a List evie, didn't think I'd trigger your inflated af intelligence

umbral zealot
#

"List"? That's not even a thing in JavaScript...

lyric mountain
#

Array, whatever it's called in js

umbral zealot
#

well, just try to actually know the answer when you help someone instead of just randomly throwing bad information out there. ¯\_(ツ)_/¯

mellow kelp
#

whoa people really out there calling someone out for calling an array "list"

lyric mountain
#

I'm not saying I'm right, I did make a mistake there, the issue is how you addressed my answer

#

"people talking out of their ass with such confidence"
Yeah, fuck it

drifting wedge
#

uh does innerhtml work with ``? with multiline code?

solemn leaf
#

exe do you know what this means?
script.js:1 Uncaught SyntaxError: Unexpected token '<'

const socket = io('/')
drifting wedge
#
        document.getElementById("status").innerHTML = `<div class="alert alert-success alert-dismissible fade show" role="alert" style="float: right; background-color: #f15050; border-color: #f15050;">
        <span class=""><b id="status" style="font-size: 17px;">Error - Ratelimited</b></span>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true" style="margin-top: 2px; font-size: 30px;">&times;</span>
        </button>
    </div>`;```
#

this is my code and it no worky

#
document.getElementById("status").innerHTML = '<div class="alert alert-success alert-dismissible fade show" role="alert" style="float: right; background-color: #f15050; border-color: #f15050;"><span class=""><b id="status" style="font-size: 17px;">Error - Unauthorized</b></span><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true" style="margin-top: 2px; font-size: 30px;">&times;</span></button></div>';``` imma try this
solemn leaf
#
<script type="text/javascript" src="public/script.js" charset="utf-8" defer></script>
drifting wedge
#

<script src="https://domain.com/static/controlpanelFunctions.js"></script>

#

this is my current

#

what should i do to it?

solemn leaf
#

I need help with mine

#

also you need to declare the type

drifting wedge
#

it doesnt need to declare type

solemn leaf
#

fr?

mellow kelp
#

yeah

#

not even the charset

solemn leaf
#
-The resource from “http://localhost:3000/public/script.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
#

did I do this wrong?
app.use(express.static('public'))

mellow kelp
#

what you did serves the files on the index route

#

so the script's route should just be /script.js

solemn leaf
#
<script src="./public/script.js" defer></script>
#

got it

#

thats weird

sacred trout
#
# kick
    @commands.command()
    @commands.has_permissions(kick_members=True)
    async def kick(ctx, self, member: discord.Member, *, reason=None):
        try:
            embed = discord.Embed(title=f"User Kicked!",
                                  colour=discord.Colour.green())
            embed.set_thumbnail(url=str(member.avatar_url))
            embed.add_field(name="**user Kicked**",
                            value=f"**{member}**", inline=False)
            embed.add_field(name="**Kicked by**",
                            value=f"**{ctx.author}**", inline=False)
            embed.add_field(name="**Reason:**",
                            value=f"**{reason}**", inline=False)
            await ctx.send(embed=embed)
            await member.send(embed=embed)
        except:
            pass
        await member.kick(reason=reason)```
#

please hlp

#

help

#

anyone

crystal wigeon
#

hey guysss

#

umm

#

the web socket ping is too high TwT 200

#

my server is in asia

#

and ig discord is US?

slender thistle
#

I don't see anything wrong with that

#

Apart from the function possibly missing self if it's a method of a class

earnest phoenix