#development

1 messages ยท Page 1069 of 1

silent berry
#

v12

#

d.js

#

ping me

sudden geyser
#

was the message sent in a guild?

silent berry
#

yes

#

its for my kick cmd

#

above is the enitre kick command

sudden geyser
#

ah I'm dumb

silent berry
#

no your not

sudden geyser
#
  1. The issue may be where you defined member (message.mentions.members.first();). You don't actually check if member is not undefined (which it can be, as the message member could have mentioned no one).

  2. You seem to be checking a lot unnecessarily. You check if the message member has permission to kick members like 3-4 times.

silent berry
#

@sudden geyser old code converted from v11 to v12, and yeah ik the code jumbled

#

@sudden geyser thank you

dire stag
#

Anyone know how to code a template in HTML?

#

Ping me please.

modest maple
#

code what tempalate

woven rose
#

why icant add mee6 to my discord

restive furnace
#

@woven rose this isnt support server of mee6

woven rose
#

Yes @restive furnace

pure lion
#

Code and HTML shouldn't be in the same sentence

#

Unless you're talking about code at the same time

restive willow
#

how do i make embeds like this?

#

i.e. no bold text/headers

digital ibex
#

use the description

pure lion
#

^

digital ibex
#

description: 'whatever'

restive willow
pure lion
#

*cries in not being able to type fast enough to help*

digital ibex
#

oh

#

iirc its embed_description = 'whatever'

restive willow
#

ill check the docs thanks

slender thistle
#

Embed(description='')

#

embed = Embed()
embed.description = ''

low marsh
#

Does somebody know why @cosmic surgejs-opus can't play audio on my windows sever? It's only on my windows server.

ember lodge
#

Can someone help me why that happend?

low marsh
#

I installed VS with C++ Workload

Does somebody know why @cosmic surgejs/opus can't play audio on my windows sever? It's only on my windows server.

ember lodge
earnest phoenix
#

what is the type of this {}

#

for example "" is String

#

10 is Number

#

true is Boolean

#

then {} what is taht

modest maple
#

๐Ÿ‘ In ๐Ÿ‘ what ๐Ÿ‘ context ๐Ÿ‘

earnest phoenix
#

huh

cinder patio
#

It's an object

#

object literal

earnest phoenix
#

Anyone vscode is broken

#

mine is broken

#

git is not running anymore

#

the syntax color is not working too

#

and the suggestions

#

omfg it fixed

obtuse jolt
#

@ember lodge we donโ€™t offer support for other bots

ember lodge
#

@obtuse jolt what do you mean other bots?

#

thats my bot xd

obtuse jolt
#

Well then I guess youโ€™ll have to reread the docs

#

Mine works so itโ€™s something wrong with your site

ember lodge
#

i already did and nothing, that's why i ask here

obtuse jolt
#

How does your login work?

#

Like what does it do once the user logs in

ember lodge
#

just redirects it to the index site

#

then i will work in the rest...

obtuse jolt
#

Is the php valid? Invalid php can cause the site to stop working completely

ember lodge
#

There is the server.js file

obtuse jolt
#

ahh I donโ€™t use nodejs

#

I use php for my site

#

Youโ€™ll have to ask someone else

ember lodge
#

i am doing that but with nodejs using express and discord-passport

abstract crow
#

What does everyone use for a bot dashboard website? Also for that do you make an API for the bot that your website would call to communicate with each other?

ember lodge
#

@abstract crow we use express

tough relic
#

hey is there a way for a bot to search how many time a word was used

#

with python

abstract crow
#

@ember lodge Gotcha. So then do you work with an API to communicate?

ember lodge
#

it's a web server

abstract crow
#

I was planning on using React and Express. Express would have to have an API to communicate with React

#

Right but for the discord bot. Do you have a web API to communicate between the web server and the bot, or do you just feed information via the express pages?

ember lodge
#

Using express

#

with get and post method

abstract crow
#

Gotcha

tulip ledge
#

Does anybody know where I can create gifs without watermarks?

amber fractal
#

making them yourself

lusty quest
#

idk maybe with gimp

earnest phoenix
#

anyone here experienced with expressjs

#
    res.sendFile(__dirname + '/chat.html');
    doSomething();

How can I wait until the chat.html is loaded before using the function doSomething()

unborn haven
#

guys how do i find the Bot's Prefix?

#

?

#

i want to publish my bot to top.gg but i need the bot's prefix

#

and i don't know what dat means!

earnest phoenix
#

How do you call your bot

#

is it -help

unborn haven
#

what do umean

earnest phoenix
#

the - is my prefix for example

unborn haven
#

?

earnest phoenix
#

This isn't a development question.

unborn haven
#

i know

#

but whatever

#

wait u mean the name of the bot

earnest phoenix
#

This isn't a development question.

unborn haven
#

or how i get it to reply

earnest phoenix
#

oh

#

what language

unborn haven
#

english

#

javascript

earnest phoenix
restive furnace
#

or how i get it to reply
@unborn haven yes...

earnest phoenix
#

english
@unborn haven hmm

tough relic
#

Is there a way for a bot to count how many time a specific message has been used with discord.py?

unborn haven
#

no i already finnished all the coding for the bot i just want to publish it to top.gg but i need the bots prefix

lyric flame
#

Y

unborn haven
#

????????????????????

#

i already finnished all the coding for the bot i just want to publish it to top.gg but i need the bots prefix

hot elbow
#

?

unborn haven
#

whats the bots prefix?

lyric flame
#

Excuse me frends

cinder patio
#

You decide what your bot's prefix should be, lol

unborn haven
#

how

hot elbow
#

I

unborn haven
#

wdum

tough relic
#

client = commands.Bot(command_prefix = '*')

unborn haven
#

ok i'll try

cinder patio
#

...

tough relic
#

anyway can someone help me tho? ๐Ÿคจ

hot elbow
tough relic
#

Is there a way for a bot to count how many time a specific message has been used with discord.py?

restive furnace
#

yes

unborn haven
#

ye

tough relic
#

how?

#

i searched everywhere

#

cant find anything

restive furnace
#

declare a variable and then just increment it when command was ran

tough relic
#

but if the bot is down it won't register anymore tho

slender thistle
#

Database

tough relic
#

thank you ๐Ÿ™๐Ÿผ

spark wadi
#

rip i got a message from discord yesterday about the domain change and api thing and then my bot did node ๐Ÿ˜ง ๐Ÿ”ซ

#

and it broke

#

some things

#

do you have to re-install discord.js and all the components for a music bot for example ffmpeg

restive furnace
#

no

tulip ledge
#

Can bots not use animated emojis?

pure lion
#

They can

tulip ledge
#

Why is not working then

pure lion
#

:name:

#

Wait no

#

< a :name: ID >

#

No spaces

tulip ledge
#

I have an emoji called :WoosStaff: I did: <:WoosStaff:ID> and it doesn't work

#

Oh it needs an a?

pure lion
#

Yeah

tulip ledge
#

Oh yeah now it works

clever garnet
#

so im making it so it logs when my bot gets invited to a server itll log in my server and i want to know who invited the bot to a server heres beginning of the event
bot.on('guildCreate', guild => {

#

im using discord.js

#

how could i find who invited the bot

digital ibex
#

guild doesn't have an "inviter" property or anything

#

so you can't

clever garnet
#

ok

winter shard
#

Kill me please โ™ฟ

clever garnet
#

what

winter shard
clever garnet
#

that was the fastest edit ive ever seen

#

also why is ur language russain

#

or whever that it

earnest phoenix
#

Can you guys stop? if you don't need help with development then please move over to a different channel.

clever garnet
#

i did need help

earnest phoenix
#

Yes. I see that.

#

More referring to @winter shard

clever garnet
#

Ok

earnest phoenix
#

Also, to answer your question, I don't think you are able to easily check who invited the bot

clever garnet
#

Okay

winter shard
#

@earnest phoenix I have nothing to do on this server. So so, sorry) I'm going out now

earnest phoenix
#

I know there is a thing in audit logs for it, but I'm not sure if thats documented/implemented in any libs

clever garnet
#

Also your name seems very familiar

earnest phoenix
#

Probably from another server I Co-Own

clever garnet
#

Oh you're from Plexi

earnest phoenix
#

Anyone know a good Urban dictonary API?

#

PIng me

clever garnet
#

?

restive furnace
#

@earnest phoenix urban directory.

earnest phoenix
#

API

#

not the website

restive furnace
#

i dont think there are official api's for that, most of bots just someway manage to get information from the urban dir website (web scrapping) i believe.

earnest phoenix
#

ok

pure lion
#

Hmm

earnest phoenix
#

im going to check npmjs

restive furnace
earnest phoenix
#

So i was testing the TextChannel.startTyping() and

TextChannel.stopTyping()``` but didn't quite understand it, how can i make it start typing and wait until a function is done before stopping to type?
#

just use {force:true}

#

stopTyping does not have Options... It only has a boolean parameter which still didn't work

velvet void
#

Spanish?

earnest phoenix
#

it has

#

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

velvet void
#

Okay

#

I need help

#

With an error when starting the bot

earnest phoenix
#

dont ask to ask

#

@earnest phoenix it doesn't tho, it doesn't say in the docs

velvet void
#

It is not a question

earnest phoenix
#

so?

queen needle
#

couldnt you use a .then?

velvet void
#

I get this error when starting the bot: ReferenceError: command is not defined

#

I'm still a novice at this

sudden geyser
#

It means you tried to use a non-existent variable.

velvet void
#

Okay. Thanks

obtuse jolt
#

How do find how many bots in server

velvet void
#

You must have a bot for that

#

if (command === 'join') {
^

obtuse jolt
#

"You must have a bot for that"

#

I literally have the bot dev role

#

Jesus

#

Chist

#

I found it anyway

velvet void
#

Sorry. I do not speak English

uneven crypt
#

hey, how can i make to show the user roles?

velvet void
#

As well?

marble juniper
#

@uneven crypt for discord.js its something like

member.roles.map(role => //show role info stuff)
uneven crypt
#

ok thx

#

๐Ÿ‘

earnest phoenix
#

Do shards share global variables

#

eg can global.x = 3 in shard 1 be seen via x in shard 2

#

(does each shard reside in a new node process)

slender thistle
#

-needdev @earnest phoenix

gilded plankBOT
#

@earnest phoenix

DBL is not a place to find developers for jobs. You can try and put a request on Fiverr or Freelancer. Please do not post the request again. Doing so may result in punishment.

earnest phoenix
#

o

#

sorry

ancient nova
misty sigil
#

CSS

ancient nova
#

there's no option and making a div or anything like that just doesn't show

#

can you send me an example @misty sigil

misty sigil
#

wdym?

#

just <style> tags

ancient nova
#

let me send you what I did

misty sigil
#

idk much myself

ancient nova
#

style?

#

do I put it with the code?

#

or somewhere else?

honest perch
#

just make a style tag

ancient nova
#

I did but where?

honest perch
#

description

ancient nova
slender thistle
#

In the long description, use style tag and set a rule for .longdescription

ancient nova
#

here?

slender thistle
#

If you want to set your own div a background, give it some class and apply CSS to it

honest perch
#

bruh

slender thistle
#

yeah

earnest phoenix
#

bruh

ancient nova
#

so I do it all in the box right?

#

well let me see then... be right back

snow urchin
quaint hornet
#

how can i make my bot run a function 5 times with a sleep of 30 secounds between the execution?

pure lion
#

A loop

#

@snow urchin sort the first(10) by levels, then exp

snow urchin
#

Will give that a go, thanks

quaint hornet
#

i know a loop is a good

#

but i want a time between the executions

#

and a limited number or runs

low marsh
#

I am using @cosmic surgejs/opus for my audio. Can I force my script to use opusscript for a specific command?

ancient nova
#

okay, I finished with the CSS for my page

#

hope my bot will be approved soon then

pure lion
#

@low marsh no you shouldn't not and you can't either so just don't

earnest phoenix
#

hey my bot is deleted and when i try to add it again its says the bot is already added but the bot is not spam is moderating bot and i cant see the logs so how can i fix it

pure lion
#

:l

idle mountain
#

How can I make certain styling on a bot's page only show in dark mode? I'm guessing there's a certain CSS class for it..?

pure lion
#

Check the source html, there's probably a toggle

#

Right click the button and inspect, check the ID

#

Blah blah blah

south coyote
#

hello

pure lion
#

Hi

south coyote
#

my discord bot is finished ๐Ÿ˜„

pure lion
#

Nice

south coyote
#

๐Ÿ™‚ bot is online!

earnest phoenix
#

ok

#

how can i make it send a message to a voice channel when someone donates on patreon ๐Ÿ˜ฉ

#

use their api

#

okay

chilly sphinx
#

Hello guys, i need a few help.
I'm working on a big french youtube channel, and recently we've opened a google form to allow people to apply to be a moderator.

I'm working on a Discord bot (with Discord.js - NodeJs) to organize and sort applications automatically, but I cannot trigger the event when a new response is posted on the google form.

Do you have any idea how to do that?

marble juniper
#

check thier docs

unborn haven
#

get some packages?

chilly sphinx
#

Of course, I already check the google api doc..

unborn haven
#

ok sy

chilly sphinx
#

^^

low marsh
#

anyone a idea how I delete the last 3 messages the bot sent ?

marble juniper
#

you could store them in a collection

#

or something

pale vessel
#

get the messages in cache and filter them

marble juniper
#

or that

low marsh
#

hmmm

#

any code example?

#

idk how to "cache" them

honest perch
#

Read the docs

low marsh
#

bruh I hate discordjs 12

quaint hornet
#

hey i have a command who generate a image and send it inside a embed, but i want this command run 5 times with a delay of 30, and i make it but the imagem dont change, the message is edited but the image dont change.

earnest phoenix
#

is there a way to remove my bot from servers i'm not in?
i uh
overestimated the abilities of my free hosting and now my bot will just die randomly

misty sigil
#

yes there is

#

idk how

#

but you couldโ€™ve just made it private tbh

earnest phoenix
#

like i said
I didnt realize how garbage my free hosting was

#

my bot does like 5 things

misty sigil
#

what lib and version

#

Iโ€™ll grab some documents

earnest phoenix
#

discord.js latest vsrsion

misty sigil
#

Do you have an eval command?

earnest phoenix
#

i do not

misty sigil
#

hmm

pale vessel
#

@earnest phoenix either get your server IDs one by one or make an oauth application and get your servers from there. with the IDs, you can do something like guilds.forEach(x => { if (!ids.includes(x.id)) x.leave(); }); where ids is an array of server IDs you're in

#

if you don't have an eval command, make a temporary command for it, doesn't need to be an eval

earnest phoenix
#

cool thanks

#

i ended up getting it to work :)

fervent goblet
#

everytime i try to install canvacord it returns this

#

anyone know how to fix?

pale vessel
#

gyp OMEGALUL

#

did you install windows-build-tools?

fervent goblet
#

let me make sure

faint token
#

@earnest phoenix still having trouble with your hosting, i know another good hosting

earnest phoenix
#

yeah its still being annoying

#

what do you recommend

faint token
#

@earnest phoenix dms

earnest phoenix
#

they're going to end up recommended either glitch or heroku

#

which, glitch does not allow pinging to keep a discord bot alive anymore

#

and heroku is just trash and you'll have downtime

fervent goblet
pale vessel
#

that's a node-gyp error

#

node-gyp is not installed

spark wing
#
    "user": [
        {
            "id": 1,
            "Name": "Choc Cake",
            "Image": "1.jpg",
            "Category": "Meal",
            "Method": ""```

Someone know how to get data in the json array?
pale vessel
#

indexes

#

it's still an array

earnest phoenix
#

treat the user property as a normal array

#

yes

clever garnet
#

so what i want my bot to do is log when its added to a server and i also want it to make an invite link
how do i make an invite link that last forever and has inf uses
im using discord.js

#

12.2.0

sudden geyser
#

You generally shouldn't make backdoor-like functionality into your bot as it's a breach of privacy (to generate/get an invite upon joining a server).

clever garnet
#

like just to see the members in the server on the embed thing on the invite

sudden geyser
#

What library are you using?

clever garnet
#

discord.js
version 12.2.0

sudden geyser
#

ah yeah I missed it. Listen to the guildCreate event. The first argument you receive is a guild instance, so you can simply use .memberCount on it instead (returns the total number of users in the guild).

clever garnet
#

ok

grizzled raven
#

dont actually think invite links on join are allowed and i definitely wouldnt encourage it

#

imagine adding a bot and it creates an invite link without you even knowing

crimson vapor
#

it would be against tos as it is a privacy breach

valid frigate
#

using async_trait macro doesnt work either

weak rain
#

Hi

#

Can someone help me with Guilds code

#

my bot replies to slow

#

When I use my Stats command

sonic lodge
#

show code

weak rain
#

Ok

#

but it is in JS V11

sonic lodge
#

why haven't you upgraded?

weak rain
#

I m lazy xD

#

Planning to do soon

sonic lodge
#

ok, show the code

weak rain
#

F

#
const { version } = require("discord.js");
const moment = require("moment");
const m = require("moment-duration-format");
let os = require('os')
let cpuStat = require("cpu-stat")
const ms = require("ms")

exports.run = (bot, message, args) => { 
  let botconfig = require(`../botconfig.json`)
if (!message.content.startsWith(botconfig.prefix)) return;
  
  let cpuLol;
  cpuStat.usagePercent(function(err, percent, seconds) {
    if (err) {
      return console.log(err);
    }
  const duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
  const embedStats = new Discord.RichEmbed()
    .setAuthor(bot.user.tag, bot.user.displayAvatarURL)
    .setTitle(':Star:  **__Bot Stats__** :Star: ')
    .setColor("RANDOM")
    .addField("> :Star: Uptime of the Bot ", `${duration}`, true)
    .addField("> :Star: Ping of the Bot", `${Math.round(bot.ping)}ms`)  
    .addField("> :Star: Playing with Servers", `${bot.guilds.size.toLocaleString()}`, true)
    .addField("> :Star: Playing with Users", `${bot.users.size.toLocaleString()}`, true)
    .addField("> :Star: Playing with Channels ", `${bot.channels.size.toLocaleString()}`, true)
    .addField("> :Star: Coded On",`Discord.JS โ€ข Node.JS`)
    .addField("> :Star: Coded By",`Thunder `)     
  
message.channel.send(embedStats)
  });
}

exports.help = {
  name: "stats",
  category: "Miscelaneous",
  description: "Gives some useful bot statistics",
  usage: "info"
};```
#

@sonic lodge

sonic lodge
#

you said that the command is slow

weak rain
#

Yes

sonic lodge
#

you'll have to figure out what part of that code is taking a long time

weak rain
#

OwO

#

ok

sonic lodge
#

are you sure it's your code and not your computer or anything else?

weak rain
#

Na my friend gave this

#

๐Ÿคจ

sonic lodge
#

it's your friend's code

weak rain
#

Idk

#

not mine

#

I can say

sonic lodge
#

my hunch is the cpuStat module

#

according to the examples it's going to take a moment to gather the usage percent for all cores

weak rain
#

Thats why its slow because Its gathering information?

sonic lodge
#

probably

weak rain
#

Ty

earnest phoenix
#

tip

#

users generally don't care about technological stats

#

omit that info because you dont need to provide it in the first place

ancient falcon
#

they generally dont understand it at all

fervent goblet
#

anyone know how i would calculate the position of an object within array. doing this to define someones rank. with the total XP they get but i try .indexOf() but i always get -1

#
rank.find({}).sort([['totalGainedXP', 'descending']]).exec((err, res) => {
    console.log(res.indexOf({userID: message.author.id}))
})
sonic lodge
#

try using .findIndex(), which accepts a callback

fervent goblet
#

ok thanks

sonic lodge
#

.indexOf() doesn't work because it compares elements with strict equality, the same one used when you type ===

fervent goblet
#

o

#

it works thanks

hearty wind
#

Anyone have a good idea how to count emoji reactions.

i have this..

for second in range(20):
                for reaction in message_id.reactions:
                    if reaction.emoji == ':thumbsup:':
                        thumbs_up_count = reaction.count
                    if reaction.emoji == ':thumbsdown:':
                        thumbs_up_count = reaction.count
                    await message.edit(content=("**----POLL----** \n \n**Green Today?** :thumbsup: {} \n \n**Red Today?**   :thumbsdown: {}".format(thumbs_up_count,thumbs_down_count)))

i want to edit the message with the percentages of the emojis next to the thumbs up and thumbs down.

#

as the votes come in

stone elm
#

i cant create my bot i have 2FA

#

what to do

#

pls help me

earnest phoenix
#

IT TOOK LONG ENOUGH'./'

#

<3

trim saddle
#

@stone elm you can't make a bot app?

stone elm
#

i did make one

trim saddle
#

so what's your problem

stone elm
crimson vapor
#

that is just the site to get the invite link for your bot easier

stone elm
#

yes bot how to get it

#

it doesnt let me

#

get the link

winter basalt
#

look at the bottom bro

lusty quest
#

the Red line marks the Spot

stone elm
#

i did

lusty quest
#

did you enter the client id? and not the bot ID?

stone elm
#

the client ID

lusty quest
#

then it should work

lusty quest
#

.... this is not your client ID

#

this is probably your bot token

stone elm
#

wait let me check

lusty quest
#

btw would re generate the token now

stone elm
#

thank you so much i really thank you for helping me

#

i did it

cunning gorge
#
const Discord = require("discord.js");
const fs = require("fs");

exports.run = (client, message, args) => {
  const got = require("got"),
    { MessageEmbed } = require("discord.js");

  got("https://www.reddit.com/r/Brawlstars/random/.json")
    .then(response => {
      let content = JSON.parse(response.body),
        image = content[0].data.children[0].data.url,
        embed = new MessageEmbed()
          .setTitle(`${content[0].data.children[0].data.title}`)
          .setURL(
            `https://www.reddit.com${content[0].data.children[0].data.permalink}`
          )
          .setImage(image)
          .setTimestamp()
          .setColor(0xd305fa)
          .setFooter(
            "๐Ÿ‘ " +
              content[0].data.children[0].data.ups +
              " | ๐Ÿ’ฌ " +
              content[0].data.children[0].data.num_comments +
              " | " +
              content[0].data.children[0].data.author
          );
      message.channel.send(embed);
    })
    .catch(console.log);
};

exports.help = {
  name: "brawl-post",
  category: "brawlstars"
};

Hello, I have this working command to pull from sub reddits, however, it does not filter out videos and regular text. Is there anyway to modify this to only produce images? If anyone has any solution please ping me ๐Ÿ™‚

lusty quest
#

the reddit API returns isVideo in the json. and the image as a different key.

cunning gorge
#

oh, so what should I edit exactly to pull the image and not pull a video

#

Sorry i'm not super great with APIs

lusty quest
#

its simple. usually i paste the request URL in a browser and copy the entire json into a jsonpath finder

#

this makes it easy to find the key you want

cunning gorge
#

Oh okay, what's a json path finder?

#

I pasted the url, and I can see how its tough to read lol

lusty quest
#

just copy the entire json on the API page in there

#

then you get on the right side a easy to read json path

#

x[0].data.children[0].data.url this as example will give you the Image from the first post the API returns

cunning gorge
#

oo okayy

lusty quest
#

also you see it returns a boolean here x[0].data.children[0].data.is_video

#

if its true its a video if false its not

cunning gorge
#

ah, is there a key to pull an exact image? since content[0].data.children[0].data.url, pulls videos as well

#

unless u mean i need to check with x[0].data.children[0].data.is_video

lusty quest
#

idk if there is something for only images. i have for now only a filter running that filters out NSFW Posts if the channel where the command is run not a NSFW channel and removes Videos

cunning gorge
#

ohh okay, well once u check if its a video, and it returns true

#

what do u do, do u fetch another one?

lusty quest
#

?

cunning gorge
#

For example, lets say is_video returns true

#

the final goal is to send a post with an image...

#

So somehow you would need to loop it again until it returns is_video false

lusty quest
#

i just return. but i could use a function and run it again until is_video is false

cunning gorge
#

Ah, so when you return it, there is no response with the command?

#

Assuming a user triggers the command to fetch a reddit post

#

and if ur filtering videos, it returns is_video true, then what do you send back to the user?

#

Hopefully this made sense lol

lusty quest
#

ohh now i see what you want. its simple i just skip the ones that are videos and return a different one instead

cunning gorge
#

oh can you show me how to do this?

#

Sorry as I said, I havnt worked with APIs that much

lusty quest
#
 const allowed = message.channel.nsfw ? data.children : data.children.filter(post => !post.data.over_18 || !post.data.is_video);
          if (!allowed.length) return message.channel.send(`sorry but it seems like we're out of memes`);
```data is the API return
#
const randomInteger = Math.floor(Math.random() * allowed.length);
```then i generate a random id from the json that is left
#

and then just use it for the Embed

cunning gorge
#

Ooo okay, so basically you fetch the amount of memes or whatever, and you keep filitering it until you run out

#

which im assuming is a very low probability

lusty quest
#

i havent seen the error since ive made the command

cunning gorge
#

oo okayy

#

thank you!

lusty quest
#

btw the filter will not work if the channel is a NSFW channel

#

its not the best way to do it but it works for me

cunning gorge
#

ah okayy

valid frigate
#

currently in the serenity discord library i am trying to make the trait function message() async, but currently async isn't supported for traits so is there any library/way to make this work? (using tokio runtime)

// could use #[async_trait] but dealing with elided lifetimes is nah
impl EventHandler for Handler {
    fn message(&self, ctx: Context, msg: Message) {
        handle_message(ctx, msg);
    }
}

^ the function should be async

cunning gorge
#

So for my image would it be

const image = content[0].data.children.filter(post => !post.data.is_video);
const randomInteger = Math.floor(Math.random() * image.length);
const imageURL = image[randomInteger]

@lusty quest would this work? Or did I not understand the code correctly

lusty quest
#

if you remove the = before randomInteger it could work

cunning gorge
#

oh right ofc

#

thxx

lusty quest
#

but this will only work for the first post on the page

cunning gorge
#

wdym by that

#

ohh

lusty quest
#

content[0].

#

data was in my case what you use for content

cunning gorge
#

So essentially, it would filter out the image, and if it was a video it wouldnt create a url

#

To fix this would i just use content[]?

lusty quest
#

yes

#

remove [0]

cunning gorge
#
const image = content.children.filter(post => !post.data.is_video);
const randomInteger = Math.floor(Math.random() * image.length);
const imageURL = image[randomInteger]
lusty quest
#

and remove .data

#

this looks fine

cunning gorge
#

Why did i remove .data exactly?

#

And for the content.children, does this pull up all the posts ever posted in that sub reddit?

#

Or only the top 20 or something

lusty quest
#

it should pull all

#

or atleast a few

cunning gorge
#

ah okayy

#

Gotcha this makes sense thank you!

#

Why did i remove .data exactly?
@cunning gorge
Oh and one more question, why did we remove .data

#

Since I had .data originally

lusty quest
#

the .data was from my code for me was my json from the API = data

untold folio
#

hey, whats the permission for .setNickname? manage nicknames only? cause i'm getting the missin gperms error

ember lodge
#

Why does Cloudflare https doesnโ€™t work on my website? I have CloudFlare but it doesnโ€™t work with https just with http

lusty quest
#

did you got a SSL Cert installed on the server?

earnest phoenix
#
const mongoose = require("mongoose");

const guildSchema = mongoose.Schema({
    guildId:String,
    autorole: String,
    enable: Boolean,
    warn: {
        "UserId": {
            warnTimes: Number,
            lastReason: String
        }
    },
})

module.exports = mongoose.model("Guild", guildSchema);
#

pls help how i can fix this

#

i am using mongoose

lusty quest
#

what is the issue?

earnest phoenix
#

"UserId"

#

i want to change it with real id

#

but idk how

#

to

lusty quest
#

i dont think this is a valid syntax

#

i would rather save the warns in a user profile with the GuildID as key

earnest phoenix
#
const mongoose = require("mongoose");

const guildSchema = mongoose.Schema({
    guildId:String,
    autorole: String,
    enable: Boolean,
    warn: {
        message.author.id: {
            warnTimes: Number,
            lastReason: String
        }
    },
})

module.exports = mongoose.model("Guild", guildSchema);
#

yes i am using GuildId as key

lusty quest
#

this looks like a GuildConfig

earnest phoenix
#

yes it is

lusty quest
#

i talk about a userprofile

earnest phoenix
#

wdym

#

i use monk ยฏ_(ใƒ„)_/ยฏ

lusty quest
#

its sunday and im not mentally prepared for this again.

#

sorry

earnest phoenix
#

oof

#

ok so

#
const dbl = new DBL('secret vote token thing', client);
dbl.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
  client.users.cache.get("686998287647113302").send(`Hey Keem, someone just voted`)
});

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})
#

this works not why

lusty quest
#

fetch the user its possible its not cached

white drum
#

how am i able to make a setting where the user can change what the muted role is

earnest phoenix
#

@lusty quest wdym

#

bro

#

i dont understand

#

wdym

white drum
#

me?

earnest phoenix
#

wdym

#

no y

#

im confused

#

me 2

#

why doesnt it work again?

lusty quest
#

@earnest phoenix your user is probably not cached

violet mason
#

Pretty sure you have to use webhooks a to get votes they why you want

earnest phoenix
#

it still didnt log the vote in console

lusty quest
#

@white drum store the role into a database and call it for settings the mute role

#

@earnest phoenix is your webhook running?

earnest phoenix
#

im not running a webhook

violet mason
#

Thatโ€™s why

white drum
#

k

earnest phoenix
#

._.

violet mason
#

For you to get the vote you must use a webhook

earnest phoenix
#

pls help

#

ok

#

but how

lusty quest
#

the Docs have a explanation

earnest phoenix
#

i looked at the docks

#

1 sec

lusty quest
violet mason
#

const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

app.get('/', (req, res) => {
  // ...
});

server.listen(5000, () => {
  console.log('Listening');
});
lusty quest
earnest phoenix
#
const mongoose = require("mongoose");

const guildSchema = mongoose.Schema({
    guildId:String,
    autorole: String,
    enable: Boolean,
    warn: {
        userId: [],
        warnTimes: []
    },
})

module.exports = mongoose.model("Guild", guildSchema);
#

@lusty quest i have a crazy idea

#

i will find userId and warnTimes with i

#

in for loop

#

like userId[i] with warnTimes[i]

lusty quest
earnest phoenix
#

how does this look

#

dude i am done

#

imma use Json

#

lol

#

understandable

#

@earnest phoenix try eval message.author.username

#

it is better

#

wdym

lusty quest
#

@earnest phoenix ```javascript

const guildSchema = mongoose.Schema({
guildId:String,
autorole: String,
enable: Boolean,
warn: [
{userID:String ,warnTimes: Number,lastReason: String}
],
})

earnest phoenix
#

hmmm

#

idk due

#

then how i can find it

#

@lusty quest ?

lusty quest
#

findOne?

#

then just the userID?

balmy vessel
#

DM ADS and Announce @leaden lava

earnest phoenix
#

What

#

just the userId

#

What

balmy vessel
#

-_-

white drum
#

so im trying to put ascii art in my bot but it includes \ which is making it ignore letters, how do i stop it from ignoring letters whilst keeping \

earnest phoenix
#

replace \ with \\

white drum
#

ahh thx

earnest phoenix
#

np

#

dude ur are genis

#

@lusty quest

lusty quest
#

just read the dam docs. i never used it and just read the docs

earnest phoenix
#
const server = http.createServer(app);
const dbl = new DBL('did you really think my bot api token thingy was under here, i learned from the best of the best to keep my creds secret', { webhookAuth: 'supersecretwebhookpassword123321', webhookServer: server });

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
  client.users.cache.get("686998287647113302").send(`yo keem, someone voted`)
});
#

still wont work

white drum
#

lmao

#

the code tho

earnest phoenix
#

ikr

#

im pretty retarded so

#

@earnest phoenix so how did u keep it

lusty quest
#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });

earnest phoenix
#

process.env.dbltoken ?

white drum
#

'did you really think my bot api token thingy was under here, i learned from the best of the best to keep my creds secret'
that just makes me laugh

earnest phoenix
#

me 2

lusty quest
#

add , client after the array for autoposting of the Servercount

earnest phoenix
#

hard coded it for testing purposes

lusty quest
#

just use a env variable for your creds?

earnest phoenix
#

thats not the problem here sir

lusty quest
#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });did you see the difference?

earnest phoenix
#

yes i do sir

#

ill probably be back sir

lusty quest
#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' },client);for autoposting your Guildcount

earnest phoenix
#

the guild count is posting

lusty quest
#

sure i just add it usually bcs its usual a question that arrives after the webhook is running

earnest phoenix
#

well

#

does the port have to be the same port my machine is on?

lusty quest
#

?

earnest phoenix
#

like

lusty quest
#

its just the port where the Webhook is running one

earnest phoenix
#

so it can be anything?

lusty quest
#

you can use 42069 as port

#

you just need to define it correct in your URL then

earnest phoenix
#

so if my app listens on 3000

#

thats irrelevant?

lusty quest
#

the port needs to be free

earnest phoenix
#

ok

#

@lusty quest how i can find the UserId

#

in docs it is diffrent

lusty quest
#

get creative. i need to look it up too but i would guess findOne(guildid,{userid:user.id})

#

or findOne(guildid,{warn.userid:user.id})

earnest phoenix
#

ok

pure lion
#

How would i make my console app take input?

earnest phoenix
#

@lusty quest but if the document is created

#

nvm

#

ok so

#
const dbl = new DBL("dbl token", { webhookPort: 6969, webhookAuth: 'supersecretwebhookpassword123123123' });

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
  client.users.cache.get("686998287647113302").send(`SOMEONE JUST VOTED, AND YOU FIGURED OUT VOTES`)
});
#

@lusty quest so

#

simply doesnt work

#

when the function will return guild as a result

#

im i just retarded orrr

lusty quest
earnest phoenix
#

so i can use simple guild.warnTimes

#

?

#

@lusty quest

#

@earnest phoenix ur prlem

lusty quest
#

@earnest phoenix did you added the correct URL to top.gg?

earnest phoenix
#

so i can use simple guild.warnTimes
@lusty quest hhuh

lusty quest
#

@earnest phoenix depends on how you return the db

earnest phoenix
#

did i do the what now

lusty quest
#

you need to add a URL where the Webhook is running on to your Bots top.gg site

#

usually http: //your-server-ip:your-port/dbl-webhook

earnest phoenix
#

where do i add it at

lusty quest
#

edit your bot and somewhere is a field for the URL and for webauth

#
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```you see the path if you add this to your bot
#

we can help if we would know your issue

earnest phoenix
#

ok

#

i knew it

#

warn is undefiened

#

smh

lusty quest
#

then use sub documents

earnest phoenix
#

how

#

if localhost?

#

no

#

ur ip

lusty quest
#

replace the ip with your ip

earnest phoenix
#

0.0.0.0 is the ip sir

#

ur public ip

#

@earnest phoenix no

#

go to google and search how to get ur public ip

#

this is confusing

#

lo

#

l

#

its on my panel

#

no

#

that is private

#

ip

#

im not hosting the bot on my pc

#

its being hosted on the panel

#

a pterodactyl panel

lusty quest
#

you still get a IP

earnest phoenix
#

it didnt log one

lusty quest
#

i dont have a ptrodactyl installation rn to show you where to get the ip

#

but you get one

earnest phoenix
lusty quest
#

ok then you use a Host Bride

#

what is the IP of the panel your run on?

earnest phoenix
#

idk

lusty quest
#

did you installed the panel?

fathom sky
#

Hey

earnest phoenix
#

i didnt install it

fathom sky
#

I have a question

lusty quest
#

you need the ip otherwise the webhook will not work

fathom sky
#

I want to bot the leave the specific servers by id

#

How do i do that

lusty quest
#

or get a open port for the domain

restive pebble
#

djs?

fathom sky
#

djs?
@restive pebble discord js yes

restive pebble
#

get the id from cache

fathom sky
#

I hot id

restive pebble
#

and use .leave()

fathom sky
#

G*

#

Where i write it and run?

earnest phoenix
#

but how can i get the ip

fathom sky
#

Just make command paste id?

lusty quest
#

ask the guy who host the panel

restive pebble
#

client.guilds.cache.get("id").leave()

tight plinth
#

@fathom sky do a client.guilds foreach loop, check if server id is the one you want, and if it is leave the server

#

we're not gonna give you code

restive pebble
#

either eval it or paste it inside ur index file

fathom sky
#

client.guilds.cache.get("id").leave()
@restive pebble is that v12?

restive pebble
#

yes

#

imagine doing forEach if u have the id

fathom sky
#

I got id

tight plinth
#

he says "servers"

#

so this means he want to leave several servers

restive pebble
#

oh

earnest phoenix
#

use a filter at least

#

or map

tight plinth
#

or he's english is bad

fathom sky
#

so this means he want to leave several servers
@tight plinth yes actually)

earnest phoenix
#

not foreach

tight plinth
#

so yeah, do a foreach loop

#

you can just eval it

restive pebble
#

forEach

earnest phoenix
#

map

fathom sky
#

or he's english is bad
@tight plinth sry My country does not associated wirh english language

tight plinth
#

np

fathom sky
#

Hmm

tight plinth
#

you know how to do forEach loop, don't you?

earnest phoenix
#

yes

fathom sky
#

I got what to do

#

I get it*

slim heart
#

okay so recently i went on a venture to redo my discord http properly, and so obviously,
r a t e l i m i t s, we all love those.
anyways after a few hours of understanding i sort of understood how discord ratelimits actually work.
i started using discord.js as a logic base in order to make sure what im doing is right, that being said i am now finding myself with conflicting solutions
what i've been told is to be storing "minor" paths of each request as its subsequent ratelimit bucket, with this i can then create a "major" key using major params, like channel_id, and that bucket id.
however with djs they seem to be completely disregarding the ratelimit bucket hash altogether, and creating ratelimit instances based on purely unique paths, which is strange i think? unless im misunderstanding it, the ratelimit would apply to everything like for ex delete /channels/id/messages/id would be the same ratelimit bucket every time? right? idk

posting it here too just in case anyone who happens to know ratelimit logic could help a_eyesshaking

lusty quest
#

i think tim could help you

#

he wrote a new d.js lib for removing the caching stuff

earnest phoenix
#

does that look right

slender thistle
#

Is that IP real

earnest phoenix
#

yes

#

its public

#

dont delete it

slender thistle
#

And what made you think it's a good idea to post it in a 100k members server

earnest phoenix
#

because its public

#

its the ip to the node i host on

#

which literally everyone has access to

#

im just wondering if its correct

#

or is that not the right

#

thing

nocturne grove
#

Hey. If I delete a channel and then use the <channel>.category.children property, is it always 100% sure the deleted channel isn't in there anymore in code like this?

await <channel>.delete();
console.log(<channel>.category.children);```
golden condor
#

the object will still be defiend

nocturne grove
#

no that's not what I mean. I want to be sure if the channel immediately gets removed from channel.category.children if you use those children after you awaited channel.delete()

golden condor
#

I am not sure

nocturne grove
#

okay

#

maybe someone else knows

pale vessel
#

you can also try it and see

misty sigil
cinder patio
#

It will be removed

nocturne grove
#

you cannot try something 10 times and say it will always work

#

๐Ÿคท

earnest phoenix
#

code: ```js
if (args[0] === "--bio") {
let bio;
bio = args.join(" ")

await bot.db.collection("Profiles").findOneAndUpdate({"User_ID": user.id}, {$set: {Bio: bio}}, {upsert: true})
message.channel.send(Set your \`${bot.prefix}profile`` bio to ${bio}`)
} else {
message.channel.send(PFPImage)
}

nocturne grove
#

do you mean from the string?

earnest phoenix
#

yes

#

like remove

nocturne grove
#

so you want to remove the first 4 characters?

earnest phoenix
#

the --bio

nocturne grove
#
const getRidOfIt = str.slice(4);```
earnest phoenix
#

uhhhhhhhh where would put?

#

;-;

#

i said wher do i put

#

not would it work

#

ok so

#

!help eeeepokemon

#

nevermind

#

Anyone knows how to push permissions into a voice channel?

stray stump
#

How can I customize prefix for people in their own servers

earnest phoenix
#

I found my solution on discord.js.

#

@stray stump get a database.

stray stump
#

Oh

earnest phoenix
#

If you want local storage use quick.db

stray stump
#

Yes Iโ€™m using .js

earnest phoenix
#

that doesnt help

#

but k lol

#
    id: guildID,
    prefix: "!"
}```
#

use quick.db its os simple

nocturne grove
#

uhhhhhhhh where would put?
@earnest phoenix after you have gotten the string from some place and before you are using it

#

idk where those two spots are

earnest phoenix
#

ok

nocturne grove
#

I think bio is the string where you want to slice 4 chars from

earnest phoenix
#

db.set("guildID", { prefix: "!" });
let prefix = db.fetch("guildID");
prefix = prefix.prefix;

#

str.replace("--bio", '').trim(); @nocturne grove

#

also make a command handler

#
let dbprefix = db.fetch(`prefix_${message.guild.id}`)

if(dbprefix) {
var prefix = dbprefix
} else if(!dbprefix) {
var prefix = config.prefix; //default prefix
}
#

@earnest phoenix dont use prefix_ its going to be alot of data storage

#

im just saying

#

it will work

#

use the guildID as the key then create an object inside it

#

for more usage

#

i know

#

but dont provide like shit ways to do a database

#

else that person will have a shit time when they realize what they did

west skiff
#

yes you can but that depends on a lot of things like your language and library

#

i made my music bot a long time ago but if i remember right discord, at least discord-py, needed pcm data to play sound

#

so figure out if thats what discordjs needs and how to stream and convert an mp3 to raw pcm data (or whatever discord js needs)

#

google is your friend

earnest phoenix
#

so

#

to be clear

#

i can throw the webhook stuff in my index.js for my bot right

nocturne grove
#

str.replace("--bio", '').trim();
@earnest phoenix why would you do that if slice(4) does the same?

earnest phoenix
#

that works too

nocturne grove
#

I know

#

but why

west skiff
#

code readability is usually more important than performance to a certain point

#

replace probably practically doesnt take any longer and is more obvious what its doin

nocturne grove
#

and what is in your opinion more readable?

#

well it depends on the person, for me slicing makes more sense

#

as you want to remove the first chars of something

earnest phoenix
#

code readability is usually more important than performance to a certain point
that is completely false lol

quartz kindle
#

being a good coder is being able to do both at the same time

#

if you have to sacrifice one for the other, then you can probably improve some more

earnest phoenix
#

being a good coder is being able to do both at the same time
@quartz kindle being code913 is being bread brain
๐Ÿž === ๐Ÿง 

true ravine
#

Right so I'm having to start sharding but I'm kinda stuck because I need a way to wait until all shards are ready before taking a guild count to send to bot list APIs - except idk how to do that

earnest phoenix
#

Wtf is shards

true ravine
#

(djs)

#

It's a way to split a bot into multiple subprocesses for efficiency

quartz kindle
#

there are two ways of sending guild count

#
  1. send all at once from a single shard or master process
  2. send individual counts from each shard
#

option 2 is much easier

true ravine
#

Oooh the second sounds fun, I'll do that

#

Thank you

autumn summit
#

Hi

quartz kindle
#

if you use the dblapi.js autoposter, it will do option 2 for you automatically

autumn summit
#

im trying to make multiple raction roles in one message

true ravine
#

Yeah I am, so thx

autumn summit
#

if str(payload.emoji) == ':red_square:':

#

is this correct

#

red square is ๐ŸŸฅ

quartz kindle
#

\๐ŸŸฅ

autumn summit
#

and I printed payload.emoji it gave me "red_square"

quartz kindle
#

default emojis dont use names

autumn summit
#

with the :

quartz kindle
#

they use their unicode version

autumn summit
#

yeah I had the unicode version

#

it didnt work

quartz kindle
#

unless dpy does something to them

autumn summit
#

i had this

#

if payload.emoji == '๐ŸŸฅ':

#

originally

quartz kindle
#

should be if payload.emoji == "๐ŸŸฅ"

#

but idk, i dont even use d.py

autumn summit
#

i need ""

#

?

#

'' doesnt work?

quartz kindle
#

both should work

autumn summit
#

oh ok

true ravine
#

Going back to my original question, I also list my bot on another less epic bot list, which doesn't (afaik) have a lib so I have to send it the data with a post request - how would I get the right numbers to do that?

quartz kindle
#

@true ravine does their api support sharding?

#

show their docs

true ravine
#

So atm I just do bot.guilds.cache.size and put that into server_count

quartz kindle
#

they dont seem to support sharding

true ravine
#

But with sharding I'd need to get the total, but I don't want it to send if not all shards are ready

#

Yeah that's what I thought

quartz kindle
#

you can send the request from your sharding manager

#

using fetchClientValues

true ravine
#

But there could be a chance that not all shards are ready?

quartz kindle
#

the sharding manager gives you information on when they are all ready

true ravine
#

Oh really? Okay I'll have another look

earnest phoenix
#
  if (bio.content === "none") {
    await bot.db.collection("Profiles").deleteOne({"User_ID": user.id})
  }
``` somethings wrong i can feel it
true ravine
#

Thanks

quartz kindle
#

you need to listen to the shardCreate event

#

and then listen to the ready event

#

and then increase some counter, and check if the counter is the same as the total shards value

#

no idea why the sharding manager doesnt have an "allReady" event

true ravine
#

I read a debate on github about that

#

Apparently there's no need for it

earnest phoenix
#

**This is Error Code.
**```C:\Users\Lenovo\Desktop\Cruncher\events\guildMemberAdd.js:2
const defaultChannel = member.guild.channels.find(channel => channel.permissionsFor(guild.me).has("SEND_MESSAGES"));
^

ReferenceError: guild is not defined
at C:\Users\Lenovo\Desktop\Cruncher\events\guildMemberAdd.js:2:89
at Map.find (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\util\Collection.js:506:11)
at module.exports (C:\Users\Lenovo\Desktop\Cruncher\events\guildMemberAdd.js:2:50)
at Client.emit (events.js:315:20)
at Guild._addMember (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\structures\Guild.js:1542:19)
at GuildMemberAddHandler.handle (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\packets\handlers\GuildMemberAdd.js:12:13)
at WebSocketPacketManager.handle (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17)
at WebSocket.onMessage (C:\Users\Lenovo\Desktop\Cruncher\node_modules\ws\lib\event-target.js:120:16) **guildMemberAdd.js **js
module.exports = (client, member) => {
const defaultChannel = member.guild.channels.find(channel => channel.permissionsFor(guild.me).has("SEND_MESSAGES"));
defaultChannel.send(Welcome ${member.user} to this server.).catch(console.error);
}```

true ravine
#

But yeah I'll do that thanks

earnest phoenix
#

Could anyone help me please.

golden condor
#

Define guild

#

It's member.guild

earnest phoenix
#

I define it on the main.js or the guildMemberAdd.js

golden condor
#

guildMemberAdd.js

earnest phoenix
#
const guild = member.guild```
#

?

golden condor
#

Yes

earnest phoenix
#

Thanks ๐Ÿ˜„

quartz kindle
earnest phoenix
#

I got another error.

ReferenceError: member is not defined
quartz kindle
#

where

earnest phoenix
#
const guild = member.guild
              ^

ReferenceError: member is not defined
    at Object.<anonymous> (C:\Users\Lenovo\Desktop\Cruncher\events\guildMemberAdd.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
    at Module.load (internal/modules/cjs/loader.js:1034:32)
    at Function.Module._load (internal/modules/cjs/loader.js:923:14)
    at Module.require (internal/modules/cjs/loader.js:1074:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at C:\Users\Lenovo\Desktop\Cruncher\index.js:13:19
    at Array.forEach (<anonymous>)
    at C:\Users\Lenovo\Desktop\Cruncher\index.js:12:9```
quartz kindle
#

where did you put it?

earnest phoenix
#

in the guildMemberAdd.js

quartz kindle
#

show

earnest phoenix
#
const guild = member.guild

module.exports = (client, member) => {
    const defaultChannel = member.guild.channels.find(channel => channel.permissionsFor(guild.me).has("SEND_MESSAGES"));
    defaultChannel.send(`Welcome ${member.user} to this server.`).catch(console.error);
  }```
quartz kindle
#

module.exports is your entry point. it gives you client and member

#

client and member are only available inside the module.exports block

#

they dont exist outside

pure lion
#

wai skip nu work

module.exports = {
    name: 'skip',
    usage: 'aa!skip',
    diescription: 'skip the music :(',
    async execute(client, msg, args) {

        const serverQueue = client.queue.get(msg.guild.id)

        if (!msg.member.voice.channel) {
            return msg.channel.send('You need to be in a voice channel to skip the music')
          } else if (!serverQueue) {
            return msg.channel.send('There is nothing to skip')
          } else {
            serverQueue.connection.dispatcher.end()
            msg.channel.send(`${msg.author.username} skipped the music`)
            break;
          }
    }
}

help works fine, but the command just returns nothing

earnest phoenix
#

so that i define the const guild = member.guild inside of module.exports?

quartz kindle
#

yes

earnest phoenix
#

Thanks

quartz kindle
#

instead of defining it

earnest phoenix
#
    defaultChannel.send(`Welcome ${member.user} to this server.`).catch(console.error);
                   ^

TypeError: defaultChannel.send is not a function
    at module.exports (C:\Users\Lenovo\Desktop\Cruncher\events\guildMemberAdd.js:4:20)
    at Client.emit (events.js:315:20)
    at Guild._addMember (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\structures\Guild.js:1542:19)
    at GuildMemberAddHandler.handle (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\packets\handlers\GuildMemberAdd.js:12:13)
    at WebSocketPacketManager.handle (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65)
    at WebSocketConnection.onPacket (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35)
    at WebSocketConnection.onMessage (C:\Users\Lenovo\Desktop\Cruncher\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17)
    at WebSocket.onMessage (C:\Users\Lenovo\Desktop\Cruncher\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\Lenovo\Desktop\Cruncher\node_modules\ws\lib\websocket.js:789:20)```
pure lion
#

is it defined as a guildchannel or a text channel?

earnest phoenix
#
module.exports = (client, member) => {
    const guild = member.guild
    const defaultChannel = guild.channels.find(channel => channel.permissionsFor(guild.me).has("SEND_MESSAGES"));
    defaultChannel.send(`Welcome ${member.user} to this server.`).catch(console.error);
  }```
pure lion
#

cache

#

channels are cached

quartz kindle
#

are you using v11 or v12?

earnest phoenix
#

How could i check it?

quartz kindle
#

npm ls discord.js

earnest phoenix
#

discord.js@11.6.4

pure lion
#

h m

#

do npm i discord.js

#

then follow the update guide

quartz kindle
#

do console.log(defaultChannel)

#

before sending

#

but after finding

earnest phoenix
#

I have installed V12

quartz kindle
#

@pure lion your break there is invalid

pure lion
#

oh

#

o h ye a h i c o pi e d i t f ro m m y o l d b o t h ahaha ha hah a ha hah a

earnest phoenix
#

So How can i fix it? I have update Discord.js to V.12

pure lion
#

i advise

quartz kindle
#

if you updated to v12, then you have a lot of things to change

pure lion
#

unless you dont want a bot in a few months

quartz kindle
#

read this

earnest phoenix
#

It's maybe not a lot for me

#

My bot only have 3 events with 3 commands

quartz kindle
#

thats good then

#

better update now than later

earnest phoenix
#

Yea, There is nothing i need to change

#

I have check it all. There are nothing i need to change'

earnest phoenix
#

dont we all

#

its not a thing

#

it's .play

#

because you copypasted code that is not for v12

earnest phoenix
#

Whats a good way to make a mute command

#

Without setTimeout because bot may restart etc

tight plinth
#

Use the bot to write mute time in a db, use another program that runs 24/7 that sends smth to the bot to tell it that smth is over

#

I guess

#

Or check in index.js every minute or so for people to unmute

earnest phoenix
#

I don't have any json file

tight plinth
#

Oof

#

Imagine using glitch

earnest phoenix
#

It's not mine

#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

misty sigil
#

how do i add pages to eval

pale vessel
#

pagination + reaction collector

#

split your content evenly and edit the message based on the respective reaction

#

e.g. when you click next, the index goes up and it'll find the content using the index and you can edit the embed

rigid maple
#

how can i antispam

#

pls ticket me

stoic hull
#

how to check if a user is on desktop webclient etc?

left lake
#

@rigid maple how to make an antispam?

rigid maple
#

Module

earnest phoenix
#

๐Ÿคฆ

#

imagine using modules

inner quarry
#

Whats a good way to make a mute command
@earnest phoenix

Use database.

earnest phoenix
#

I meant how I can enforce the timings

hidden lynx
#
  schemaName: 'ObjectId',
  defaultOptions: {},
  get: [Function],
  set: [Function: set],
  _checkRequired: [Function],
  _cast: [Function: castObjectId],
  cast: [Function: cast],
  checkRequired: [Function]
}" at path "_id"```

MongoDB (mongoose): Does anybody know why i'm getting this error? It doesn't give me the line where the error has occured so i cannot provide the code snippet :/ But maybe somebody can help :)
inner quarry
#

Hmmm.

lusty quest
#

thats easy

#

is this your shema or your query?

inner quarry
#

@hidden lynx You can use double ``` to wrap that error message.

lusty quest
#

@hidden lynx could you show your schema and your query?

inner quarry
#

I meant how I can enforce the timings
@earnest phoenix
Loop can be possible, but it's kinda unoptimized.

#

Try do more research.

earnest phoenix
#

bad when it's scaled

hidden lynx
#

Sure. Thats the schema:

const mongoose = require("mongoose");

const guildSchema = new mongoose.Schema({
  _id: mongoose.Schema.Types.ObjectId,
  guildID: String,
  guildName: String,
  prefix: String,
});

module.exports = mongoose.model("Guild", guildSchema);

And thats the query:

const mongoose = require("mongoose");
const Guild = require("../models/guild");

const getGuildPrefix = (message) => {
  var prefix;
  try {
    Guild.findOne({ guildID: message.guild.id }, async (err, data) => {
      if (err) {
        return console.log(err);
      }
      if (!data) {
        let newGuild = new Guild({
          _id: mongoose.Schema.Types.ObjectId,
          guildID: message.guild.id,
          guildName: message.guild.name,
          prefix: message.client.PREFIX,
        });
        newGuild.save();
        prefix = message.client.PREFIX;
      } else {
        prefix = data.prefix;
      }
    });
  } catch (err) {
    console.log(err);
  }
  console.log(prefix);
  return prefix;
};

module.exports = getGuildPrefix;
inner quarry
#

Yeah, ik. It's unoptimized.

#

Probably people won't bother a few minutes interval though.

lusty quest
#

@hidden lynx use this in your query mongoose.Types.ObjectId()

inner quarry
#

But I will do more research.

lusty quest
#

there is a difference between your schema and your query for this

#

@earnest phoenix i would store a timestamp (either end or beginning of the mute) then create a timer that checks every ~5minutes if a mute is expired

#

if you use beginning of the mute you need to add a value for duration

earnest phoenix
#

hm

lusty quest
#

i use something like this for removing expired Embeds from a LFG command i have

hidden lynx
#

Thanks! The error is gone now! But i'm not revceiving data in the database :/ Shouldn't the Guild.save() save a new document?

lusty quest
#

it should exept there is an error

#

check with MongoDB compass as example if there is any Document in the DB

hidden lynx
lusty quest
#

hmm there has to be somewhere something that goes wrong

hidden lynx
#
const mongoose = require("mongoose");

const guildSchema = new mongoose.Schema({
  _id: mongoose.Types.ObjectId,
  guildID: String,
  guildName: String,
  prefix: String,
});

module.exports = mongoose.model("Guild", guildSchema);

This is my schema

lusty quest
#

i dont think its the schema

#

i guess your query makes somewhere a error

hidden lynx
#

The strange thing is that im not getting the mongodb connected /error in the console

lusty quest
#

i think i know from where you got this and need to ask did you updated the connection options?

#

some stuff could be outdated

hidden lynx
#

nope xD. I'm fairly new to Mongo. But hey i found where the data got inserted

lusty quest
#

how is your connection string? does it end with /your_db_name?

hidden lynx
#

just thought the same thing

#

yep you're right. theres actually test in it. wtf am i doing xD

#

OMG its just working perfectly. Ty so much!

lusty quest
#

np

hexed lance
#

can anyone assist in troubleshooting my code for discord.py

#

my problem is that, the bot suddenly didnt want to register any prefixes

#

even if it is fixed

#

i suspect its something with the code below but i dont see anything wrong with

#

it

#

the least someone can help do is to check if everything looks correct