#development

1 messages ยท Page 941 of 1

grizzled raven
#

not like im gonna sleep anyway

quartz kindle
#

sleep is sacred

#

im out

#

gn

neat ingot
#

yay my images are loading again โค๏ธ

#

gn tim ๐Ÿ˜—

grizzled raven
#

wait

#

wait

#

if you disable presence intent, you wont recieve guild members on guild joins, right?

neat ingot
#

isnt presence only for user activity? like, their current game and status? why would that be relating to guilds at all? seems silly imo ๐Ÿ˜›

#

could be tho idk

grizzled raven
#

yeah you'd think that

#

but not subbing to presence intent actually affects quite alot of things

neat ingot
#

:/

vivid crescent
#

Presence basically gives you all user info updates

#

Your member cache is usually outdated without presence, since the bot won't recieve information about users changing their name

#

Also TheNoob27, the guild_members intent is tied to those events

#

So those events should be called if you have the guild members intent

neat ingot
#

wait, so if i dont enable those presences, and i - for example - try to show an embed with a member.username it could* display the old incorrect name?

vivid crescent
#

Potentially, unless you make a call to discord to retrieve the users info

neat ingot
#

lmao wth

vivid crescent
#

Presence gives you all info on user state changes, which includes user info changes ยฏ\_(ใƒ„)_/ยฏ

#

It always has the most up-to-date data

neat ingot
#

usernames tho ๐Ÿ˜

#

like, every bot i would imagine uses a username somehow

#

for discord to add an intent that will make usernames not be accurate is a joke imo

#

like, thats the one thing that has to be up to date imo

vivid crescent
#

Just retrieve the new user info

neat ingot
#

anything else, sure, fetch the data, but a username should be updated with every ping or w.e

#

perhaps not every ping

#

but yea.

vivid crescent
#

I mean, if you are using the member who sent the message then yeah their data will be up to date

#

Since the message contains the member instance

#

I meant if you are grabbing a random user from the member cache, there's no guarantee their info is up to date

neat ingot
#

yea thats what i mean. i dont mean like, some other members username, but the member who is using the bots commands

#

ahh yea, mkk thats fair then lol

vivid crescent
#

Oh, the member using the command should be up-to-date

neat ingot
#

i had a panik mode there for a minute cause i recently decided to remove anything that required intents lol

plain current
#

@vivid crescent can i send you some code because i am getting an error saying ReferenceError: bot is not defined

vivid crescent
#

Send the full error + code here

earnest phoenix
#

send it here

#

dont dm

neat ingot
#

^

earnest phoenix
#

thats what this channel is for anyways

plain current
#

yeah ig

neat ingot
#

its also better to not request assistance from a specific person as it may limit the people who reply to you. imo

plain current
#

facts

#

const Discord = require("discord.js");
const Bot = new Discord.Client();

const token = 'Hidden';

bot.on('ready', () =>{
console.log('This Bot is Active');
})

bot.on('Message', msg=>{
if (msg.content === "HELLO" ){
msg.reply("HELLO FRIEND!!!");
}
})

bot.login(token);

neat ingot
#

lower case 'b'

#

should be 'B'

#

ez

#

๐Ÿ˜›

vivid crescent
#

Bot not bot ^^

earnest phoenix
#

^

#

caps can change what it defines too

plain current
#

man im dumb thanks for the help

neat ingot
#

np ๐Ÿ™‚

vivid crescent
#

Np lol

neat ingot
#

programming is always case sensitive, its always best to make sure your using correct spellings and case ๐Ÿ˜„

earnest phoenix
#

which is why you will sometimes see stuff like

let Client = Discord.Client;
let client = new Client();
plain current
#

im just trying to start Creating bots for fun

#

ah

vivid crescent
#

Do events need to be lowercase as well? Will that message event work?

neat ingot
#

oh idk

#

maybe

earnest phoenix
#

i think javascript is case sensitive all the time so ig

vivid crescent
#

I don't use djs ยฏ\_(ใƒ„)_/ยฏ

neat ingot
earnest phoenix
#

same i switched to eris

neat ingot
#

seems they have whats it? camel case? for some events

#

camel case with a lower case intiial letter?

vivid crescent
#

lowercamelcase

neat ingot
#

idk what thats called lol

vivid crescent
#

Called lower camel case ๐Ÿ˜›

neat ingot
#

fair enough ๐Ÿ˜„

plain current
#

damn thats all it need

earnest phoenix
#

?

plain current
#

im am dumb thanks for the help also

vivid crescent
#

It's ok, we all start somewhere

earnest phoenix
#

no ur not dumb, ur just starting

neat ingot
#

^

plain current
#

how do you do like an auto role for new joiners

#

Thanks

vivid crescent
#

Listen for member join

#

And add a role

neat ingot
#

i've been coding idk, like 8-9 years? and still do dumb shit every day.

sick cloud
vivid crescent
#

Got an empty selector?

earnest phoenix
#

what does vue do anyways

#

im planning to learn it some day

neat ingot
#

idk any vue or sass ๐Ÿ˜„

glacial thicket
#

in discord.py i have a command that i want to reply to your message when you do b!info but i keep getting error messages. can someone help with how to get it to send these messages in response to the command?

neat ingot
#

can barely get by with regular css ๐Ÿ˜

vivid crescent
#

Devin they should be in 1 message

#

Separate them with a \n char

sick cloud
#

nope i got it nvm

#

@earnest phoenix renders pages on the front end not the back end

#

so page changes are instant for eg

earnest phoenix
#

thx

glacial thicket
#

oh thanks, im a bit confused by the usage, could you give an example please?@vivid crescent

sick cloud
#

which of these should i do for something like loading a list of blog posts

    Fetching After Navigation: perform the navigation first, and fetch data in the incoming component's lifecycle hook. Display a loading state while data is being fetched.

    Fetching Before Navigation: Fetch data before navigation in the route enter guard, and perform the navigation after data has been fetched.```
earnest phoenix
#

why are you making a bot send so many messages for one command devin? wont that be api abuse?

neat ingot
#

bot.send("line1\nline2")

vivid crescent
#

Yeah

sick cloud
#

should i show the page and then display the posts , or only show the page when done

vivid crescent
#

Like that

glacial thicket
#

okay thanks, sorry im new to coding, i have commands that work but they all rely on message.content.startswith and im trying to change them all to actual commands

vivid crescent
#

Quantum you can show the page with a loading icon ยฏ\_(ใƒ„)_/ยฏ

neat ingot
#

^

#

page load faster, data load after, show loading icon in meantime.

#

whenever i show posts i have a modal window appear with a loading icon in it and then that window displays the data.

#

^discuss also does the same

#

disqus*

glacial thicket
earnest phoenix
#

you're missing the n for the line break presumably

glacial thicket
#

oh okay thanks

#

rip still getting the error

earnest phoenix
#

show the new code

#

theres another one btw

glacial thicket
earnest phoenix
#

yeah dont use ' inbetween these i think

#

a line break should be a part of the actual string

vivid crescent
#

Need to join your strings

glacial thicket
#

my ping command doesnt even work, is it the bot.send('pong') that is wrong??
sorry for asking so many questions, i just dont know why it isnt working

neat ingot
#

also, is that a . at the end of your line in between ' and ) ?

glacial thicket
#

yeah it was, i fixed it and the error still showed up

slender thistle
#

What's your d.py version

glacial thicket
#

im not sure but i might need to update. ill do that now

slender thistle
#

Remember to await it

#

Also use ctx.send

plain current
#

so i got my code to work but it for some reason will not work When i try to use the command i set

glacial thicket
vivid crescent
#
@bot.command() 
async def test(ctx, *, arg): 
    await ctx.send(arg)
sudden geyser
#

is it not self-explanatory?

vivid crescent
#

You need await

plain current
#

hm thats not what the tutorial showed at all lol

glacial thicket
#

jesus christ im an idiot, thank you

vivid crescent
#

Role mentions in embeds don't trigger the mention right?

earnest phoenix
#

yeah

#

same for user mentions

vivid crescent
#

Cheers

#

Neat website for intent event info ^

earnest phoenix
#

unless the mention is on the actual message above the embed, then that user/role will get mentioned

vivid crescent
#

So in the fields its fine

earnest phoenix
#

yeah

astral yoke
#

anyone know

#

why this dosent work

#
const { RichEmbed } = require("discord.js");
var servers = {};
const ytdl = require("ytdl-core");
module.exports = {
  config: {
    name: "play",
    description: "play a song",
    aliases: ["p", "pplay"]
  },
  run: async (bot, message, args) => {
    message.channel.send("this is the start of the command")
    let premium = bot.db.get(`premium_${message.guild.id}`)
    if(!premium) message.reply("sorry! This server doesn't own premium! Buy it today!")
    if(premium) {
    function play(connection, message) {
      var server = servers[message.guild.id];
      server.dispatcher = connection.playStream(
        ytdl(server.queue[0], { filter: "audioonly" })
      );
      server.queue.shift();
      server.dispatcher.on("end", function() {
        if (server.queue[0]) {
          play(connection, message);
        } else {
          connection.disconnect();
        }
      });
    if (!args[0]) return message.reply("sorry. I need a link!")
  
    if (!message.member.voiceChannel) return message.reply("join a voice channel!")
    if (!servers[message.guild.id])
      servers[message.guild.id] = {
        queue: []
      };
    var server = servers[message.guild.id];
    server.queue.push(args[0]);
    if (!message.guild.voiceConnection)
      message.member.voiceChannel.join().then(function(connection) {
        play(connection, message);
        let embed = new RichEmbed()
        .setColor('RED')
        .setDescription(`๐ŸŽถ Now playing ${args[0]}.`)
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setThumbnail(bot.user.displayAvatarURL)
        message.channel.send(embed)
      });
    }
  }
    message.channel.send("this is the end")
  }
} 
#

it shows the "start of the command" and "end"

#

but nothing else

earnest phoenix
#

I can work it out to prevent bots from getting xp??

#

just check if the user is a bot or not

#

@astral yoke ill go through it in a sec

#

how can i do that?

astral yoke
#

if (message.author.bot) return;

earnest phoenix
#

Thanks ๐Ÿ˜—

#

@astral yoke can you insert some debug lines?

astral yoke
#

where?

earnest phoenix
#

if possible in every condition check

uneven monolith
#

Im wondering if there is a way to run code from a command you type in discord... Is it possible?

strong tundra
#

yeah

#

a bunch of bots have repl commands

#

if you use js or python iirc it's not hard to add one

uneven monolith
#

Ok, I have no idea where to start to make that command. I would love help!

#

Sorry if it sounds a little rude, i was trying to think of a way to say it without making it sound like that, im using discord.js

earnest phoenix
#

use eval for js

#

though make it owner only

strong tundra
#

yeah

#

i haven't done any of this stuff in a while as my bot i'm currently working on is made with a compiled lang

#

๐Ÿ˜”

earnest phoenix
#

evals are for noobs, hardcoding it and recompiling is for pros GWgoaMonikaSmug

amber fractal
#

I made a command to make a command because I'm lazy

earnest phoenix
#

i made a command that autoclones from github, and start the bot with the new code

strong tundra
#

i could just start up a docker container containing the eval bot and then close it when it's done

earnest phoenix
#
const applyText = (canvas, text) => {
    const ctx = canvas.getContext('2d');

    // Declare a base size of the font
    let fontSize = 70;

    do {
        // Assign the font to the context and decrement it so it can be measured again
        ctx.font = `${fontSize -= 10}px sans-serif`;
        // Compare pixel width of the text to the canvas minus the approximate avatar size
    } while (ctx.measureText(text).width > canvas.width - 300);

    // Return the result to use in the actual canvas
    return ctx.font;
};

client.on('guildMemberAdd', async member => {
    const channel = member.guild.channels.find(channel => channel.name === 'welcome');
    if (!channel) return;

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

    const background = await Canvas.loadImage('./wallpaper.jpg');
    ctx.drawImage(background, 0, 0, canvas.width, canvas.height);


    ctx.strokeStyle = '#74037b';
    ctx.strokeRect(0, 0, canvas.width, canvas.height);

    // Slightly smaller text placed above the member's display name
    ctx.font = '28px sans-serif';
    ctx.fillStyle = '#ffffff';
    ctx.fillText('Welcome to the server,', canvas.width / 2.5, canvas.height / 3.5);

    // Add an exclamation point here and below
    ctx.font = applyText(canvas, `${member.displayName}!`);
    ctx.fillStyle = '#ffffff';
    ctx.fillText(`${member.displayName}!`, canvas.width / 2.5, canvas.height / 1.8);

    ctx.beginPath();
    ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
    ctx.closePath();
    ctx.clip();

    const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
    ctx.drawImage(avatar, 25, 25, 200, 200);

    const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png');

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

Hey everyone! this is my code and the error is member.user.displayAvatarURL is not a function

#

๐Ÿ™‚ Thanks in advance

uneven monolith
#

welcome message?

grizzled raven
#

that cant be the error

earnest phoenix
#

yep welcome message

stiff hound
#

hello

earnest phoenix
#

Can anyone help?

#

theres no such thing as display avatar url

#

oh thx hope!

grizzled raven
#

it is

#

what version of discord,js

small prairie
#

message.member.setNickname("") would reset the nickname right?

earnest phoenix
#

yeah

small prairie
#

thanks

copper cradle
#

imagine using a do {} while statement lmao

#

that's so c++

earnest phoenix
#

theres no such thing as display avatar url
@earnest phoenix What can i put so that i get the person's avatar?

#

literally what i've sent

#

or whats the error now?

spice pasture
#

can anyone help me figure out why this is just now happening

#

this just started happening with everything i code

earnest phoenix
pale vessel
#

he's running python for a js file

#

what

earnest phoenix
#

OH LOL YOU'RE RIGHT GWjiangoOmegaLUL

#

i'm not

#

i'm running canvas

#

lol

pale vessel
#

you are lmao

earnest phoenix
#

we didnt mean you valckyz

#

oh

#

my bad

pale vessel
#

bruh

earnest phoenix
#

omg i am so sorry

pale vessel
#

big brain

earnest phoenix
#

@spice pasture you having quite the big developer stroke right there

spice pasture
#

WAIT WHAT

#

AHAHAHAA

#

ok

#

im not insane

#

ok

#

i swear

#

my ise

#

ide

#

just

#

i must have accidentally switched it to python

earnest phoenix
spice pasture
#

oh my god

#

i spent

#

you dont know how long

#

trying to fix that

earnest phoenix
#

I have these retarded moments too

#

multiple times a day

#

until i just give up

spice pasture
#

hmm no

#

its still crashing when i run it with the debugger

#

wait

#

im just dumb

#

python debuggeer

#

.>

earnest phoenix
#

make sure the debugger is js, not python GWowoHehe GWgoaMonikaSmug

spice pasture
#

ohmygod

#

im gonna cry

#

i spent too much time on this

earnest phoenix
#

welcome to the frustrating world of development

spice pasture
#

yeah ive been developing for two years

#

wait three now

#

my last "wtf" moment was

#

plotly crashes pm2

copper cradle
#

I mean

#

if you read the error

#

it's a python error

#

and the way the traceback looks

#

you know it's python when you see it

spice pasture
#

look

#

its late

#

ok

copper cradle
#

it's 11:14

spice pasture
#

ok cool im not insane

earnest phoenix
#

get some sleep before you ask yourself why your bot is not running, try to debug it for 5 hours and realize you didnt even start it

copper cradle
#

I'm insane tho

spice pasture
#

the (javascript) debugger is crashing on perfectly fine code still

copper cradle
#

lol

earnest phoenix
#

i speak from experience weirdsip

spice pasture
#

ok the debugger was not crashing

#

the program was exiting normally because 50507 =\= 5057

earnest phoenix
#

I saw that ping angeryBOYE

stray wasp
#

yeah lul I was behind

earnest phoenix
#

you gotta be faster

stray wasp
#

I thought the messge he sent was like posted now lmao

#

but nope it was like idk ages ago

wheat valve
#

How do you find how many bots are in a server? i use discord.js

neat ingot
#

iterate over the members of that server, and check if the user is a bot.

spice pasture
#

Ok so the debugger is still closing but turns out that's because minecraft is rate limiting me

#

Annoying

earnest phoenix
#

make sure its not python again

neat ingot
#

what are you doing with minecraft?

#

checking some api or something?

earnest phoenix
#

Suddenly realizes he accidentally started coding a minecraft plugin instead of his bot

neat ingot
#

lmao

#

so i got that error when my bot went to a new server and i tried to interact with it, because it didnt have permissions, obviously.

#

however, i check if i have relevant permissions before sending anything

#

what permissions other than 'SEND_MESSAGES' would a bot require in order to send a message?

#

maybe embeds?

earnest phoenix
#

send_messages has send embeds

#

afaik

#

though you could try it out

neat ingot
#

yea im going through each permission atm to see which one it is that is needed

tall arrow
#

is there any way I can get the permission integer of a role?

neat ingot
#

'embed links' permission seems to fix it

#

thats my embed, which doesnt actually link anything

#

so it must require that perm just to add an embed

tight plinth
#

Yes

#

Bot Embeds are actually personalized links embeds

fluid basin
#

@tall arrow depends on what library

tall arrow
#

discord.js

tight plinth
#

You can have role permissions by doing <role>.permissions

#

Pretty sure you can find what you want

tall arrow
#

le me try

neat ingot
#

so ill have to update almost all my commands to check for that permission also lol

#

thats dumb

tight plinth
#

No

fluid basin
#

d.js v12 @tall arrow?

tall arrow
#

ye

tight plinth
#

Just check for it in your message event

#

Before executing a command

neat ingot
#

yes, thats what i do, but each command has an array containing the permissions it requires to be used.

tight plinth
#

I personally do that in the command itself

neat ingot
#

so ill need to update that array with this perm, so that the message event will correctly check for it

#

easy enough change tbh ๐Ÿ˜›

#

just tedious

fluid basin
tall arrow
#

thanks,that was usefull

wheat valve
#

How do you find how many bots are in a server using discord.js?

fluid basin
#

check the docs and try to get what you think should be the correct code

#

can't be expecting people to spoonfeed

earnest phoenix
#

@wheat valve someone told you already

fluid basin
#

and ask here for help with your current code

earnest phoenix
#

iterate over the members of that server, and check if the user is a bot.

wheat valve
#

Me and him had a conversation in DMs and it didn't work

earnest phoenix
#

that can still work

#

just loop through the users and check if these users are bots

fluid basin
#

show what you current have so far

pale vessel
#
fluid basin
#

the general concept is that you should have a loop to iterate through the users of a guild and get those that are a bot

wheat valve
#

The code I have, if you look in #265156322012561408 in shows "0" has the bot count

    let args = message.content.substring(PREFIX.length).split(" ");

    switch (args[0]) {
        case 'serverinfo':
            if (message.author.bot) return; // do nothing

            if (!message.content.startsWith('RH-')) return;

            const bot = message.guild.members.cache.filter((u) => u && u.bot);

            const serverinfo = new Discord.MessageEmbed()
                .setColor("#0099ff")
                .setTitle('Server Information')
                .setThumbnail(message.guild.iconURL())
                .addField('Server Name:', message.guild.name, true)
                .addField('Server ID:', message.guild.id, true)
                .addField('Server Owner', message.guild.owner, true)
                .addField('Role Count:', message.guild.roles.cache.size, true)
                .addField('Member Count:', message.guild.memberCount, true)
                .addField('Bot Count:', bot.size, true)
                .setFooter(message.guild.name)


            message.channel.send(serverinfo)
            break;
    }
})```
pale vessel
#

u.user.bot

#

bot is a user property

wheat valve
#

Thanks!

earnest phoenix
pale vessel
#

ClientUser ah, yes

earnest phoenix
#

i just look at the docs okay angeryBOYE

neat ingot
#

tbh that was my bad for totally blanking that bot was a user prop and not a member one ๐Ÿ˜„

digital ibex
#

hi

#

if i have {+role:role} how can i search for that? i done js const array = ['h', 'e', '{+role:role}']; array.find((e) => 'e' === e) so, what can i do to get {+role:role} from that? i can't look for the exact match cuz idk what the role they want 2 add is.

neat ingot
earnest phoenix
#
        if (args[0] == "true") {
            if (log[message.guild.id].logs == "true") return message.channel.send("You already enabled logs");
            log[message.guild.id] = {
                logs: args[0]
            }
            writeFile("./logs.json", JSON.stringify(log), (e) => {
                if (e) console.log(e);
            });
            let embed = new RichEmbed()
                .setColor("RANDOM")
                .setTitle("Enabled logs")
                .setAuthor(message.author.username)
                .addField("**Date:**", message.createdAt.toLocaleString())
            message.channel.send("Enabled logs");
            let sChannel = message.guild.channels.find(c => c.name === "logs")
            if (!sChannel) {
                embed.setDesctiption("Generated Logs channel");
            }
            if (sChannel) {
                sChannel.send(embed);
            }
        }

and the stringfy making the json file error

{"701141875628834906":{"logs":"true"}}}

3 } at the End of the Json file

#

idk why

digital ibex
#

w/o the u adding data to the json

earnest phoenix
#

??

#

w/o = ??

digital ibex
#

what does ur json look like

#

without

earnest phoenix
#

it was

{"701141875628834906":{"logs":"fasle"}}
digital ibex
#

no i mean

#

when u created ur json file

#

what did it look like

#

u just done js { } or something?

earnest phoenix
#

yes

#

it was {}

nocturne grove
#

Why are you using JSON as a database? I did that too but MySQL or something like that is way easier and better

earnest phoenix
#

no

#

local

pale vessel
#

json is actually easier but it's unreliable and slow

nocturne grove
#

well for me mysql is easier. You can easily get a time difference or something, and you don't have to loop through it to find elements

earnest phoenix
#

dude

nocturne grove
#

yes the syntax is maybe easier

#

?

earnest phoenix
#

pls anyone help me

#

wait

#

sorry

nocturne grove
#

I just asked a simple question but okay, won't help you then ๐Ÿ˜‚

earnest phoenix
#

LMAO

#

T_T

#

r.i.p me

nocturne grove
#

okay does the console give an error?

earnest phoenix
#

nah

nocturne grove
#

or is it an error according to you?

neat ingot
#

your json file should not be an object containing objects which is what it seems like you have done.
i mean, if your empty file contains {} and your reading from that file, and then adding to that data, and then saving it with stringify, it should be fine

nocturne grove
#

I think the third } is because the json file ends there

earnest phoenix
#

the file was {} and i use code to chnage the file

neat ingot
#

but if your like, trying to save something like {{"thing":{'a':2}}} then that probly wont work

earnest phoenix
#

wut

neat ingot
#

{{"701141875628834906":{"logs":"fasle"}}}

earnest phoenix
#

come i will screenshare

neat ingot
#

is what it looks like your trying to save

earnest phoenix
#

the file was so :
{{"701141875628834906":{"logs":"fasle"}}
after /logs true commands
{{"701141875628834906":{"logs":"true"}}}

neat ingot
#

thats what i mean though

#

you have an object within an object

#

{{"701141875628834906":{"logs":"fasle"}}

earnest phoenix
#

so how i can fix it

pale vessel
#

remove {}

earnest phoenix
#

wut

pale vessel
#

just let the file be empty

earnest phoenix
#

so it will give error

neat ingot
#

create an empty file with json format

#

open that file, add your data, save.

pale vessel
#

wait, never mind

#

lol

earnest phoenix
#

but i want it automaticly

pale vessel
#

let the file be {}

earnest phoenix
#

-____-

#

yes

pale vessel
#

make it js log[message.guild.id] = args[0];

earnest phoenix
#

but after some command it will give error

#

no

#

i need filter

pale vessel
#

so the structure will be js { "id": true }

#

oh

#

why

neat ingot
#

tbh you should be using a proper database for guild configurable options as when saving a file, if your bot dies,. your file is rekt

#

and if that file has the config for all of your guilds, thats catastrophic

earnest phoenix
#

-______-

quartz kindle
#

backups :^)

pale vessel
#

he just gave you a good advice

#

don't -__-

#

smh

quartz kindle
#

also, good practice for json files is to save to temp file then rename file

#

instead of saving directly to file

earnest phoenix
#

just because you can doesn't mean you should, proper databases exist for a reason. there's also a reason why none of the successful bots use json files as their storage

#

ok

#

but i cant use database

pale vessel
#

sounds like a you problem

quartz kindle
#

i got to 2500 guild running on json lmao

#

but yeah, dont do that pls

#

i deeply regret it

earnest phoenix
#

it's probably slow though

quartz kindle
#

it wasnt slow at all actually

earnest phoenix
#

oh

quartz kindle
#

because it was done properly

earnest phoenix
#

memory caching ig

quartz kindle
#

ye

earnest phoenix
#

so there is no way to fix my error

#

i have to use database

#

?

quartz kindle
#

from your code it looks fine, i dont get what could be causing it

pale vessel
#

you can fix it but you'll ended up having to switch to an actual database later so why not now

earnest phoenix
#

yes but the json file

#

3 }}}

neat ingot
#

man, when i was first researching discord bot examples, everyone seemed to use some json storage module thing that i cannot find at all now lol

earnest phoenix
#

we can't fix it if the root if the issue is the thing that you're actually using

#

@neat ingot probably configs, not dbs?

neat ingot
#

nah it was used for a level /rank system

#

lol

earnest phoenix
#

oh

#

yuck

neat ingot
#

ikr

#

but it could be helpful if dude is really determined not to database

#

although, databasing is ez af

earnest phoenix
#

@neat ingot dude i cant host mysql on heroku

#

can i use mongoDB on heroku ??

pale vessel
#

then use other host

neat ingot
#

yes you can, and mongodb

#

but they are 'premium' extras

quartz kindle
#

everyone used to use enmap no?

neat ingot
#

enmap yes!

quartz kindle
#

now everyone uses quick.db

neat ingot
#

omg, ty tim

pale vessel
#

postgres is available on heroku too

earnest phoenix
#

dude i am poor, i using free

#

FREE

#

xD

neat ingot
earnest phoenix
#

enmap ??

#

wut is that

shell totem
#

Better-sqlite

neat ingot
#

two trash means of storing data.

#

but they are much easier than setting up an actual worthwhile database

quartz kindle
neat ingot
#

lol

#

rip enmap

earnest phoenix
#

lol

neat ingot
#

tbh no one should be using that for data intensive things anyway

earnest phoenix
#

How to make top gg show the number of servers in discord.js

quartz kindle
#

use the api

neat ingot
#

send the data from your bot to top gg servers via dbl api (js) or equivalent

quartz kindle
#

my bot is exactly rank 400 in top.gg lmao

#

such an oddly exact number

neat ingot
#

๐Ÿ˜ฎ

#

how do you find your bot rank?

earnest phoenix
#

I have the api key

#

What now

quartz kindle
#

https://dbl.marcorennmaus.de/ranking/servers

#

rank by servers i mean, you can rank by votes as well

fickle arch
#

in profane filter github saying to module.exports = require("./words.json") {at the index.js} but seemsly it doesn't work after doing all of the instruction.

neat ingot
#

oh i aint gonna be anywhere near the top 1k lol

earnest phoenix
#

I have the api key

#

Where do I put it

quartz kindle
#

@earnest phoenix check the official libraries section

earnest phoenix
#

okay

neat ingot
#

11 votes this month ~ thats rough! need to vote lock your commands tim ๐Ÿ˜›

quartz kindle
#

nah fork that

neat ingot
#

nah, commit and push!

#

๐Ÿ˜„

quartz kindle
#

lmao

neat ingot
#

im vote locking some commands for my new minigamebot

#

like, it costs credits to play, credits from voting, easy enough.

earnest phoenix
#

I can't find the official libraries section

neat ingot
#

got a decent list of dumb games already ๐Ÿ˜„

#

all of them technically vote locked from the credits thing.

quartz kindle
earnest phoenix
#

Anyone can tell me, wut the heck is shard

quartz kindle
#

technically, a discord connection

earnest phoenix
#

ok . . . . (i dont understand)

quartz kindle
#

often used to refer to a bot process in a large multi-process bot

earnest phoenix
#

oh

quartz kindle
#

when you reach 2500 servers, discord forces you to start sharding

#

which is splitting your bot's connection into multiple connections

earnest phoenix
#

oh

neat ingot
#

i thought it was at 2k?

earnest phoenix
#

oh

quartz kindle
#

each connection handling a part of the total servers

neat ingot
#

isnt it cause of websocket limitations?

earnest phoenix
#

so i cant use it on my bot

#

cuz my bot doesnt have 2,5k

pale vessel
#

you don't need it

quartz kindle
#

you can shard at any point

neat ingot
#

you can use it, but there is no need until you have many guilds

earnest phoenix
#

but i dont need it

quartz kindle
#

but you only need it at 2500

earnest phoenix
#

ok

quartz kindle
#

discord recommends sharding at 1500

#

at 2500 is mandatory

robust moth
#
 module.exports = (error, description) => {
     switch (error) {ย ย 
         caseย  "CoolDown":
         let cooldown = `Please Wait \`${description}\` More Second(s) Before You Use This Command`
         return cooldown;
             ย ย ย ย break;
     }
 
 }
earnest phoenix
#

wut is the problem

pale vessel
#

isn't it error

#

the event name

earnest phoenix
#

so ?

#

nvm

robust moth
#

I need string

pale vessel
#

isn't it error

quartz kindle
#

box-shadow in your css

pale vessel
#

make sure to use !important

sullen salmon
#

Ok wtf kind of permissions do you need to create an overwrite for a channel?

#

In discord.js

pale vessel
#

MANAGE_CHANNELS

vivid ravine
#

How can i install quick.db?

#

Its not going

sullen salmon
#

It doesn't work @pale vessel

vivid ravine
#

I tried it multiple times

pale vessel
#

okay

sullen salmon
#

The bot has manage_channels yet it gives me a missing permissions for every channel I try to change perms in

pale vessel
#

oh

#

idk man

vivid ravine
#

Is this for discord.js?

#

Or for python

#

kk

#

I ll take ss and try later

#

But thanks man

sullen salmon
#

It does

robust moth
#

@pale vessel

        caseย  "CoolDown":
        let cooldown = `Please Wait \`${description}\` More Second(s) Before You Use This Command`
        return cooldown;
            ย ย ย ย break;
    }```
How can I get this output in event
pale vessel
#

did you try to change client.emit('errors') to error

robust moth
#

No

mystic ice
#

how to delete messages by userid

sullen salmon
#

It has MANAGE_CHANNELS but still gives the error vor every channel, when I give it admin perms it works though

mystic ice
#

djs

pale vessel
#

you can get messages and filter the author and delete them

mystic ice
#

how to get messages, i tried a few examples but none worked lol

pale vessel
#

read docs

mystic ice
#

then another question

#

how to define textchannel

earnest phoenix
#

where i can find mongoDB docs

#

imma learn MongoDb

mystic ice
#

search mongodb @earnest phoenix

earnest phoenix
#

cuz there is a lots of mongo

sullen salmon
#

On the role but I've tried with .filter(channel => channel.permissionsFor(message.guild.me).has("MANAGE_CHANNELS")) and that didn't work either @low orbit

mystic ice
#

i have mongo uwu

neat ingot
#

use mongoose. its a node js module for managing mongodb

sullen salmon
#

Yhea

earnest phoenix
#

@neat ingot wait the nodejs will auto host a localhost server, when i use mongoDb ??

neat ingot
#

no?

earnest phoenix
#

wait

#

wait what

neat ingot
#

although it could

earnest phoenix
#

wait imma watch youtube tutorial

#

xD

neat ingot
#

watch more than 1!

#

watch like, 5-10

#

that way you wont come asking dumb questions about it later ๐Ÿ˜›

#

that seemed meaner than i intended, sorry ๐Ÿ˜„

earnest phoenix
#

LMAO

neat ingot
#

mongodb+mongoose is also what i use. i swear by it โค๏ธ

sullen salmon
#

Anyone know what's up with my bot having MANAGE_CHANNELS yet not being able to change perms?

earnest phoenix
#

@neat ingot suggest for mongo version

sullen salmon
#

Wait lol

neat ingot
#

wouldnt it need MANAGE_ROLES or something for that? I had an issue earlier where I found out embeds wouldnt send without the 'embed links' permission :/

sullen salmon
#

I was iterating over it with an array but if I iterate over it with in it works

haughty night
sullen salmon
#

That's extremely weird

neat ingot
#

idk even what mongo version i use atm lol

earnest phoenix
#

lol

neat ingot
#

the latest one ๐Ÿ˜„

#

whatever that is

sullen salmon
#

Or wait it doesn't even

haughty night
#

Did you try background: transparent !important; ?

earnest phoenix
#

@low orbit inspect element is your friend

#

@neat ingot mongo is a shell app

#

it has no UI ??

#

rly

neat ingot
#

correct. you would use some other ui, such as 'mongo admin' or one of the countless others.

#

also, yes, mongodb would run a localhost server on your machine on port 27017 or something by default

earnest phoenix
#

r.i.p i hate terminal

#

but nvm

neat ingot
#

but node js would not

#

i dont think ive ever used mongo via command terminal ๐Ÿ˜„

#

been using it for like, 4 years or so

sullen salmon
#

Anyone know of permissions needed to create overwrites that isn't MANAGE_CHANNELS?

pale vessel
#

it's MANAGE_CHANNELS

#

something is wrong

#

ยฏ_(ใƒ„)_/ยฏ

sullen salmon
#

Wow thanks

shell totem
#

Read the discord api documentation

neat ingot
shell totem
#

It's manage roles

neat ingot
#

as i said, pretty sure it was manage roles.

sullen salmon
#

That's so stupid

#

I missed your message damn @neat ingot

#

Thx

#

So stupid that it needs that perm

neat ingot
#

yea lol

#

i think its also stupid that you need embed links perm to send an embedded message without a link ๐Ÿ˜

#

like, regular discord embed object

shell totem
#

Lol

whole knot
#

Hello. Can someone help me out here? In line 421 my bot says: TypeError: 'bool' object is not subscriptable and I do no know where I did somethin wrong...

earnest phoenix
whole knot
#

I was on that site and the code is totally different/faces other things I do not use in my code

earnest phoenix
#

You know what is the permissions to send embed ?

earnest phoenix
#

Ty

mossy vine
#

so my bot has a feature where it fetches information based on text between curly shits, {like this}. for this im using the regex /\{[^}]+}/g to get the text between the curly shits. a small problem with this is that it triggers in codeblocks too, and i have about 0 idea how to fix it

vivid ravine
#

How can i run my bot 24/7 without heroku

pale vessel
#

vps

#

or use your old pc and pay the electricity bills

vivid ravine
#

Is it free

#

Vps

pale vessel
#

no

earnest phoenix
#

buying a vps is worth it

pure lion
#

How much is a VPS?

modern sable
#

depends

#

cheap ones usually start at a few dollars per month

pure lion
#

Ugh

#

Time to find my windows xp tower

modern sable
#

considering it's windows xp it's probably a bad idea

#

XP is out of support for 6 years now so its possible that the required programs dont even run anymore

golden condor
#

Hi I am trying to use shoukaku, and I am not entirely sure how to set the bot to be deaf, and I couldn't find it in the docs, can someone help

zenith terrace
#

Support server

earnest phoenix
#

Did you see the 3 codes to enter on MongoDB to get 500$ ? ๐Ÿค”

knotty steeple
#

no

#

what

earnest phoenix
#

NRABOY200
GETATLAS
WF200

knotty steeple
#

its for mongo atlas specifically

#

useless to most unless u somehow cant host urself

golden condor
#

Support server
@zenith terrace thanks what would I do without you

zenith terrace
#

Lol

earnest phoenix
#

by using css

#

and inspect element

#

we aint spoonfeed here

#

thats what inspect element is useful for

zenith terrace
#

^

golden condor
#

Hi I am trying to use shoukaku, and I am not entirely sure how to set the bot to be deaf, and I couldn't find it in the docs, can someone help me out or link me to the page on the docs (I asked in the support server and they didn't respond)

next remnant
#

so my bot has a feature where it fetches information based on text between curly shits, {like this}. for this im using the regex /\{[^}]+}/g to get the text between the curly shits. a small problem with this is that it triggers in codeblocks too, and i have about 0 idea how to fix it
@mossy vine pretty sure you gotta just get rid of codeblocks before tryna parse curly braces

still merlin
#

how do you host a bot with heorkuu

golden condor
#

Upload it to GitHub and add a procfile

toxic jolt
#

help please

#
const Discord = require("discord.js");
const ms = require("ms");

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

  //!tempmute @user 1s/m/h/d

  let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  if(!tomute) return message.reply(" \`!!mute <@USER> <1sn/1dk/1sa/1g>\`");

  //end of create role
  let mutetime = args[1]
  .replace(`sn`, `s`)
  .replace(`dk`, `m`)
  .replace(`sa`, `h`)
  .replace(`g`, `d`)

  if(!mutetime) return message.reply(`:warning: Time? \`!!mute <@kullanฤฑcฤฑ> <1sn/1dk/1sa/1g>\``)
  await(message.guild.channels.get(`${message.guild.id}`).overwritePermissions(tomute, {
                    SEND_MESSAGES: false,
                   // VIEW_CHANNEL: true
  }))
// await(tomute.addRole(muterole.id));```
earnest phoenix
#

you're trying to get the channel from the message id it seems like

#

correct me if im wrong

toxic jolt
#

hmm

#

yes

#

i how to fix now

#

@earnest phoenix

earnest phoenix
#

@toxic jolt i told you whats wrong, you're trying to get the channel through the Message ID seen by ${message.guild.id}

toxic jolt
#

hmm

earnest phoenix
toxic jolt
#

okay ๐Ÿ˜„

#

omg

#

i like it

earnest phoenix
#

but im pretty sure the {message.guild.id} returned undefined because obviously theres no channel with that "message ID"

toxic jolt
#

i try it and i see it.

#

xd

earnest phoenix
#

whats your discord version?

#

discordjs*

toxic jolt
#

"discord.js": "^11.5.1",

pale vessel
#

you should upgrade

#

also, that's a collection so you have to loop through them

toxic jolt
#

noo :(,

viral spade
#

can someone help me on caching data to the client from a database?

toxic jolt
#

if I upgrade it will give a lot of error.

pale vessel
#

that's okay. you can fix them. if you're on v11 until the next few months, you can't fix the errors without upgrading

viral spade
#

When caching db rows into the client on cache miss, what do i do with other cache misses, while the first one is still loading?

quartz kindle
#

if they depend on each other, fetch them sequentially

#

if they are independent, fetch them concurrently

viral spade
#

lets say i want to cache guild information. So add guild.appData.prefix, ..
The getGuildCache function that impelemnts the cache miss will be called from all kinds of events "at the same time".

#

so its no independent or dependent, its the same information

#

(thank god youre here tim)

quartz kindle
#

ah i see the issue

neat ingot
#

we should all chip in $1 each and order tim a superman costume with a big T logo on it ๐Ÿ™‚

quartz kindle
#

you need a deferred promise

#

lmao, i'd rather get food

neat ingot
#

no no idc how well you eat! i care about fashionable skin tight outfits ^_^

quartz kindle
#

so basically a deferred promise (idk if that's even the name for it) works like this

viral spade
#

i will store the promise in a loadingGuilds map?

#

and place it "onto" the new call somehow?

#

so when the promise resolves it will send the result to all instances?

quartz kindle
#
let promises = {}
getGuildCache();
getGuildCache();

function getGuildCache(id) {
  if(!client.guilds.get(id).AppData) {
    if(promises[id]) { return promises[id]; }
    promises[id] = new Promise(async resolve => {
      data = await db.guilds.fetch(id) // or whatever your database does
      client.guilds.get(id).AppData = data;
      resolve();
    });
    return promises[id];
  }
}
neat ingot
#

thats pretty much the exact logic my mongodb cache system uses

quartz kindle
#

when a concurrent call happens, it checks if there is already a promise waiting, and if it does, return the existing promise instead of creating a new one

viral spade
#

oh man tim thats like a so fine solution to a problem i have been thinking on quite some time now.. i will try, thank you so much

quartz kindle
#

then you can await getGuildCache() once the promise resolves, all concurrent operations will proceed

honest perch
quartz kindle
#

discord.js version?

honest perch
#

going from 11 to 12

#

so 12 is installed

quartz kindle
#

overwritePermissions takes a list of overwrites

#

and replaces all overwrites with it

#

if you want to update a single overwrite, use this

honest perch
#

that only updates the permissions on one channel

quartz kindle
#

yes

#

overwritePermissions also only updates one channel

#

there is no method to update all channels

#

you need to update them one by one

neat ingot
mossy vine
#

@neat ingot is that battleship

neat ingot
#

yup ๐Ÿ™‚

mossy vine
#

noice

quartz kindle
#

haha cool

neat ingot
#

one of my 9 finished discord games ๐Ÿ˜›

honest perch
quartz kindle
#

no

neat ingot
#

annoying though cause my mobile cant display all the emojis for monopoly ๐Ÿ’”

quartz kindle
#

using a forEach for api calls is a bad idea, because that will make your bot send all updates at once

#

and will likely get rate limited by discord

#

you should use a for loop and await each call

#
for(let [id,channel] of message.guild.channels.cache) {
  await channel.updateOverwrite(...)
}
viral spade
#

tim, does the caching code you posted allow null values to be resolved/cached? or will your db always insert on a miss (most importantly for the guildmember cache)?

#

i was thinking about setting up a default object that gets used if it was not found in the database. and then only actually insert when a set happens

quartz kindle
#

if you do resolve(null) the promise will return null to the variable that awaited it

#

if you do resolve() or resolve(undefined) it will return undefined

#

so you can do let data = await getGuild(); if(!data) { insert default data }

viral spade
#

sure, i just mean in general do you assume the getCache call will have xsuccessfully cached all values so these settings can be accessed

quartz kindle
#

you can do the same in your await fetchFromDb thing

#

inside the function

#

if the db fetches, add it to guild, if the fetch returns nothing, add a default to the guild, then resolve the promise

viral spade
#

i know, but i was thinking about not inserting a row that has not changed its default values

#

for example. looking at the guildChannel entity, i have the property noxp (no xp channels).

If i make the insert-on-db-miss for every channel, where a user writes, i have a lot of channels in the db. BUT i could also only insert the channels, where the admin changed the noxp value and if the db calls returns 0 rows, i will simply put a default row at its place for the cache.

quartz kindle
#

for inserting to the db its another story

#

if you're going the write-in-chunks route to reduce db writes, you can save an object of db changes somewhere

#

for example, channel A was changed, store somewhere that channel A was changed, then when the insert to db function gets called, it inserts only the data that was changed, and then reset the was changed state

#

alternatively, once a channel changes, immediately write it do the db

viral spade
#

i am not sure if were talking about the same thing ๐Ÿ˜…
I am talking about not inserting most rows at all. about size of the database.

So 100% of all channels need to have the noxp property cached. like 0.1% are noxp channels.

If i "get-insert" every channel i cache i need to have 100% of channels in my database. If i instead only insert when someone changed the noxp setting (and put a default object on the cache if it was not found) i will only need to have 0.1% of channels saved in my db.

quartz kindle
#

well yes, thats a given

#

you dont even need to give it a default value

#

just omit it, if it doesnt exist it means its not set

viral spade
#

well but i want that the code if(channel.noxp == true) resolve();
to not throw erroes and i also dont want for every property to check all the time if it is set, right?

#

but whatever, i am wasting your time. i need to try this first. thanks!

quartz kindle
#

why not if(channel.noxp)?

viral spade
#

well thats true for booleans, but i also need multiple texts set default

#

dates

quartz kindle
#

ah so noxp can have other values

#

then you can if(channel.noxp !== undefined)

neat ingot
#

@earnest phoenix

1: "Me"
2: "Other"
3: "Last Guy"
#

yw ๐Ÿ˜—

quartz kindle
#

but well, all other values besides 0 would still work

viral spade
#

noxp can have only 1/0.
well guildmember is the most easy example, but on guild for example, i need a mix of strings, dates, ints over like 30 necessary setting properties

#

i mean i could write everywhere f.e.

if(!guild.pointsPerMessage) guild.pointsPerMessage = 3;

But then i would have to write that at multiple locations, for many properties

earnest phoenix
#

Discord bots can not send animated or custom emojis?

nocturne dagger
#

In discord.js how can I have a command is guild a add a role in guild b

neat ingot
#

im just gonna go out on a limb here and say you shouldnt be doing that

nocturne dagger
#

Are you talking to me?

neat ingot
#

yea, sorry lol

nocturne dagger
#

And why shouldn't I do that?

neat ingot
#

1 - security

#

2 - not guaranteed to send

earnest phoenix
#

How?

nocturne dagger
#

I don't think your understanding.

The user does something in one server. i.e sets up our bot. then gets a role in our support server

pale vessel
#

<:name:id>
<a:name:id> for animated

earnest phoenix
#

not animated?

neat ingot
#

there is no guarantee your bot client is in the support server (when sharding is involved)

earnest phoenix
#

message.guild.roles.cache.get(roles => roles.delete); not reacting

neat ingot
#

instead you should setup some kinda webhook event that your support server listens for

earnest phoenix
#

v12

pale vessel
#

delete is a method

earnest phoenix
#

v12 js

pale vessel
#

make it a function

earnest phoenix
#

it

pale vessel
#

also, you need a loop

#

wait a minute

#

that's not even a working code

earnest phoenix
#

well

pale vessel
#

like

#

.get accepts a string

#

which is an id

#

perhaps you meant forEach()?

earnest phoenix
#

message.guild.roles.forEach(roles => roles.delete);

pale vessel
#

don't do that tho

#

delete is a method

#

do you understand this?

earnest phoenix
#

not reacting again xd

pale vessel
#

that's not how it works

neat ingot
#

dude, your not calling the function.

#

your just checking if that function exists and then doing nothing with it

earnest phoenix
#

what function? v12 not working

neat ingot
#

also not sure thats even valid lol

pale vessel
slender thistle
#

The roles.delete part could be really confusing tbh.

pale vessel
#

read that and learn how to use loops

earnest phoenix
#

nothing seems understandable

pale vessel
#

you also shouldn't use forEach because it would lead to api abuse

earnest phoenix
#

to know a little english

pale vessel
#

i feel like you really need to have at least a basic understanding of english in order to understand docs and guides.

proper inlet
#

Hello, when I upgraded to discord.js 12 my economy command /top stop working.
Bot must delete user's reactions from message, but bot must'nt remove himself reactions.
In discord.js 11 I do this if(user.id != client.user.id) { reaction.remove(user.id); } but in discord js 12 this remove bot reactions too.
How can I fix it?

pale vessel
#

that happened to someone else too

neat ingot
#

yw ๐Ÿ˜—

pale vessel
#

i didn't touch reactions when using discord.js so i can't help you, sorry

#

remove brackets mmLol

proper inlet
#

Thx

neat ingot
#

oh, 'this hwnd' in that code reffers to a sent message

#

hwnd is just the message that was sent.

proper inlet
#

Ok

neat ingot
#

i should actually probably change that guild.me.has permission thing cause it doesnt take channel specific perms into account which could cause errors

earnest phoenix
pale vessel
#

i gave you the guide

#

it tells you what to change

#

please read it.

earnest phoenix
#

readable though an understandable guide @pale vessel xd

neat ingot
#

np ๐Ÿ™‚

earnest phoenix
#

how do i check if a member object is a bot in python?

modest maple
#

member.bot

#

returns a bool

earnest phoenix
#

ight cool

modest maple
#

but it will almost 100% always be false

#

as discord.py Automatically ignores bots if its the commands.Bot

earnest phoenix
#

yeah but lil check to ignore bots

rocky veldt
#

i just made a bot

#

but its whack as

#

ass

neat ingot
#

my friend was trying to talk me into making a bot that just randomly repeating things back to you

#

like, it wouldbe quiet for hours, then just copy or repeat a random phrase it had heard throughout the day

naive mantle
#

hey uh

#

im trying to make my bot have a status

#

this isnt working

#

bot.user.setActivity.('prefix ples', { type: 'STREAMING' })

#

i dont know what to set it to-

#

it says

#

TypeError: Cannot read property 'setActivity' of null

#

can someone help?

white anvil
#

wait until you have connected properly

naive mantle
#

wh

#

what

white anvil
#

you are calling this method before you have connected to discord

#

so the bot user doesnt exist yet

naive mantle
#

wait do you have to put it after bot.login?

#

@white anvil it still says null

#

i dont know have to put it after ive connected to discord

white anvil
#

no

hasty sparrow
#

Use the ready event

white anvil
#

logging in takes time

#

you are logging in and you are trying to set activity before it has finished

naive mantle
#

idk how to use the ready event

#

um

#

@hasty sparrow what is the ready event and how do i use it-

hasty sparrow
pale vessel
#

make sure to select v12 on top

naive mantle
#

i already have v12 and i made bots beforwe

#

i never used the ready event before

hasty sparrow
#

You also never set a bot's status before?

naive mantle
#

no

hasty sparrow
#

K

naive mantle
#

oh i did it

#

bot.once('ready', () => {
    bot.user.setActivity('my prefix ples', { type: 'STREAMING' })
});```
golden condor
#

So if you didn't want to restart your bot to change something in an event, how could you do that?

#

Like is there a way of doing it in the same way in commands?

#

I'm just not sure if something like this would work

naive mantle
#

i dont know ive never done this before-

golden condor
#
fs.readdir("./events/", (err, files) => {
  if (err) console.log(err);
  for (const file in files)
    let eventFunc = require(`./events/${file}`);
    let eventName = file.split(".")[0];
    client.events.set(file, {name: eventName, run: eventFunc.run})
  };
});
for (const event in client.events){
client.on(event.name, (...args), event.run(...args))
}
pale vessel
#

make a function that reloads the event

neat ingot
#

^

#

and clears the require cache

naive mantle
#

how do i run that function

neat ingot
golden condor
#

Ok so like commands, I was just wondering, thanks ๐Ÿ‘

naive mantle
#

oml this is all confusing

#

i dont know what to put to make a function that reloads the event-

pale vessel
#

you'll get used to it

#

you don't need to

#

we were talking to cxllm

naive mantle
#

should i?

pale vessel
#

it's okay for now.

naive mantle
#

ok

#

i kinda need it

#

so i can do it faster than restarting my bot

#

because right now it takes forever for it to log off then log back on

neat ingot
#

best to learn some javscript or w.e code language you use first before deciding what you 'need'

plain current
#

hello i am getting some error saying SyntaxError: Unexpected end of input

naive mantle
#

i only know basic javascript

neat ingot
#

then learn some not basic javascript ๐Ÿ˜›

coral stirrup
#

@plain current you have code where it shouldnt be

golden condor
#

Like this?

client.reloadEvent = function (eventName) {
  delete require.cache[require.resolve("./events/" + eventName)]
  client.events.delete(eventName)
  const event = require("./events/" + eventName)
  client.events.set(eventName, { name: eventName, run: event.run })
}```
coral stirrup
#

explanation 100

neat ingot
#

ehhh, i wouldnt do it quite like that cx, but it looks functional enough assuming client.events is a discord collection.

golden condor
#

It is

plain current
#

ok because i used to get an error saying SyntaxError: Unexpected token and now it is this one

naive mantle
#

how do i use that @golden condor

coral stirrup
#

you should learn js first @plain current

golden condor
#
fs.readdir("./events/", (err, files) => {
  if (err) console.log(err);
  for (const file in files) {
    let eventFunc = require(`./events/${file}`);
    client.events.set(file, eventFunc)
    let eventName = file.split(".")[0];
    client.on(eventName, (...args) => eventFunc.run(client, ...args));
  };
});``` Should I do something like this or what I showed before?
naive mantle
#

i wanna try to use one of those

pale vessel
#

that would reload all events

golden condor
#
fs.readdir("./events/", (err, files) => {
  if (err) console.log(err);
  for (const file in files)
    let eventFunc = require(`./events/${file}`);
    let eventName = file.split(".")[0];
    client.events.set(file, {name: eventName, run: eventFunc.run})
  };
});
for (const event in client.events){
client.on(event.name, (...args), event.run(...args))
}```
coral stirrup
#

thats some very basic stuff right here, you should atleast know a little bit what youre doing @plain current

golden condor
#

No I mean before it starts

naive mantle
#

i need to reload all events

#

someone help me do that-

golden condor
#

that would reload all events
@pale vessel Ik that would be on start

naive mantle
#

oh it works like that alone

#

its very fast

pale vessel
#

then don't say this

Should I do something like this or what I showed before?

golden condor
#

but what about reloading, I was wondering about that, would it actually work?

pale vessel
#

try

#

i have no idea lol

golden condor
#

Ok

naive mantle
#

how do i make an event run when someone joins the server

#

wasnt it like

#

guild member add

#

or something

neat ingot
#

personally i would create an event handling class, and give it functions for loading/unloading/removing events entirely. i'd then create a dev command that uses that class to load w.e the events.

coral stirrup
#

yea its guildMemberAdd

naive mantle
#

ok ty

golden condor
#

personally i would create an event handling class, and give it functions for loading/unloading/removing events entirely. i'd then create a dev command that uses that class to load w.e the events.
@neat ingot how lol

coral stirrup
#

he literally told you

neat ingot
#

lol, idk 'how' exactly, it'd depend on how the rest of your codebase is structured, but the underlying logic remains the same.

pale vessel
#

classes

viral spade
coral stirrup
#

member is guild, user is discord

modest maple
#

id is still the same lmao

viral spade
#

but is the id attribute on both objects the same?

#

ok thx

modest maple
#

Ids dont change just cuz one is a member and one is a user object

viral spade
#

well a user could also have a id per guild

coral stirrup
#

no

modest maple
#

i mean no

neat ingot
#

@modest maple does your netdata thing show your docker container names? or just the container id's?

modest maple
#

that would be an awful idea

#

and just cause massive bloat

viral spade
#

it would

#

just checking

neat ingot
#

i cannot get mine to show container names for the life of me lol

coral stirrup
#

yeah that would be extremly stupid

modest maple
#

@neat ingot container name

neat ingot
#

fml ๐Ÿ˜

viral spade
neat ingot
#

did you have to do anything special to get it working?

modest maple
#

nop

neat ingot
#

fmlllllzzzzz

modest maple
#

just stuck it as a dameon and let it run lul

neat ingot
#

๐Ÿ’”

#

there are settings that apparently change things

#

like, it tells netdata where your docker user group processes are running or some shit

viral spade
neat ingot
#

and even though i 100% correctly gave the data and correct settings, it just does not show anything at all lol

#

i mean, obviously i didnt 100% do it correctly or it would have worked

#

but yea, as far as i could tell, i was doing everything correctly lol

modest maple
#

@viral spade Cuz its discord.js lol, its awful

neat ingot
#

perhaps its just a convenience thing

opaque seal
#

My bot is randomly restarting sometimes, might this be because it's in the process of being verified?

modest maple
#

no

opaque seal
#

Strange

modest maple
#

probably your host if its not just a shard disconnecting

opaque seal
#

My bot is in 105 servers and I haven't implemented sharding yet

#

My host should, should, be fine

neat ingot
#

pretty sure discord severs connections after a few hours which would force a bot to reboot/reconnect

opaque seal
#

Weird

neat ingot
#

it could be a random bug in your code thats causing the bot to crash and reboot though

opaque seal
#

But it doesn't log anything

modest maple
#

what host?

opaque seal
#

?

modest maple
#

My host should, should, be fine
Who is your host

opaque seal
#

Vultr

golden condor
#

lol, idk 'how' exactly, it'd depend on how the rest of your codebase is structured, but the underlying logic remains the same.
@neat ingot I did what I said, it did not work, so I'm not sure how I can do it, I tested it

neat ingot
#

dunno what to tell ya dude, you did it wrong ๐Ÿ˜„

golden condor
#

I did this