#development
1 messages ยท Page 1069 of 1
was the message sent in a guild?
ah I'm dumb
no your not
-
The issue may be where you defined
member(message.mentions.members.first();). You don't actually check ifmemberis not undefined (which it can be, as the message member could have mentioned no one). -
You seem to be checking a lot unnecessarily. You check if the message member has permission to kick members like 3-4 times.
@sudden geyser old code converted from v11 to v12, and yeah ik the code jumbled
@sudden geyser thank you
code what tempalate
why icant add mee6 to my discord
@woven rose this isnt support server of mee6
Yes @restive furnace
Code and HTML shouldn't be in the same sentence
Unless you're talking about code at the same time
use the description
^
description: 'whatever'
not sure that exists in discord.py
*cries in not being able to type fast enough to help*
ill check the docs thanks
Does somebody know why @cosmic surgejs-opus can't play audio on my windows sever? It's only on my windows server.
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.
what is the type of this {}
for example "" is String
10 is Number
true is Boolean
then {} what is taht
๐ In ๐ what ๐ context ๐
huh
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
@ember lodge we donโt offer support for other bots
Well then I guess youโll have to reread the docs
Mine works so itโs something wrong with your site
i already did and nothing, that's why i ask here
Is the php valid? Invalid php can cause the site to stop working completely
ahh I donโt use nodejs
I use php for my site
Youโll have to ask someone else
https://YxriDev.com/test/ is the site site Iโm referring to if you were interested
i am doing that but with nodejs using express and discord-passport
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?
@abstract crow we use express
@ember lodge Gotcha. So then do you work with an API to communicate?
it's a web server
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?
Gotcha
Does anybody know where I can create gifs without watermarks?
making them yourself
idk maybe with gimp
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()
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!
what do umean
the - is my prefix for example
?
This isn't a development question.
This isn't a development question.
or how i get it to reply
or how i get it to reply
@unborn haven yes...
english
@unborn haven hmm
Is there a way for a bot to count how many time a specific message has been used with discord.py?
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
Y
????????????????????
i already finnished all the coding for the bot i just want to publish it to top.gg but i need the bots prefix
?
whats the bots prefix?
Excuse me frends
You decide what your bot's prefix should be, lol
how
I
wdum
client = commands.Bot(command_prefix = '*')
ok i'll try
...
anyway can someone help me tho? ๐คจ

Is there a way for a bot to count how many time a specific message has been used with discord.py?
yes
ye
declare a variable and then just increment it when command was ran
Database
thank you ๐๐ผ
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
no
Can bots not use animated emojis?
They can
Why is not working then
I have an emoji called :WoosStaff: I did: <:WoosStaff:ID> and it doesn't work
Oh it needs an a?
Yeah
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
ok
Kill me please โฟ
what

that was the fastest edit ive ever seen
also why is ur language russain
or whever that it
Can you guys stop? if you don't need help with development then please move over to a different channel.
i did need help
Ok
Also, to answer your question, I don't think you are able to easily check who invited the bot
Okay
@earnest phoenix I have nothing to do on this server. So so, sorry) I'm going out now
I know there is a thing in audit logs for it, but I'm not sure if thats documented/implemented in any libs
Also your name seems very familiar
Probably from another server I Co-Own
Oh you're from Plexi
?
@earnest phoenix urban directory.
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.
ok
Hmm
im going to check npmjs
found this https://dev.to/nhighleysalongenius/comment/epgk @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
Spanish?
It is not a question
so?
couldnt you use a .then?
I get this error when starting the bot: ReferenceError: command is not defined
I'm still a novice at this
It means you tried to use a non-existent variable.
Okay. Thanks
How do find how many bots in server
"You must have a bot for that"
I literally have the bot dev role
Jesus
Chist
I found it anyway
Sorry. I do not speak English
hey, how can i make to show the user roles?
As well?
@uneven crypt for discord.js its something like
member.roles.map(role => //show role info stuff)
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)
-needdev @earnest phoenix
@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.
how do I change the background?
CSS
there's no option and making a div or anything like that just doesn't show
can you send me an example @misty sigil
let me send you what I did
idk much myself
just make a style tag
I did but where?
description
In the long description, use style tag and set a rule for .longdescription
here?
If you want to set your own div a background, give it some class and apply CSS to it
bruh
yeah
bruh
I have gone ahead and reworked how my database is being done, how would I go about getting a leaderboard this way?
https://i.callumdev.pw/jqb05.png
how can i make my bot run a function 5 times with a sleep of 30 secounds between the execution?
Will give that a go, thanks
i know a loop is a good
but i want a time between the executions
and a limited number or runs
I am using @cosmic surgejs/opus for my audio. Can I force my script to use opusscript for a specific command?
@low marsh no you shouldn't not and you can't either so just don't
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
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..?
Check the source html, there's probably a toggle
Right click the button and inspect, check the ID
Blah blah blah
hello
Hi
my discord bot is finished ๐
Nice
๐ bot is online!
ok
how can i make it send a message to a voice channel when someone donates on patreon ๐ฉ
use their api
okay
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?
check thier docs
get some packages?
Of course, I already check the google api doc..
ok sy
^^
anyone a idea how I delete the last 3 messages the bot sent ?
get the messages in cache and filter them
or that
Read the docs
bruh I hate discordjs 12
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.
heres my code: https://pastebin.com/smNeGdkz
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
like i said
I didnt realize how garbage my free hosting was
my bot does like 5 things
discord.js latest vsrsion
Do you have an eval command?
i do not
hmm
@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
let me make sure
@earnest phoenix still having trouble with your hosting, i know another good hosting
@earnest phoenix dms
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
ok now when i try to install canvas i get this error:
"user": [
{
"id": 1,
"Name": "Choc Cake",
"Image": "1.jpg",
"Category": "Meal",
"Method": ""```
Someone know how to get data in the json array?
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
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).
like just to see the members in the server on the embed thing on the invite
What library are you using?
discord.js
version 12.2.0
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).
ok
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
it would be against tos as it is a privacy breach
Hi
Can someone help me with Guilds code
my bot replies to slow
When I use my Stats command
show code
why haven't you upgraded?
ok, show the code
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
you said that the command is slow
Yes
you'll have to figure out what part of that code is taking a long time
are you sure it's your code and not your computer or anything else?
it's your friend's code
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
Thats why its slow because Its gathering information?
probably
Ty
tip
users generally don't care about technological stats
omit that info because you dont need to provide it in the first place
they generally dont understand it at all
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}))
})
try using .findIndex(), which accepts a callback
ok thanks
.indexOf() doesn't work because it compares elements with strict equality, the same one used when you type ===
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 you can't make a bot app?
i did make one
so what's your problem
down it says not Not affiliated with Discord
that is just the site to get the invite link for your bot easier
look at the bottom bro
the Red line marks the Spot
i did
did you enter the client id? and not the bot ID?
the client ID
then it should work
wait let me check
btw would re generate the token now
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 ๐
the reddit API returns isVideo in the json. and the image as a different key.
oh, so what should I edit exactly to pull the image and not pull a video
Sorry i'm not super great with APIs
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
Oh okay, what's a json path finder?
I pasted the url, and I can see how its tough to read lol
i use jsonpathfinder.com
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
oo okayy
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
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
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
ohh okay, well once u check if its a video, and it returns true
what do u do, do u fetch another one?
?
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
i just return. but i could use a function and run it again until is_video is false
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
ohh now i see what you want. its simple i just skip the ones that are videos and return a different one instead
oh can you show me how to do this?
Sorry as I said, I havnt worked with APIs that much
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
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
i havent seen the error since ive made the command
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
ah okayy
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
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
if you remove the = before randomInteger it could work
but this will only work for the first post on the page
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[]?
const image = content.children.filter(post => !post.data.is_video);
const randomInteger = Math.floor(Math.random() * image.length);
const imageURL = image[randomInteger]
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
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
the .data was from my code for me was my json from the API = data
hey, whats the permission for .setNickname? manage nicknames only? cause i'm getting the missin gperms error
Why does Cloudflare https doesnโt work on my website? I have CloudFlare but it doesnโt work with https just with http
did you got a SSL Cert installed on the server?
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
what is the issue?
i dont think this is a valid syntax
i would rather save the warns in a user profile with the GuildID as key
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
this looks like a GuildConfig
yes it is
i talk about a userprofile
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
fetch the user its possible its not cached
how am i able to make a setting where the user can change what the muted role is
me?
@earnest phoenix your user is probably not cached
Pretty sure you have to use webhooks a to get votes they why you want
it still didnt log the vote in console
@white drum store the role into a database and call it for settings the mute role
@earnest phoenix is your webhook running?
im not running a webhook
Thatโs why
k
._.
For you to get the vote you must use a webhook
the Docs have a explanation
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');
});
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]
@earnest phoenix https://mongoosejs.com/docs/subdocs.html this maybe helps you
how does this look
dude i am done
imma use Json
lol
understandable
@earnest phoenix try eval message.author.username
it is better
wdym
@earnest phoenix ```javascript
const guildSchema = mongoose.Schema({
guildId:String,
autorole: String,
enable: Boolean,
warn: [
{userID:String ,warnTimes: Number,lastReason: String}
],
})
findOne?
then just the userID?
or use sub documents https://zellwk.com/blog/mongoose-subdocuments/
Learn what are Mongoose subdocuments, and how to create, find, update, and delete subdocuments.
DM ADS and Announce @leaden lava
-_-
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 \
replace \ with \\
ahh thx
just read the dam docs. i never used it and just read the docs
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
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
process.env.dbltoken ?
'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
me 2
add , client after the array for autoposting of the Servercount
hard coded it for testing purposes
just use a env variable for your creds?
thats not the problem here sir
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });did you see the difference?
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' },client);for autoposting your Guildcount
the guild count is posting
sure i just add it usually bcs its usual a question that arrives after the webhook is running
?
like
its just the port where the Webhook is running one
so it can be anything?
the port needs to be free
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})
ok
How would i make my console app take input?
@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
so i can use simple guild.warnTimes
?
@lusty quest
@earnest phoenix ur prlem
@earnest phoenix depends on how you return the db
did i do the what now
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
where do i add it at
on your Top.GG Bot page
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
then use sub documents
replace the ip with your ip
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
you still get a IP
it didnt log one
i dont have a ptrodactyl installation rn to show you where to get the ip
but you get one
idk
did you installed the panel?
Hey
i didnt install it
I have a question
you need the ip otherwise the webhook will not work
or get a open port for the domain
djs?
djs?
@restive pebble discord js yes
get the id from cache
I hot id
and use .leave()
but how can i get the ip
Just make command paste id?
ask the guy who host the panel
client.guilds.cache.get("id").leave()
@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
either eval it or paste it inside ur index file
client.guilds.cache.get("id").leave()
@restive pebble is that v12?
I got id
oh
or he's english is bad
so this means he want to leave several servers
@tight plinth yes actually)
not foreach
forEach
map
or he's english is bad
@tight plinth sry My country does not associated wirh english language
np
Hmm
you know how to do forEach loop, don't you?
yes
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 
does that look right
Is that IP real
And what made you think it's a good idea to post it in a 100k members server
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
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);```
the object will still be defiend
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()
I am not sure
you can also try it and see
you can also try it and see
@pale vessel did you mean https://tryitands.ee
It will be removed
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)
}
do you mean from the string?
so you want to remove the first 4 characters?
the --bio
const getRidOfIt = str.slice(4);```
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?
How can I customize prefix for people in their own servers
Oh
If you want local storage use quick.db
Yes Iโm using .js
that doesnt help
but k lol
id: guildID,
prefix: "!"
}```
use quick.db its os simple
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
ok
I think bio is the string where you want to slice 4 chars from
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
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
str.replace("--bio", '').trim();
@earnest phoenix why would you do that if slice(4) does the same?
that works too
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
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
code readability is usually more important than performance to a certain point
that is completely false lol
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
being a good coder is being able to do both at the same time
@quartz kindle being code913 is being bread brain
๐ === ๐ง
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
Wtf is shards
there are two ways of sending guild count
- send all at once from a single shard or master process
- send individual counts from each shard
option 2 is much easier
if you use the dblapi.js autoposter, it will do option 2 for you automatically
im trying to make multiple raction roles in one message
Yeah I am, so thx
\๐ฅ
and I printed payload.emoji it gave me "red_square"
default emojis dont use names
with the :
they use their unicode version
unless dpy does something to them
both should work
oh ok
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?
@autumn summit i checked the d.py docs, it seems the correct way is payload.emoji.name == unicode
@true ravine does their api support sharding?
show their docs
they dont seem to support sharding
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
But there could be a chance that not all shards are ready?
the sharding manager gives you information on when they are all ready
Oh really? Okay I'll have another look
if (bio.content === "none") {
await bot.db.collection("Profiles").deleteOne({"User_ID": user.id})
}
``` somethings wrong i can feel it
Thanks
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
**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);
}```
But yeah I'll do that thanks
Could anyone help me please.
I define it on the main.js or the guildMemberAdd.js
guildMemberAdd.js
Yes
Thanks ๐
or just use member.guild.me directly
I got another error.
ReferenceError: member is not defined
where
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```
where did you put it?
in the guildMemberAdd.js
show
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);
}```
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
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
so that i define the const guild = member.guild inside of module.exports?
yes
Thanks
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)```
is it defined as a guildchannel or a text channel?
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);
}```
are you using v11 or v12?
How could i check it?
npm ls discord.js
discord.js@11.6.4
I have installed V12
@pure lion your break there is invalid
So How can i fix it? I have update Discord.js to V.12
i advise
if you updated to v12, then you have a lot of things to change
unless you dont want a bot in a few months
Yea, There is nothing i need to change
I have check it all. There are nothing i need to change'
dont we all
its not a thing
it's .play
because you copypasted code that is not for v12
Whats a good way to make a mute command
Without setTimeout because bot may restart etc
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
how do i add pages to eval
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
how to check if a user is on desktop webclient etc?
@rigid maple how to make an antispam?
Module
Whats a good way to make a mute command
@earnest phoenix
Use database.
I meant how I can enforce the timings
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 :)
Hmmm.
@hidden lynx You can use double ``` to wrap that error message.
@hidden lynx could you show your schema and your query?
I meant how I can enforce the timings
@earnest phoenix
Loop can be possible, but it's kinda unoptimized.
Try do more research.
bad when it's scaled
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;
Yeah, ik. It's unoptimized.
Probably people won't bother a few minutes interval though.
@hidden lynx use this in your query mongoose.Types.ObjectId()
But I will do more research.
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
hm
i use something like this for removing expired Embeds from a LFG command i have
Thanks! The error is gone now! But i'm not revceiving data in the database :/ Shouldn't the Guild.save() save a new document?
it should exept there is an error
check with MongoDB compass as example if there is any Document in the DB
There is literally nothing in the console and nothing in the compass either:
hmm there has to be somewhere something that goes wrong
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
This is my connection. I'm initializing it in the index file on the left
The strange thing is that im not getting the mongodb connected /error in the console
i think i know from where you got this and need to ask did you updated the connection options?
some stuff could be outdated
nope xD. I'm fairly new to Mongo. But hey i found where the data got inserted
for some reason it created another database called test and put the data in there:
how is your connection string? does it end with /your_db_name?
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!
np
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


