#development
1 messages · Page 1004 of 1
we know
you want to find its index?
Yea
still passing
.findIndex
my one still isn't finished 
you need to find 2 indexes then
Where can I host my bot 24/7 of BDFD (Bot designer for discord)
Is that a plain function @cinder patio
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex or .indexOf if it's a primitive value
yea
Where can I host my bot 24/7 of BDFD (Bot designer for discord)
Oh lemme see
@plush oar idk, nobody here uses bdfd
Though you'll have to create your own to get multiple indexes like Tim said
my one is still cloning F
@plush oar please dont spam your bot invite here
btw on my bot when u say !order ill give you a peak what happends
its not the appropriate channel
or server
with photos
lol
bot designer for discord bots can only be hosted on their platform, which you top up by viewing ads
you cant take them away and host them anywhere else
REEEE
theyre in a bespoke programming language... if you can call it that
thats why i said nobody here uses bdfd lol
:0
dude
How to fetch a message with cycling thru channels
lol ignore the 3 and the £
@plush oar you probably should not make a fast food delivery bot tbh, tons of works with little reward, there is already a big bot that does this and discord likes to flag down users that join servers too quickly
what does it even do
a user places an order, the mods of the bot go to that server via an invite to "deliver" an image of some food
lol wut
yeah, i dont get it either
bruh
tf
do u not know "roleplay"
sure, but this is a lot of effort to roleplay being something you can get paid for irl
heard of it, but i dont practice it
for me roleplay means loading up skyrim or fallout 4
or at most, getting out some dice
😄
Oh good you didn't say 76
of fork no
76 can do one
i never even bought it
actually just bought no mans sky today on steam summer sale, 50% off
apparently its better now (nms) now the fuss has died down and theyve patched it
how can i make a script to start both folders at the same time?
like in the package.json scripts thing
you don't "start" folders
if it was me, i would have dashboard and bot as completely separate repositories, in separate accounts, just sayin'
lol idk what to put as my long desc on my BOT on https://top.gg LOL
yeah, they are
I have them as different branches, not sure if that's a good idea
@plush oar think keywords that will get you listed in searches, "delivery", "roleplay", "fast food" etc, and maybe say something like "better than <competitor bot name>"
that way anyone searching for <competitor bot name> gets your bot in their results
i mean something like
wtf
how can i make a script in a package.json file to start everything at once, what i do now is open 2 separate consoles ( because its beta ) and run it separately
in the main property
uh
the file contans: json { "scripts": { "start": "./" } }
to bth files
You can do this using node or batch
or a bat file
bat file sounds easiest to me
one option is to use pm2
no, your bot is awaiting approval @plush oar
That's because of FS, not sure how the thing's called but
i dont want to use pm2 as it takes too much memory
Ah,
@digital ibex that happens because when you start your a process from another folder, all relative paths will be based on where you started the script from, not where the script is located
thats what happens with the dashboar dwhwn i try to start
oh
how can i change that?
like make it not error
yeah provide absolute paths using __dirname
o ok
Or
i done ```json
{
"scripts": {
"start": "node __dirname ./bot/src/bot.js & nodemon __dirname ./dashboard/src/app.js"
}
}
that's not how that works I dont think
wait for the bot i get Error: Cannot find module 'C:\Users\Aneesah\Desktop\Lost\__dirname'
oh
No you use it in your code,
fs.something(`${__dirname} + relative path`)
^^
put that in the package.json file?
oh
pm2 has a cwd option to set the base directory from where to start the process in, idk about nodemon
wait you're using npm to start
fs.readdirSync(`${__dirname}./commands/`)
``` i was doing before: fs.readdirSync('./commands'); btw
so it would be like that?
You'll want to remove that dot
oh ok
I'm trying to get information out of a Json api. The website is using cloudflare.
my code to request :
request('https://corporateclash.net/api/v1/districts.js', { json: true }, (err, res, body) => {
APP CODE
});```
error code :
```json
'cf-error': 'user-agent not supplied.'
how can I supply a User-Agent ?
package used : Request
Discord.js
you can set a user agent in the headers
and how do I know what user-agent do I need?
you dont
you can supply a random user agent and see if it works
if it doesnt, try using a browser-specific user agent
for example copy and paste google chrome's user agent
wait, this could mess my paths up right? because im hosting it on my pc, windows, where my host is a linux?
or won't it do nothing
request('https://corporateclash.net/api/v1/districts.js', { json: true }, headers: { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0" } (err, res, body) => {
like that?
yeah
I think you're missing a comma
si
oh gotcha
s
it work ty @quartz kindle!
what xd
Nvm
idk how to skip
add a filter before the forEach
^
guilds.cache.filter(g => check if it has permissions here).forEach()
@quartz kindle can u tell me bcs idk xd brain dead
8 hours trying but in clieant.on(ready)
idk how
client*
no...
you dont know how to check permissions?
g.me.permissions.has ig
^

sighs im not allowed to spoonfeed so sorry :/
¯_(ツ)_/¯
Has is a method
On the docs it explains the method has
^
you gotta specify which permissions you wanna check for lol
bro rlly idk how can u edit the code for me pls if u have time
code is not smart, code is very stupid actually, you need to tell your code EXACTLY what you want, it cant guess for you
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});```
xd
also that extra .cache there is wrong
no offense but did you take this code of a git rep?
Then under methods, click has
i use commando's member arg off the git try doing that :/
Not what I was looking at
how can I make this an async function
client.queue = new Queue(function (input, cb) {})```
i think
async function
lol i figured it out
lol
big brain time
lol
how would i, in discord.py generate an image with text on it and send it
Tkinter is quite decent
any idea how I can make my userinfo command respond to names and nicknames
i can use tkinter for that?
depends on what you want to do
i wanna send a black image with text on it using a custom font
yes
its telling you right away what it error'd
M I S S I N G P E R M I S S I O N S
I gave you the page explaining how to use has
but idk how to skip guilds who not give permission
check for perrmission and send when it does
if(perm) do
i dont see whats the issue
what are you even trying to do]
cant fetch invites
Your using has wrong
why does your bot need invite perm
ping me if anyone has any ideas bout my problem
invites uses
why is your bot logging all guild invites when it starts?
.......
i have aboslutely no idea how 50% of people here managed to get bot developer role
So you don't know why you are writing what you are?
same @opal plank, same
Code from github @opal plank
I don't even know how I got here
copy pasting code isnt developing
maybe because I made an actual bot.

i made two actual bots owo
having a basic bot that works is enough to get approved
i see that
otherwise this website would have 10x less bots in it xD
im just tryna figure out new libraries
learning and getting experience
cant figure out the PIL library tho, can't seem to save a file
i dont use py sorry
im gonna end it here cuz this is getting offtopic, but still quite a shame to see this many people not knowing a lang
any idea how I can make my userinfo command respond to names and nicknames
js?
yea
nah, i was thinking plain text
name => fetch cache name
mention => regex <@!
id => copy this
isNaN for id
regex for mention
everything else try cache
aight

I think ima do a study on people asking for help here.
Give people the docs for the question they ask, if they don't understand still, I'll copy paste the example code from the doc and give it to them
If they magically understand the exact same code just when a user says it, they are a help vampire
and if they dont understand still?
if they tried it, then give a bit more help
^
spoonfeeding creates vampires
post garlic emojis to send them away
I'm just going to be copy pasting from docs
try and error and problem solving are skills required to be a dev
@opal plank mom allso did spoon feeding
is you vampire then?
soorry for offtopic
So uhh im new at making bots at C# using DSharp, I managed to get the bot latency using cmContext.Client.Ping, cmContext being CommandContext. How would I get the message response time?
holy shit @quartz kindle I did it... https://cdn.vurighosting.com/u/2RkSxl.png
A queue? 
nice
it finally works
@potent dust message response time is usually obtained by manually measuring it
for example, get the current timestamp in milliseconds, and save it in a variable, then send the message
it even says when the queue is empty https://cdn.vurighosting.com/u/dYT04o.png
once the message is successfully sent, compare the saved timestamp to the current timetsamp
@solemn latch yes I added a queue because of the virustotal api limits
its 4 requests max per minute
which also means i can add queue priority heh
what if your queue grows faster than it resolves? lmao
imagine using your command and being told there are 3765 requests ahead of you in the queue
o god
could somebody help me make a bot pls pls!
well i hope not but it shouldnt be a problem because its all in a database so it should get through it even if i restart it
In a sharded mongodb cluster for a statistics bot with lots of user data, should i make
a) 1 guild collection, that contains all the data in arrays, including roles,members,channels and big statistics arrays textmessages,voiceminutes,...
b) 1 collection per all of these entities
also note i have to do lots of calculations on the data.
I would add a check if there's more than x things in the queue, dont add it to the queue
something like that
If you think users will wait that long
i mean it does say that its queued im gonna add a command to see your position in the queue too
Hello guys
Since you probably know the time exactly how long it'll take you could add that
thats why it gives the user their queue ID
it's like 1 request per 20 seconds
which is shit
but i cant do anytrhing about that
60/4 is 15
15 seconds, if your 7th in queue it'll take 15*7 seconds, which will give users the estimated time
idk how to like handle votes tho
once the message is successfully sent, compare the saved timestamp to the current timetsamp
Oh alright, im not so new to C# but I am for DSharp. Will try out doing that, thanks!
thats my problem
In a sharded mongodb cluster for a statistics bot with lots of user data, should i make
a) 1 guild collection, that contains all the data in arrays, including roles,members,channels and big statistics arrays textmessages,voiceminutes,...
b) 1 collection per all of these entities
also note i have to do lots of calculations on the data.
the api makes it simple
I managed to get the queue working because I am rewriting the whole of the scan command
it will look so much better after
it will also be a lot more reliable
the current one works most of the time
this one should have a really low fail rate
i need to test if the queue keeps going even if i restart
it doesnt
i can just add a queued restart so it restarts next time the queue is empty
Hi, I want to do that when someone type "Meme" in chat, it'll show random meme from sitehttps ://www.memedroid.com/ and I can't figure how to do that. Even google don't have anwser.
in javascript
if you did that it would get muted in 99% of bot lists
wdym?
Ideally it should be a command, not just the word meme
hello guys
i have made a bot
i need a code to set his status as listening
not streaming or anything
can any one help me ?
Ideally it should be a command, not just the word meme
ik but for this moment I need it as world meme
@obtuse jolt thank you bro
damn i actually need to add the scanning part to it soon
thats gonna suck
i need to finish this command first tho
Hi, I want to do that when someone type "Meme" in chat, it'll show random meme from sitehttps ://www.memedroid.com/ and I can't figure how to do that. Even google don't have anwser. I'm doing it in javascript
why cant you just use reddit or something
and its funny because theres a lot more results if you just use something like reddit
How do you create a levelling up system?
no pls dont
they are so annoying
What are?
levelling up bots
How do you create a levelling up system?
@marble scaffold on yt are a lot of tutorials
You spend like hours to do the code
you can always see github ready rojects
usually people do to flex on other devs that their sound quality is better
make your own ones
discord js
var limit = getRandomNumber(0, 3)
console.log(limit)
var hugUrl;
var response = await fetch("http://api.giphy.com/v1/gifs/search?api_key=[api]&limit=3&q=hug")
.then(res => res.json())
.then(res => res.data[limit].url)
console.log(hugUrl)
const embed = new MessageEmbed()
.setImage(hugUrl);
message.channel.send(embed)
how can I have it so that hugUrl is res.data[limit].url)
music bots are pretty easy to make

music bots are pretty easy to make
ya

My first discord bot was a music bot
If you have a slightest idea of what you are doing, anything is, honestly
i just refactored this one music bot script to work with my framework is all
very very easy stuff
help


discord js
var limit = getRandomNumber(0, 3) console.log(limit) var hugUrl; var response = await fetch("http://api.giphy.com/v1/gifs/search?api_key=[api]&limit=3&q=hug") .then(res => res.json()) .then(res => res.data[limit].url) console.log(hugUrl) const embed = new MessageEmbed() .setImage(hugUrl); message.channel.send(embed)
how can I have it so that hugUrl is res.data[limit].url)
hi
hi
it looks like response is res.data[limit]url
ya
so you'd need to do something like let hugUrl = response
stupid question, should you await database inserts/selects
doesn't usually matter
I mean, if you are getting stuff from it, yeah
but inserting.. up to you
music bots are pretty easy to make
@strong tundra You say that, but it does depend on the quality
Can u do .includes on an array?
Yes
literally just wasted all of my data doing this but it works! https://cdn.vurighosting.com/u/y5tXIZ.png
sd
So like, I want to send a message on the channel if a parameter isnt specified on a command. The thing is that I know how to send the message but I dont know how to verify is the parameter is null, I already tried doing a if statement to see if it is equals to null but it seems like it doesnt work
here is code for reference
(DSharp)
can someone help
i made a bot on py
it works
im tryna host on heroku
and get this error in cmd
error: update_ref failed for ref 'refs/remotes/heroku/master': cannot lock ref 'refs/remotes/heroku/master': unable to resolve reference 'refs/remotes/heroku/master': reference broken
Everything up-to-date
i reinstalled heroku clia
cli
checked update
and everythin
hi again, I need help woth "meme" command. When I'm typing in chat "meme" (what is correct), it isn't showing what it have to show. No errors in chat and terminal.
client.on("message", message => {
if (message.content === 'meme') {
exports.run = async (client, message, args) => {
try {
const { body } = await snekfetch
.get('https://www.reddit.com/r/dankmemes.json?sort=top&t=week')
.query({ limit: 800 });
const allowed = message.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
if (!allowed.length) return sg.channel.send('It seems we are out of fresh memes!, Try again later.');
const randomnumber = Math.floor(Math.random() * allowed.length)
const MemeEmbed = new Discord.MessageEmbed()
.setColor(0x00A2E8)
.setTitle(allowed[randomnumber].data.title)
.setDescription("Posted by: " + allowed[randomnumber].data.author)
.setImage(allowed[randomnumber].data.url)
.addField("Other info:", "Up votes: " + allowed[randomnumber].data.ups + " / Comments: " + allowed[randomnumber].data.num_comments)
.setFooter("Memes provided by r/dankmemes")
message.channel.send(MemeEmbed)
} catch (err) {
return console.log(err);
}
}
}
});
snekfetch is deprecated iirc
node-fetch is the current one
(i litteraly use the same command and fixed it and updated it to the current stuff)
const { data } = await fetch('https://www.reddit.com/r/memeframe.json?sort=hot').then(response => response.json());this is the same but using node-fetch
(i litteraly use the same command and fixed it and updated it to the current stuff)
@lusty quest what do you mean?
oh
also why did you just copy/pasted the command. it will not work
quick question:
if I make a command holder will this work? and how do I use my image feature? do I add all the code for (PREFIX + "image") to the command.js file or do I keep the code in the main file?
name: 'ping',
description: "this is a ping command!",
execute(message, args){
message.channel.send('pong!');
}
} ```
depends on how the command handler is coded
this above is the command handler
client.on('message', message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping'){
client.commands.get('ping').execute(message, args);
}
});
this is the handler
yes but for a single file execution
? wdym?
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
yes this is the handler
I understand
you can actually handle the prefix in a message handler
?
something like this
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
const cmd = client.commands.get(command);
if (!cmd) return;
``` (its incomplete)
do I replace that with:
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(./commands/${file});
client.commands.set(command.name, command);
}
?
no
both work together
the command handler loads the commands and the message handler executes them
do u NEED the command handler or is it optional?
its way cleaner if you have one
do I add it here
nice side bar
it needs to run in the on message event
and like i said its not complete and copy / paste will not work out of the box
oops I have 2
bot.on('message', message=>{
and this for this
bot.on("message", function(message) {
var parts = message.content.split(" "); // Splits message into an array for every space, our layout: "<command> [search query]" will become ["<command>", "search query"]
/* Simple command manager */
if (parts[0] === "b!image") { // Check if first part of message is image command
// call the image function
image(message, parts); // Pass requester message to image function
}
});
^the image command
you dont need the command handler in there
since you have then 2
if everything works fine you have your image command in a extra file with the function
I can just add this
var parts = message.content.split(" "); // Splits message into an array for every space, our layout: "<command> [search query]" will become ["<command>", "search query"]
/* Simple command manager */
if (parts[0] === "b!image") { // Check if first part of message is image command
// call the image function
image(message, parts); // Pass requester message to image function
}
to ```bot.on('message'blablblalblabllba````
idk what you plan to do, it feels like you just Frankenstein a bot together
I plan to build a command handler
and yes Im making the most random command bot ever
yes but everything in the code is Random. like you search on Github for Node.js Bots and just copy/paste commands out of it
no I dont
but it feels like this. bcs the style is for some reason different every time you ask here
I get alot of information online though
i have nothing against it but you dont get some connections between stuff right
I do
bot.on("message", function(message) {
var parts = message.content.split(" ");
blablabla```
I was stuck here (like really stuck, took me 4 hours to get this lmao and I asked discord multiple times) and used a pastebin that someone made ¯\_(ツ)_/¯
I dont like to copy
but I was done with wasting my whole day
what does this part should do?
? thats not correct english
but ok
ill try to explain
/* Simple command manager */
if (parts[0] === "b!image") { // Check if first part of message is image command
// call the image function
image(message, parts); // Pass requester message to image function
``` this part takes the 1st agrument from !image so the 1st argument would be **cookies** here: b!image **cookies**
it chages the function image(message) some part of this function here: ``` var options = {
url: "http://results.dogpile.com/serp?qc=images&q=" + search,
method: "GET",
headers: {
"Accept": "text/html",
"User-Agent": "Chrome"
}
}; ``` It changes search to the 1st argument and the api will search and randomly pick an url and send
message.channel.send( urls[Math.floor(Math.random() * urls.length)]);
@lusty quest
disclaimer: this is what I see and the explanation is probably shi
am I correct?
hello guys
can you give me antispam code ?
We don't spoonfeed code in this server
@quartz kindle @solemn latch it workssssssssss!!!!! https://cdn.vurighosting.com/u/BmD31a.png
virus total discord bot
A virus total bot? Thats pretty sick
i just added a feature that queues files and urls for scanning instead of spamming the api
its taken me ages
but it looks AMAZING
does it scan the file/links for virusses?
yeah
Which library did you make it in?
thats cool
yeah i'm just waiting for it to be approved into here
its been accepted into 1 so far
its taking ages
no denies tho
just taking ages
im really excited to release that update its a prototype at the moment
im still making it
does someone knows how can i log the user that deleted the message?
ngl that is pretty awesome,
ive so far only finished the url scanning
.addField(`Deleted by:`, what i need to put )
but its getting done fast
if someone sends me a sucpisious link
@knotty sigil there isnt 1 line you have to call the event then log it
Yeah
thats exactly why i made it
so that people could scan sketchy dm links
and files
Yeah I can actually see use in it, opposed to most of the bots I make being based around pure bullshittery
if the owner deletes the message, there isnt any event log. but if someone else deletes it, it will create an entry in the event logs, so you need to fetch event logs to get it
im hoping once it gets into here it will start to get servers because its only in 9 rn
@obtuse jolt can I use that for my server?
Ill add it to my server if you've got an invite?
ur bot?
just dm me an ivite link
i dont think i can send it here
.addField(`Deleted by:`, what i need to put )
@knotty sigil https://www.reddit.com/r/Discord_Bots/comments/779sa0/how_do_i_log_deleted_messages/?utm_source=share&utm_medium=ios_app&utm_name=iossmf also make sure you read what Tim said ^^
@knotty sigil you need the deleted message log ?
but if i do author.tag it will show the one who made the massage and not the one who deleted it @hoary elm
@knotty sigil try this but you need a room with name log
client.on('messageDelete', message => {
if(message.author.bot) return;
if(message.channel.type === 'dm') return;
if(!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
if(!message.guild.member(client.user).hasPermission('MANAGE_MESSAGES')) return;
var logChannel = message.guild.channels.find(c => c.name === 'log');
if(!logChannel) return;
let messageDelete = new Discord.RichEmbed()
.setTitle('**[MESSAGE DELETE]**')
.setColor('RED')
.setThumbnail(message.author.avatarURL)
.setDescription(`**\n**:wastebasket: Successfully \`\`DELETE\`\` **MESSAGE** In ${message.channel}\n\n**Channel:** \`\`${message.channel.name}\`\` (ID: ${message.channel.id})\n**Message ID:** ${message.id}\n**Sent By:** <@${message.author.id}> (ID: ${message.author.id})\n**Message:**\n\`\`\`${message}\`\`\``)
.setTimestamp()
.setFooter(message.guild.name, message.guild.iconURL)
logChannel.send(messageDelete); ```
spoonfeeding at its finest
Indeed 
this is what you should probably tell them. Check MESSAGE_DELETE event emitted and see the snippets in the example using it
I mean what I sent was pretty much the same explanation just via Reddit
always send them docs
docs is your trusty source of information for anything you do coding wise
if they cant read the docs, then give a more summarized explanation, but coding without knowing how to read docs is a huge set-back
Don’t really need to explain that to me 👌 but yeah I understand
how can i add invite logs (with invites counter and inviter) plz ?
Is there a solution to reduce the API
how can i add invite logs (with invites counter and inviter) plz ?
@trim burrow database
how can i add invite logs (with invites counter and inviter) plz ?
@trim burrow fetch the invites and store them in.. an object or database or something of the sort there should be a detailed guide for it around somewhere just look on google
Is there a solution to reduce the API
Reduce what
Yeah what about the API
You don't "reduce" an API
what does that even mean
There is pressure on it and the higher the API compression, the bot is restarted @slender thistle @hoary elm
So "reduce the load on the API"
Explain more @slender thistle
I wish I myself understood what you are asking
but well, ratelimits sound like what you want
😂
such thing as reducing an api does not exist nor does it make any sense
... unless it means "reducing the amount of functionality an API provides"
which doesn't not make sense
yes
True
I mean is there a solution to reduce API consumption
If it's your API - implement and enforce ratelimits
If it's an API you use - enforce local ratelimits, either through local limit or dynamically
Hi! one question
I am making a command handler
if I want to make an command that sends an embed do I add the embed code
.setColor('#d29e04')
etc.```
to the commandname .js
or do I leave it in bot.on('message', message=>{
everything on the code will be on the command file
aka the commandname.js
on your index.js you'll only execute the file(which contains the code)
ah I get it
:))
@knotty crane Firstly, no. Secondly, no. Thirdly, no.
As for the rest of the reasons, wrong channel and that's not true
Some one told me that is true sorry
To say nicely, that's complete... bullshit
Please refrain from spreading such messages in the future
Thank you for understanding 👍
so just making sure @opal plank the commandname.js will be:
name: 'ping',
description: "this is a ping command!",
execute(message, args){
let botping = message.createdAt - new Date()
let apiping = bot.ws.ping
const embedping = new Discord.MessageEmbed()
.setColor('#d29e04')
.setTitle('Ping :banana:')
.setAuthor('Banana')
.setDescription(':ping_pong: Pong!')
.addField(`blablabla`)
.addField('ur dinner today', 'bananas', true)
.setTimestamp()
.setFooter('Justii :3')
message.channel.send(embedping);
}
}```and it would send the embed?
if I execute it
I need a little help. . .
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\catra\OneDrive\Desktop\my discord bot> npm install
npm WARN my-discord-bot@1.0.0 No repository field.
audited 15 packages in 1.991s
found 0 vulnerabilities
PS C:\Users\catra\OneDrive\Desktop\my discord bot> node .
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'dotenv'
Require stack:
- C:\Users\catra\OneDrive\Desktop\my discord bot\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at Object.<anonymous> (C:\Users\catra\OneDrive\Desktop\my discord bot\index.js:1:1)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
{
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\catra\\OneDrive\\Desktop\\my discord bot\\index.js' ]
}
PS C:\Users\catra\OneDrive\Desktop\my discord bot> npm dotenv -v
6.14.5
``` this made no sense.
does this use an api?
Cannot find module 'dotenv' probably something wrong in ur code
:P
@pine bear npm i dotenv
i forgot how to fetch a channel out of a guild category
Hi, is there any way to get all members status (lik: online, don't disturb and idle) to one count?
I have this but I can't find thing what will add users with these status into one count:
const totalOnline = fetchedMembers.filter(member => member.presence.status === 'online');
const totalIdle = fetchedMembers.filter(member => member.presence.status === 'idle');
const totalDND = fetchedMembers.filter(member => member.presence.status === 'dnd');
const totalOffline = fetchedMembers.filter(member => member.presence.status === 'offline');
npm i --save dotenv*
category.children.get() right?
Making everything on index.js is bad? Like everything in only one file, all commands and such. If so, I'd like some explanation of why
okay, not I gotta get a correct token
@lusty quest can u check my message above catra c'yra s message?
Making everything on index.js is bad? Like everything in only one file, all commands and such. If so, I'd like some explanation of why
@potent dust why not all commands in index.js file?
Why does this return an Object is possibly null error?
if(!prefixes[message.guild.id]) {
prefixes[message.guild.id]
}```
Hi, is there any way to get all members status (lik: online, don't disturb and idle) to one count?
I have this but I can't find thing what will add users with these status into one count:
const totalOnline = fetchedMembers.filter(member => member.presence.status === 'online');
const totalIdle = fetchedMembers.filter(member => member.presence.status === 'idle');
const totalDND = fetchedMembers.filter(member => member.presence.status === 'dnd');
const totalOffline = fetchedMembers.filter(member => member.presence.status === 'offline');
@potent dust its not bad just can end be pretty inefficent, You will get spagetti code at one point
it's cause prefixes may be null, check if it's null first
Oh alright, its bc my friend is doing that and I just couldnt explain why it is kind of unorganized
Here I define prefixes: js let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"))
You're using typescript right?
Correct
Define an interface for the object
ok
why am I getting an error here?
You're missing a } after your if
interface Prefixes {
[key: string]: Object
}
let prefixes: Prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"))
alr thanks
@sudden geyser no im not
How so
or am I blind
You are blind
Hi, is there any way to get all members status (online, don't disturb and idle) to one count?
I have this but I can't find thing what will add users with these status into one count:
const totalOnline = fetchedMembers.filter(member => member.presence.status === 'online');
const totalIdle = fetchedMembers.filter(member => member.presence.status === 'idle');
const totalDND = fetchedMembers.filter(member => member.presence.status === 'dnd');
const totalOffline = fetchedMembers.filter(member => member.presence.status === 'offline');
That }); at the bottom should be assigned to your bot.on message
It still turns up with the "object is possibly null" error
Cnnn, you could use one for loop
@worn niche put .size on the end of each?
I am using repl which is buggy atm, imma see if anything happens in vscode
Refresh the page
I already did
alright then try with vscode
ok
or just do if (prefixes && !prefixes[...]) {...
@worn niche put .size on the end of each?
@tepid canyon I have other fetchedMembers.filter for doing all avaible members, what should I do?
All the members in the guild?
yes
You don't need a filter for that
I mean all users with status online, idle, dnd
into one count like:
All avaible members:
all avaible memers
const totalAvailable = fetchedMembers.filter(member => member.presence.status !== 'offline').size;
what is happening?
install discord.js
did you deleted the node_modules folder?
const totalAvailable = fetchedMembers.filter(member => member.presence.status !== 'offline').size;
@tepid canyon I'll try
yes
const totalAvailable = fetchedMembers.filter(member => member.presence.status !== 'offline').size;
@tepid canyon it says: undefeined
aaaaaaaaaaaaaaaaaaand it still shows the object is possibly null even in
even in vscode
does it work for your other 4 where you filter online/idle etc @worn niche
because if it doesnt work for that it most likely aint working for the other ones then
does it work for your other 4 where you filter online/idle etc @worn niche
I'll give ss here
ok
Code:
client.on("message", message => {
if (message.content === "SMChecker")
message.guild.members.fetch().then(fetchedMembers => {
const totalOnline = fetchedMembers.filter(member => member.presence.status === 'online');
const totalIdle = fetchedMembers.filter(member => member.presence.status === 'idle');
const totalDND = fetchedMembers.filter(member => member.presence.status === 'dnd');
const totalOffline = fetchedMembers.filter(member => member.presence.status === 'offline');
const count = fetchedMembers.filter(member => member.presence.status !== 'offline').size;
// We now have a collection with all online member objects in the totalOnline variable
const SMCheckerEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Online Members')
.setDescription('***Status:***')
.addFields(
{ name: 'Online:', value: `${totalOnline.size} "online" members`, inline: true},
{ name: 'Idle:', value: `${totalIdle.size} "idle" members`, inline: true},
{ name: 'Do not disturb:', value: `${totalDND.size} "do not disturb"\nmembers`, inline: true},
{ name: 'Offline:', value: `${totalOffline.size} "offline" members`, inline: true},
{ name: 'Total Avaible Users (alpha):', value: `${count.size} avaible members`, inline: true},
)
.setTimestamp()
message.channel.send(SMCheckerEmbed);
})
});
jeremy clarkson is inside me
yes
do i fix it using cloudflare
remove .size then i suppose and it should be fine @worn niche
ye, but it'll show offline members
var user = message.mentions.users.first() || message.author;
var embed = new Discord.MessageEmbed()
.setTitle("User Information")
.setThumbnail(user.avatarURL)
.addField("Player Name", user.username)
.addField("Current Server", message.guild.name)
.addField("Current Role ", user.guild.roles.highest.name)
.addField("User ID ", `${user.id}`)
.setColor(0xffa500);
message.channel.send(embed);
break;```
I'm getting "Cannot read property 'roles' of undefined"
Remove .size from the const count
this should work right?
So that null error over there still exists but this line doesnt return any errors for some reason
let prefix = prefixes[message.guild.id].prefixes;
uhhh
okay, problem fixed. I was just having ${count.size} and not ${count}. But thanks for wasting your time @tepid canyon . ❤️
ok I dont understand
you could of kept count.size you just needed to remove .size from the const
If youre new it will of course take some time
So it's gotta find the user inside of the guild then find the role?
bot.on('message', message=>{
if(!message.content.startsWith(PREFIX) || message.author.bot) return;
const args = message.content.slice(PREFIX.length).split(/ +/);
const command = args.shift().toLowerCase();
if(message.content.startsWith(PREFIX + "ping")) {
bot.commands.get('ping').execute(message, args);
}``` this has to execute ping.js right?
oh really?
@earnest phoenix I am still getting the same error
Where
can you show us your ping file
yes the issue is you're doing bot.ws.ping, but bot was never declared in the scope.
Are you sure the execute function will have those three values
how do I declare it? do I just add const bot = new Discord.Client();
I fixed my problem
no
I did but
Use the single instance you created in your index file
if(!message.content.startsWith(PREFIX) || message.author.bot) return;
const args = message.content.slice(PREFIX.length).split(/ +/);
const command = args.shift().toLowerCase();
if(message.content.startsWith(PREFIX + "ping")) {
bot.commands.get('ping').execute(bot, message, args);```
still gives an error
You can do message.client.ws.ping
Why not client.ws.ping
@obtuse jolt which one
i want it to search through all of it to see if the users id already exists in there
so that they can only do it once
what is the property of the channels in a category
nO
@obtuse jolt if you need searching, perhaps converting everything to an array of objects would be better
woot, 200 servers in a week 😄
because the default of 10 for my framework was overkill? 😄
lmao
why shard at that point
why is the bot ping 900? I run the bot on this device
@spare mirage because it is
shards cost me nothing, so i just enable them as default and not worry about it if for some reason i get a massive spike in invites
thats a good point actually
what is the property of the channels in a category
ok how do i shard
well i say nothing, what i mean is they have so little cost as to not be noticable, and it means that theres less interruption to as many servers when it receives opcode 7
@peak parcel in what language are you coding your bot?
ok how do i shard
@misty sigil docs I believe
well depending on your platform and language, shards most definitely wont cost you nothing
jk
😛
@earnest phoenix yes bit the bot is running on my pc so it should be VERY LOW right? or do I connect to the discord servers and after that to my bot?
no
no
@livid rivet I have 0 experience in coding. I've just been looking around for cool bots and stuff and stumbled here.
It's your connection
no it wont be very low, the ping has to go to the discord websocket and back via REST
yes my connection trash
thats just how the client.ws.ping wants to be
okay are you fluent or at least beginner in any language?
so its 2x your connection latency plus any discord api overhead
who @livid rivet?
How to shard:
Smash your server boi
I am very begginer
not you, FRX
Doesn't it say to only shard after 1000 servers?
@livid rivet Nah i'm not and its not something I am interested in starting. Just looking to find and add new bots to my server.
How to shard:
Smash yourserver boi
@pure lion H A M E R T I M E
@misty sigil mind if i ask why the username? the guy is a legend. i have a boss that looks a lot like him
wdym
what is the property of the channels in a category
jeremy clarkson lol
@peak parcel If u try to learn coding actually learn it (try to understand) and dont copy paste from yt vids
Ma boi jeremy
just kinda like top gear tbh
@livid rivet Nah i'm not and its not something I am interested in starting. Just looking to find and add new bots to my server.
@peak parcel for adding bots to your server you can find a list of bots that have been approved here on the http://top.gg website if you want to learn to code well where you start depends on the Lang you want to use
how do i convert miliseconds to days in discord.js
@peak parcel oh lmao... then go on the webssite and search for bots with DM on join
@misty sigil to shard first you need purples.
purples
then you shard the purples
yes
@quartz kindle i have this now
[{"user":"X Æ A-Xii#0002","userid":"551854789990940699","channelid":"726960119929241631","type":"ip","input":"8.8.8.8","isautoscan":false,"priority":false},{"user":"X Æ A-Xii#0002","userid":"551854789990940699","channelid":"726960119929241631","type":"ip","input":"8.8.8.8","isautoscan":false,"priority":false},{"user":"X Æ A-Xii#0002","userid":"551854789990940699","channelid":"726960119929241631","type":"ip","input":"8.8.8.8","isautoscan":false,"priority":false}]```
how can i search through that
is it an good idea to give our ur clientid? to let people make invites?
yes
@livid rivet Cheers mate
obviously
ok thats a no
i can access clientID easily
youll need to if you want anyone to invite your bot, but you can find it if anyone can see your bot online, its same as your bots snowflake id
just rightclick and then copy id
oh lol
how do i convert miliseconds to days in discord.js
@errant perch help it shows my account is 9 quintillion miliseconds old
with dev mode?
yes
its amazing the amount of 'private' bots ive invited, where people didnt tick 'private bot' and just assumed without an invite link, i couldnt. i just made one with their snowflake id and permissions as minimal as possible
i mean on my own servers not here
😂😂

Usually helps if you enable that
lmao
yeah
luca i bet is useless anywhere but here
i bet its got hard coded ids of this server all over it
it does
i mean why do otherwise
have you seen the git
theres a git?!
Yeah lol
https://sourceb.in/a064946d59 help my mute cmd isnt working like the roles has all the default permissions and its called new role not Muted
i recently put my latest bot onto github, if anyone wants to critique
GitHub links on its page on the bot list to
very complexicated folder structure
wtf at the one pull request
-bots 265925031131873281
i lol'd
n o
https://sourceb.in/a064946d59 help my mute cmd isnt working like the roles has all the default permissions and its called new role not Muted
Definitely not
if I just regen it :P
@misty sigil i am going to invite your bot
ok
aaaaaaaaaaaaaah!
are you trying to make me cry?
this joke code is AWFUL
😢
lol
:o
https://sourceb.in/a064946d59 help my mute cmd isnt working like the roles has all the default permissions and its called new role not Muted
its well written
somone help
very well
help
https://sourceb.in/a064946d59 help my mute cmd isnt working like the roles has all the default permissions and its called
new rolenotMuted
@earnest phoenix your code is outdated and you're overwriting permissions of each channel which will reset the perms of the channel every time the command is run
ok
soo uh
how can i update it
Best bot cheems
Check the docs on how to create roles
k
And also use updateOverwrite instead
-docs create roles
@earnest phoenix what lib
discord.js
Id like to add the bot that this discord uses so when a user joins the server that popup comes up and they can select what they want to do. Does anyone know the name of it?
@earnest phoenix https://discordjs.guide/popular-topics/permissions.html
And also use updateOverwrite instead
@earnest phoenix ?
Id like to add the bot that this discord uses so when a user joins the server that popup comes up and they can select what they want to do. Does anyone know the name of it?
@peak parcel that isn't a bot, and we don't provide support for bots
if(!message.member!.hasPermission"MANAGE_SERVER") {
message.channel.send("Insufficient perms!");
}``` This returns a `) expected` and a `; expected` error at `"MANAGE_SERVER")`
Since it will overwrite the perms
If you don't know what I mean read the docs
And it seems like you don't know your code
@opaque hawk it is !message.member.hasPermission("MANAGE_SERVER")
Invalid flag
ik but if I do that it returns a null error so I have to use member!
oh wait
MANAGE_GUILD instead
its MANAGE_GUILD
ok
im dumm
makes sense, thx
ik but if I do that it returns a null error so I have to use
member!
@opaque hawk TS?
yes
@peak parcel that isn't a bot, and we don't provide support for bots
@misty sigil ^^ he was referring to Luca I just informed him it’s private
no !message.member!.
will this work? https://sourceb.in/9001e868c3
it still has the same error
he was?
Yeah he DMed me
i thought that thing was discord builtin
It gives the same error, even with "MANAGE_GUILD"
show code @errant perch
What are the requirements for a bot to be added here? Like will it need to be online 24/7?
yes/ but accidental downtime is fine aslong as its not offline for review
nope
no
What are the requirements for a bot to be added here? Like will it need to be online 24/7?
@long yew yes
..
no need 24/7
Oh
var user = message.mentions.users.first() || message.author;
var embed = new Discord.MessageEmbed()
.setTitle("User Information")
.setThumbnail(user.avatarURL)
.addField("Player Name", user.username)
.addField("Current Server", message.guild.name)
.addField("Account Created", `${user.createdAt} days old`)
.addField("User ID ", `${user.id}`)
.setColor(0xffa500);
message.channel.send(embed);
break;```
@pure saddle
If the bot is offline when it’s tested it will most likely be denied
@opaque hawk code?
So I would like to set up a bot on my server where a user would fetch their Rocket League ranked data from the Rocket League tracker network and then assign them the appropriate role. I've seen this on another server and am looking for someone who would like to help me.
If the bot is offline when it’s tested it will most likely be denied
@hoary elm will ALWAYS
@hoary elm what do you use to keep urs on 24/7?
@peak parcel we don't give support, look it up on https://top.gg
guys what you use to set your bot always online ? 
VPs
@earnest phoenix doesnt work
@hoary elm what do you use to keep urs on 24/7?
@long yew I use a VPS or a paid host
Suggest any vps?
@hoary elm said for me to ask here. i'll leave you guys be. Have a good day.
DigitalOcean currently usually I use Google Cloud
Use heroku it is free
@long yew ik that you didnt ask me, but in my repl.it i have a file named keep_alive.ts with the following contents: ```js
import fetch from "node-fetch";
const app = require("express")();
// @ts-ignore
app.all("/", (req, res) => res.send("Not dead!"));
app.listen(3000);
setInterval(() => fetch(process.env.ANTI_DUPE!), 30 * 1000);```
Date.now() - user.createdAt /1000/60/60/24 @errant perch u can make like that
k
Or heroku but they do have limits 😉
What is the Limit
I dont personally like heroku, they dont like my Procfile
So much usage per month
somone help with my mute cmd
DigitalOcean currently usually I use Google Cloud
@hoary elm how do u use google cloud to host?
on heroku u cant save persisent data
Any other fre hosting?
Hmm kk
if(newcxp >= level * 375) {
finished = false;
let newxp = newcxp;
let newlevel = level;
while (!finished) {
if(newcxp >= level * 375) {
newxp -= (newlevel * 375);
newcxp -= newlevel * 375;
newlevel++
console.log(newxp)
}
else finished = true;
}
let lvlsql = `UPDATE users SET level = ${newlevel} WHERE discordid = "${message.author.id}"`;
let xpsql = `UPDATE users SET xp = ${newxp} WHERE discordid = "${message.author.id}"`;
client.con.query(lvlsql)
client.con.query(xpsql)
}
Any idea why this gives me negative XP?
put for code there, add a file named "keep_alive.<file extension>"
only token
Obsfucate it
@hoary elm how do u use google cloud to host?
@long yew look on YouTube
how can i add anti spam for my bot plz ?
That’s where I found the guide I used
how can i add anti spam for my bot plz ?
@trim burrow loop through sent messages and check if it has duplicate characters
Or I believe there is some modules for it but last time I used it it was buggy
i don't have the code 🙂
Free lifetime vps or hosting?
i think no free vps
Ik how get free vps for 3 hrs
npm modules for antispam not good
@pure saddle this i agree with very unreliable.. I coded my own from scratch.
Not a module itself just the feature
muterole = await message.guild.roles.create({
name: "Muted",
permssions: {
SEND_MESSAGES: false,
ADD_REACTIONS: false,
SEND_TTS_MESSAGES: false,
ATTACH_FILES: false,
SPEAK: false,
},
color: "2f3136"
});
``` will this work?
i think i got it

