#development
1 messages · Page 879 of 1
Yeah
who is tim?
Scroll up the chat
Does anyone know where i can find an example of a Moderation system? Im struggling on creating one for my bot.
@quartz kindle
If so... That would be helpful
He's a great djs dev
I hope so 
Kinda of a tos question but how often can I just the status and presences of a bot??
45 seconds should be fine
Rule of thumb is 60 seconds delay between each update
Yeah that makes sense I was gonna set it to 2 mins anyways just wanted to make sure
Thank you ❤️
hey, I'm looking for someone who can help me configure nginx. I don't know much about how it works and a friend of mine tried but he couldnt get it to work either. and my website keeps returning error 522
Ah, I see
It used to work before, but I switched to a new vps and now I cant get it to work anymore... :/
recheck your dns configuration
I have changed the dns ip settings
Yeah, cloudflare can be a pain sometimes
what could it be in cloudflare I need to change still?
Probably it's some issue regarding nginx not being able to serve tcp requests
Idk how to deal with that, never had that issue
Would that be ufw allow 80/tcp?
Maybe
Try this
@lyric mountain thanks, but unfortunately it didnt sovle my issue...
client.on('voiceStateUpdate', async (oldMember, newMember) => {
const stream = "http://radio.livida.net/radio/8000/radio.mp3"
, newUserChannel = client.channels.cache.get(newMember.channelID)
, oldUserChannel = client.channels.cache.get(oldMember.channelID)
, { RadioBindings } = require(`${process.cwd()}/src/Structures/Constants/Models.js`)
, data = await RadioBindings.find({guildID: (newMember.channelID ? client.channels.cache.get(newMember.channelID).guild.id : client.channels.cache.get(oldMember.channelID).guild.id)});
if((newMember.channelID === data[1].channelID && data.binded) || newMember.channelID === "700486716968009800") {
// THIS CODE WILL NOT RUN... WHY??
if(newUserChannel.members.size > 2) return;
newUserChannel.join().then(connection => {
connection.playStream(stream, {bitrate: 96000, volume: 0.1});
})
} else if(oldUserChannel && oldMember.channelID === data[1].channelID){
if(oldUserChannel.members.size < 2) {
if(oldUserChannel.members.map(x => x.id).includes(client.user.id)) {
oldUserChannel.leave();
}
}
}
})
what
code in the first if statement is not running, it should be running though
Help
you kinda have to explain your entire issue to get help
how does the ship command
im gonna cry
it uses an api
why does my bot go offline every time my project is offline?
the code's process needs to stay running
do i need a host to keep it online?
generates a name based on the two users and places a percentage along with the photo of the two side by side
@snow urchin idk if you've figured it out or not because its been a long time since you posted that but try using a console.log() for each of those comparisons in the if statement and see if either is actually true. chances are, they are both false
@clear wraith are you using glitch
disgusting
lol
idk about glitch its kinda ass
also you need to use something like uptimerobot
to continuously ping it so it never goes offline
because yes, when the project goes offline, the bot goes offline
glitch is all i have
if ur serious abt a bot then get a real hosting service
but PLEASE for the love of god if you have like $3 get an actual VPS
do you guys use node app to program your bot?
you mean javascript?
yeah
yes
yes, i do, but to answer your question, you need to ping your project on glitch to keep it up
if it is not pinged in 10 minutes (iirc) your bot will go down
i use uptime robot, but that doesn't seem to work
When I use this command first time it's run perfectly but second time this two line not working...
@clear wraith what URL are you pinging on uptimerobot
should be (glitch project name).glitch.me
umm
I just deleted the monitor, and am going to make a new monitor.
Witch one would i choose to keep the bot online?
HTTP(s) @clear wraith
its on glitch.com
RadioBindings.findOneAndUpdate(query, {guildID: msg.guild.id}, {upsert: true}, function(err, doc) {
i have this for mongoose, and whenever it runs, instead of updating the existing document, it creates a new one, why??
hm
so if ur project is called epic-bot-5000 it should be epic-bot-5000.glitch.me
yes
ok
Anyone else having a long wait time for verification?
yes
not the place to ask.
what would i do after i create the monitor?
@indigo folio
you close the glitch project, wait 5 minutes and make sure it works
literally nothing
bruh it hasn't pinged yet
wait 5 mins
i set to 10
it needs to be 5
ok
if glitch does not get a ping every 5 minutes, it goes offline
Ok
@robust moth bc you're checking if data.dispatcher doesn't exist, and if it doesn't then inside the if statement you're setting data.dispatcher to be something, so next time you check it'll be something and the code inside the if statement won't work
I meant so not to
@copper cradle
oh shit
I didn't see that
however your question was why the codeblock inside the if statement wasn't working when you ran the code twice
Yeap
and I answered that question
now, lemme look into this
what does the end function do
besides from ending it
thats probably it
what does the end function do
@copper cradle stop dispatcher..I mean playing stop
playing stop?
Yes
Hi how can I add a link to another channel on the same server?
So for if I want to link it to the general channel I would do what. Sorry
So in my welcome text I want them to click on the link to the rules page
Guys how do i map a member's roles in a guild
#map
The docs, yeah, right.
any place to ask for feedback if my site is good?
make sure to ping me as im bout to sleep
Can someone help me with the discord verification stuff
Ik
It’s just the things I hav to answer
I don’t understand them
HOW HAVE YOU SECURED ACCESS TO YOUR SYSTEMS AND INFRASTRUCTURE?
I never tried, my bot only has 28 servers
Oh
then like how you stored your code and things
Oh
and how you secured them
So what would I put
I don’t know how I secured them
They are just hosted on GitHub
Then online with Heroku
if you answer like that, then you absolutelly will be declined
I dont think you are allowed to host it on GitHub
Rlly?
Its not secure
But all the tutorials I have seen make u do it on github
So you can't say on how you did not secure it
But all the tutorials I have seen make u do it on github
@sacred mountain for testing purposes
Great so what do I host it on
What’s a vps
Virtual Private Server
Umm
Google it
Wait what
What what?
You can host it on github but is likely 90% decline rate
You have to make sure its secure
And github usually isnt
So is glitch
Free stuff are not that secure
Your token IS a data
And so does databases etc.
Also, my bot is randomly giving stupid errors, such as image url is nit a well built url or whatever. And randomly sends my bot's profpic. Hmmm...
Its frigging annoying
If the url was not made correctly by the bot it gives that error... Or you did the code wrong
Code is proper
You can host it on github but is likely 90% decline rate
@high bough what no github is not a host wtf
Url is correct
honestly if ur getting errors its your codes fault
@high bough what no github is not a host wtf
@mossy vine Open source hosting, yes it is
@high bough can i see that image CREATE url code?
you are just hosting source code, not the actual bot. glitch hosts both
honestly if ur getting errors its your codes fault
@mossy vine The error is the url of the inage is not well built or smlt
@high bough can i see that image CREATE url code?
@earnest phoenix Its just my bots profpic url
Here's the url
It should be <client>.user.displayAvatarURL({ dynamic: true, size: 1024 or 2048, format: 'png' })
As you can see in my screenshot earlier, the other xommands works juat fine
You can use that... It's better and doesn't give an error
Why am i getting this error on only half of my commands?!
(node:20150) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.author.icon_url: Not a well formed URL.
embed.footer.icon_url: Not a well formed URL.
A sec
Hmm are you using discord.js? @high bough
Yes
@high bough what no github is not a host wtf
@mossy vine u can’t host on github?
Huh?
Defining avatarURL
var avatarURL = "https://cdn.discordapp.com/avatars/700935897259966474/35fcc2c2911f111d6de5cee702ee0a9d.webp"
//The code of my command file
module.exports = {
name: "suc", //command name
async execute(client, message, args, Discord, config, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
///Command Starts Here
if (message.author.id !== config.ownerID) {
const NLEmbed = new Discord.MessageEmbed()
.setAuthor(`${clientname}`, `${avatarURL}`)
.setColor([173, 216, 230])
.setDescription("Cannot show `Dev-Special` Commands")
.setFooter(`${footer}`, `${avatarURL}`);
message.channel.send(NLEmbed);
} else if (message.author.id === config.ownerID) {
const embed = new Discord.MessageEmbed()
.setAuthor(`${clientname}`, `${avatarURL}`)
.setColor([173, 216, 230])
.addField(
"**Unlisted Developer Commands**",
"`restart`, `readuser`, `listservers`, `addbalance`, `subbalance`, `setactivity`, `resetactivity`, `getowner`, `listserversid`, `eval`, `op`, `deop`"
)
.addField(
"**Unlisted Experimental Commands**",
"`purge`, `chat`"
)
.setFooter(`${footer}`, `https://cdn.discordapp.com/avatars/700935897259966474/35fcc2c2911f111d6de5cee702ee0a9d.webp`);
message.channel.send(embed);
}
}
}
``` @earnest phoenix @mossy vine
//The function that calls the commands
try {
await command.execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed, db2).catch(err => console.log(err))
Profile.findOne({
userID: message.author.id
}, async (err, res) => {
if(err) console.log(err);
if(!res){
const newDoc = new Profile({
userID: message.author.id,
username: message.author.username
})
newDoc.save().catch(err => console.log(err));
} else {
if (res.exp >= res.nextexp) {
res.level = res.level + 1;
res.exp = 0;
res.nextlevelexp = res.nextlevelexp + 100;
res.maxsanity = res.maxsanity + 5;
res.sanity = res.maxsanity;
res.maxexpearn = res.maxexpearn + 10;
res.arccoins = res.arccoins + (res.level * 10000);
res.arccrystals = res.arccrystals + 10;
res.daily = res.daily + 5000;
res.save().catch(err => console.log(err));
}
}
})
} catch (err) {
var owner = await client.users.cache.get(`${config.ownerID}`)
console.log(err);
}
}
Crap my PC is not responding niw
ok can u like stop with the misinformation
you do not host a bot on github, only source code
and private repos exist
Literally looking at the code and Wondering what in the fuck is even that...
I literally didn't understand a single thing on that code lmao
Are you doing all that just to show the bot avatar lol?
this is very likely the result of someone not knowing what theyre doing
They know what they're doing but their brain just had a stroke
@high bough you can do
dynamic: true,
size: 1024,
format: 'png'
})``` instead of that tho
Umm thats not what im trying to do
?
What im talking about is the embed is not letting me embed because the var avatarURL apparently is not a well built URL
I mean
If you get what i mean
Yes
Then just remove that url you put in there and replace it with the code i gave you
(Replace the <client> with your client name)
Hmm, lemme try
Hmm sure
Its everywhere on google
Lol true
@high bough also here is an example:
@fresh hatch just a simple ping command that responds back with pong or the one that also checks for the bot latency and API katency?
@earnest phoenix I'm still getting this error tho.```js
(node:20150) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.author.icon_url: Not a well formed URL.
embed.footer.icon_url: Not a well formed URL.
Hmm can i see your current code?
@high bough also you need to put that code i gave you in every Footer of your embeds
Yes i did as you can see
Hmm that's strange...
I have 5 commands, i changed all of them
Do you have an eval command?
The rest are copy pastes
yes i do
But i can't op myself, so i can't use it
I'm too lazy to change the codes again
your editor is so white
Yes, it is.
(Brighter than the sun itself) @spare goblet
Do you have an eval command?
@earnest phoenix It's an entire code copy from my first project
K lemme test that
It works well on half of all of my commands
The rest are broken
Idk why
I was just wondering if it was my 10KBps internet
@high bough it completely works fine for me tho...
As i said, it works fine for half of my commands
You can see that on the top it works well, but then the others )suc etc. Didnt reapond and gives me a console error
Some others just gives the avatar url
--WEIRD--
Aint it
Hmm maybe you're putting the url incorrectly on the help command or the ones that doesn't work?
Hmm I mean put it in a correct format like between: '' or "" ``
)support, )invite, works well, but the others screw up.
Hmm that's kinda strange
Hmm STRANGE AT IT'S FINEST
Bruh
i need help
CPU usage is only at 6%
none of my commands work
I mean, duh
Code please?
me?
Yea
if(!message.content.startsWith(PREFIX)) return;
let args = message.content.substring(PREFIX.length).split(" ")
let command = args.shift()
switch(command){
case 'help':
message.reply('```AHH! WHY WOULD U WAKE ME UP?? JUST USE c!c <cursedimagetopic> FOR CURSED IMAGES OR c!m <memetopic> FOR A MEME. NOW JUST LEAVE ME ALONE ALRIGHT?!```');
console.log(message.member + ' used help prompt');
break;```
thats one of the things
but none of them work since adding command instead of using args
Any errors on the console.log?
none of my commands work
@sacred mountain Didn't you have the same issues yesterday?
@sacred mountain any errors?
no
Hmm
Wait no
I fixed a bit
It replies but I can’t do a second args
It’s in switch(command)
Also that message.member needs to be changed to message.member.username
I barely understands the code, hmm..
If he wants to mention, message.member is fine i think
The problem is that it doesn’t detect a second word
I mean... It's showing the whole member info... Not just the username @high bough
Args[1] doesn’t do anything now
Bc within the function it’s meant to then say what is args[1] but it says undefined
Hmm idk but maybe try mine @sacred mountain
(my split and args function and stuff)
Smh
If you use mine then the first args will be => args[0]
Smh
uhh...
Alright, someone fix my Can't connect to this network error on my PC.
Hmm Nice i guess...
I LOVE THE SMELL OF MY BURNING PC IN THE MORNING BECAUSE OF ERRORS
i mean, you could simply use a process manager such as PM2 and see logs for all bots in the same session/window
@earnest phoenix I did the stuff in ur code and now I hav the problem I had before
All of my bots are broken
I rlly need help
show code
@high bough use google remote desktop
@sacred mountain maybe because discord.js update to v12 ?
how u gonna remote desktop a machine with no desktop?
hey guys, is showing discord usernames against tos?
I have a leaderboard in my website, and I have user ids, I am using the API endpoint to get the names of the users and show them in a table based on some ordering
nvm got it
Does anyone know why my bot's shards keep disconnecting after several hours online?
My bot uses 9 shards in a single server
I use digital ocean VPS and the RAM is 8gb
do they disconnect and not reconnect?
I’m having trouble with commands
I changed it up but still cant get args[1] to work
I literally give up
I’ve been trying for hours but either it responds to any prefix or it responds to none
@winter hawk there seems to be other people with similar issues, not sure if its the same as yours https://github.com/discordjs/discord.js/issues/4096
i had similar issues with my bot as well, but im using internal sharding, and i made my own workaround for it (monitor shard activity and force inactive shards to reconnect)
@sacred mountain show code
One sec
This is some of it:
if(!message.content.startsWith(PREFIX)) return;
let args = message.content.substring(PREFIX.length).split(" ")
let command = args.shift()
switch(command){
case 'help':
message.reply('```The current commands available are: cc!pingme - pings you, cc!ping, replys with pong, cc!info version - replys with the current version, cc!info release - replys with the current Github release, cc!clean <amount> - cleans the specified amount of messages from that channel. If you need any help/you find a bug/you have a suggestion for the bot, please contact me on either Instagram or Discord (IG - @sacred mountainyt, DISC - SaltySpamz#7828)```')
break;
case 'pingme':
message.reply('pong!');
console.log(message.member + ' USED \'cc!pingme\' PROMPT')
break;
case 'ping':
message.channel.send('pong!');
console.log(message.member + ' USED \'cc!ping\' PROMPT')
break;
case 'info':
if(args[1] === 'version'){
message.channel.send(version + '. ```In this 0. version - ' + addition0 + '. In this 1. version - ' + addition1 + '. In this 2. version - ' + addition2 + '```');
console.log(message.member + ' USED \'cc!info version\' PROMPT')}
but basically if i do switch args[0] it replys to any prefix but if i do switch command it replys to none
@sacred mountain
args = [a,b,c]
command = args.shift()
command is now a
args is now [b,c]
args[1] is c
its pretty self explanatory
so
that means
the new args is c!
instead of cc!
and command is c
so then i shouldnt do command
but if i just use args then it will respond to any prefix
if your command is "!info version"
args is [info,version]
command = args.shift()
command is now info
args is now ["version"]
so there is no args[1]
args[1] is now args[0]
wdym second word?
ohhh
wait but then if that does that i can do cc!info version
but i cant do a third word
you can
look at what your code does, step by step
message.content .substring(PREFIX.length) <-- remove the prefix .split(" ") <-- split on spaces and create an array of words
Oh
i had similar issues with my bot as well, but im using internal sharding, and i made my own workaround for it (monitor shard activity and force inactive shards to reconnect)
@quartz kindle thank you
so if you type cc!info bla bla 1 2 3 4 5 your args will be [info,bla,bla,1,2,3,4,5]
Ohh
then when you do args.shift(), the FIRST item of args is REMOVED, and all items are shifted backwards
so info is removed from args
So i have a function to see if the user is playing/watching/listening to anything and as it would show it but it only works for the PLAYING type... Is there something wrong here?
But I would have to do if args is version test then do something I can’t do if args is version then if args is test
then your args will be [bla,bla,1,2,3,4,5]
then args[0] is bla
args[1] is bla
args[2] is 1
args[3] is 2
args[4] is 3
args[5] is 4
args[6] is 5
Lmao
So I would do if args[0] is info then...
yes
Ohhhh
no
you put info in your command
you did args.shift()
so you remove the first word from args
Yh
and give it to command
Ohh
So i would do if command is info then...
Ohhhh
and whatever else
@quartz kindle also any idea about my issue up there?
@earnest phoenix can you even have more than one activity at once?
Hmm custom status and game?
you check for activities[1] which would be a second activity
sounds like your IFs are messed up
I'm doing it because if the user doesn't have a custom status... It would be [0] and if user has a custom status it would be [1]
instead of js if(activities[0].type === 1) {} else if(activities[0].type === 2) {} you're doing ```js
if(activities[0]) {
if(type === 1) {}
} else if(activities[1]) {
if(type === 2) {}
}
you should probably check for all types in activites[0] not immediately give up on it
I mean... I'm checking if they have the [0] or [1] activity...
If not just then don't check
@quartz kindle is it possible to check for all types in one go?
there are many ways to do that
but i still think your IFs are messed up, i cant understand them since broken indentation and small pic
looks like youre checking for activities[0] again from inside activities[1] which will only work if activities[0] doesnt exist in the first place?
@quartz kindle nevermind i fixed it
I just removed the if statement for check if the activities[0] existed or not because if the <userfunctionname>.presence.activities.length is true there will 100% there be a activities[0] right?
IQ === 9 MILLION
Lmao
@quartz kindle but there's also a STREAMING type for activities right?
hi
When is my bot approved?
@earnest phoenix in 2-3 weeks
oh
very long time
let me go and have coffee
K have fun
is link sharing forbidden?
Share my bot top.gg adress
so now it works for PLAYING and WATCHING but it doesn't work for LISTENING... Anything wrong here?
@earnest phoenix link sharing on where?
here
Idk ask that in #memes-and-media
idk your indentation is still a mess lol
Lmao
you could also simplify it a bit
I might try but I'm still confused about why the listening one isn't working
for example, instead of if(activities[1]) else if(activities[0])
you do if((activities[1] || activities[0]).type === "WHATEVER")
en français :
Bonjour, jaimerai faire une commande comme a!logs on mais je ne sait pas comment faire le on et le off
je peut avoir un script ?
in English :
Hello, I would like to place an order like a!logs on but I don't know how to do the on and off
can i have a script?
to do on/off things per server you need a database to save server settings
like mongoDB?
yes
ok
how do we do ? I'm just 13 years old so I'm not too strong in js I make an anti-raid bot
Hey how do you make your bot s game staus
listening for commands
i cant seem to make it say anything but playing in discord js
uh
game = playing
stream = STREAMING
watch = WATCHING
listen = LISTENING
@still merlin
how do we do ? I'm just 13 years old so I'm not too strong in js I make an anti-raid bot
https://top.gg/bot/700715384281759806@quartz kindle
@earnest phoenix i suggest you look into studying programming, look for online courses, many of them are free
read pins
nobody can see your bot until its approved anyway, but self-advertising is still not allowed
Sorry for the inconvenience
I have a problem. I made a message delete command but whenever you do it, it is meant to send 1 message saying that it was deleted successfully but for some reason it seems to add it on to like a list each time so whenever u do it, it sends a message for every time you have done it. It’s hard to explain but I think I might be missing a break; thing but I don’t know where. If anyone can help me that would be great
the code for it is ``` case 'clean':
//message.channel.send('Clean feature is currently disabled. Sorry for any inconvenience. The support server is in the website https://salty-coder.weebly.com')
if(!args[0]) return message.reply('Please specify how many messages')
else{
message.reply('Are you sure you want to delete ' + args[0] + ' messages? (Y/N)')
bot.on('message', message=>{
if(message.content === 'Y'){
message.channel.bulkDelete(args[0])
console.log('Successful deletion of ' + args[0] + ' messages');
message.reply('Successfully deleted ' + args[0] + ' messages!');};
if(message.content == 'N'){
message.reply('The action has been cancelled!');
console.log('Successful cancellation of ' + args[0] + ' messages')};```
And it seems it does more than how much I specify
didnt i tell you to remove this
because it would destroy your bot
thats precisely why
const Discord = require('discord.js')
const fetch = require('node-fetch');
module.exports = async(message,args) => {
let countries = args[0];// Your/someone countries prefix.
fetch(`https://covid19.mathdro.id/api/countries/${countries}`).then(response => response.json())
.then(data => {
let confirmed = data.confirmed.value.toLocaleString()
let recovered = data.recovered.value.toLocaleString()
let deaths = data.deaths.value.toLocaleString()
// Add .toLocaleString() to separate 3 numbers into commas.
const embed = new Discord.MessageEmbed()
.setColor(0x7289DA) // Blurple.
.addField(`Country: ${countries}`, `Confirmed: **${confirmed}** \nRecovered: **${recovered}** \nDeaths: **${deaths}**`)
.setTimestamp()
message.channel.send(embed);
// Let's test it out!
})
}```
i dont know whats wrong
@quartz kindle I can’t just delete that whole section
Then the function will do nothing
you should delete that whole section, because thats not how you do things
i already told you how to await for messages
I still don’t understand tho bc that is filter and options but how do u wait for a message
@sacred mountain you're adding an event inside an event, that will lead to infinite event creation, because events last forever (unless you manually destroy them) and are global, affected by everything
Does anyone know anyway to access a local host mongo db on mongo compass on another pc
so every time you run a command, you will have a new event listener processing ALL bot messages
you run the command 5 times, and you have 5 event listeners processing ALL bot messages
They stack up
is there a way to let a bot know if the author of the command is on a certain server?
@rustic mica message.guild
just use an if statement
thanks
if (message.guild.id === "the guild id")
@quartz kindle then how would I re write it
Bc I don’t understand that thing u sent
you should use awaitMessages as i said
Does anyone know anyway to access a local host mongo db on mongo compass on another pc
I really need this
what is it about it that you dont understand?
@sacred mountain by looking at the docs, and see what Tim just said
But how do u specify the message you are waiting for
store the id
what do you think I said
I hav no idea what a filter is
you specify what you're waiting for in the filter
you do this
a filter is a function
like this
message => message.content === "Y" || message.content === "N"
message.channel.awaitMessages(msg => msg.author.id === message.author.id) for example
Cxllm
yep
But that doesn’t specify the message u are waiting for
das a spoonfeed
because they didn't pay any attention to we say
But how would I write it tho
oh my god
Like what it says in the picture??
we literally..
But I want to have something to happen for Y and something to happen for N
Does anyone know anyway to access a local host mongo db on mongo compass on another pc
Is there a mongo command that I have to run or what
ok I'ma slip before i snap and become a demon, and proceed to get muted for a month 
@sacred mountain you check with a second if statement
that's just to make sure "anything after this, yeah process it."
otherwise it skips into your else statement
@sacred mountain define the result with const blabla and say if(blabla == ???) {}
message.channel.send()
message.channel.awaitMessages(response => response.content === "Y" || response.content === "N", { max:1, time:30000 }).then(answers => {
if(answers.first().content === "Y") { answer was Y }
})
``` @sacred mountain
tim
whY
but where do i write what happens if it is y
LMFAO
do i write the finction in that
Y E S
Write what you want to happen in that
okkkk
oml
u cant expect me to be a genius
before coding a bot learn the language
now just leave me alone
How can you connect to a localhost mongodb from another pc
@golden condor using the computer's ip address and port
I tried
and port forwarding in the router
It times out
you need to unblock it in your router then
yes
Does anybody have any idea about why
<useridentificationname>.presence.activities[0].state if it's a custom status and it only has an emoji... It says null?
custom status emojis are stored elsewhere i believe
Hmm where is it stored?
probably the first one
yes
so I need to forward my mongodb port got it
How's it possible to make a function that gives the bot a special role for itself upon joining a guild? (Just like dank memer or
Other popular bots)
you dont need to do that, discord does it automatically if you specify the required permissions in the invite link
Hmm oh nice
Hey so I got an array of allowed prefixes, this includes the mentions ect. Yet it only responds to non mention prefixes.
Some information:
Library: discord.py - v1.3.3
Image:
@ me if you have a solution for this.
<@!>
How can you make these embeds with this black rounded box?
code blocks don't look the same
neither do these
tysm
Wher I advertise
Oof
if(command === "reset") {
await message.guild.fetchMembers().forEach(member => {
coins.set(`${message.guild.id}.${member.id}`, 0)
})
}```
(node:4516) UnhandledPromiseRejectionWarning: TypeError: message.guild.fetchMembers(...).forEach is not a function
version?
v11
let members = await message.guild.fetchMembers();
members.forEach((member) => /* ... */);
if(command === "reset") {
let members = await message.guild.fetchMembers();
members.forEach((member => {
coins.set(`${message.guild.id}.${member.id}`, 0)
}))
}```
(node:5029) UnhandledPromiseRejectionWarning: TypeError: members.forEach is not a function
if(command === "reset") {
let members = await message.guild.fetchMembers();
members.array().forEach((member => {
coins.set(`${message.guild.id}.${member.id}`, 0)
}))
}```
(node:5218) UnhandledPromiseRejectionWarning: TypeError: members.array is not a function
lmao
Are you sure you're on V11?
YES
Is the command being called in dms?
but i want to get all members and set their coins
i dont get why its not working
It does, i believe, otherwise it would give you an undefined error
It seems to be defined
but i am in the server?
But it's missing methods.
No.
Collection {
'336885192490745858' => GuildMember {
this is the guild member part
so how can i get all members ?
Ah shit, I was looking at the wrong thing lol.
Once you've got the guild, check the guild members collection.
no idea how to
oh use fetchMembers?
well you've been using that
At least what I'd assume
message.guild.members.array().forEach()
you don't have to turn it into an array btw
oh and btw
how can i check if a db table includes a user id ?
What are you using to interact with said db?
quick.db
tried it already, cant find anything
I'd assume it'd be <db>.has
tried that too
How's your database laid out?
wdym
How does data get stored in each "table"?
i dont think quick.db does that
quick.db stores in an sqlite3 database.
i mean, quick.db doesnt provide an interface for database planning afaik
let level = new db.table("level")
did you mean that?
i have no idea what you talking about
kind of slow
Then use level.has(id)
but how can i use if on it
so if he is in the db it will return
again, it didnt work
Then use level.has(id)
@warm marsh
level.set(id, data)?
Then .has returns true or false.
but it says its not a function
if(blockedusers.has(message.author.id)) return message.channel.send(notallowed)```
the db table name is blockedusers btw
try console logging blockedusers
table {
name: 'blockedusers',
fetch: [Function],
set: [Function],
delete: [Function],
push: [Function],
add: [Function],
subtract: [Function],
fetchAll: [Function],
startsWith: [Function] }
fetch(message.author.id)?
You're using an older version of quick.db?
if i update will i need to change my whole code ?
Probably not.
should i then ?
Yes.
You'll still need to run npm
Now .has should work
if(command === "blockuser") {
let user = client.users.get(args[0])
blockedusers.add(user)
}```
this command is supposed to add them to the db
but it doesnt seem to work
console.log
what
(node:8423) UnhandledPromiseRejectionWarning: TypeError: Must specify value to add. Need Help? Check Out:
I'm guessing that's quick.db
But the error is pretty self explanatory
i need to add a value tho
why are you adding an entire object?
^ was about to say that
oh right
Hey, I'm trying to create the same mention thing as from last post.
I used the commands.when_mentioned_or() wich works.
I took a look at the array that it posted and used exactly the same for other code.
But it doesn't work...
My code:
main = 699693525104590889
prefixes = [f'<@!{main}>', f'<@!{main}> ', f'<@{main}>', f'<@{main}>']
def get_bot_prefix(bot, message):
prefix = "!" # Actually fetches it from a db as a string 2.
# but to prevent confusion lets place it here as a string.
return [prefix, *prefixes]
And called it using: command_prefix=get_bot_prefix
(Lib is discord.py)
Yet it doesn't function:
if(command === "blockuser") {
let userid = args[0]
blockedusers.add(userid)
}```
i tried that
but same error
add(key, value)
what should i use as a key ?
id
so you can run something like if (blocked)

check if the message is received as @late thunderhelp or @shrewd breach help
not sure if discord automatically puts a space after a mention
You could use when_mentioned_or
(node:12176) UnhandledPromiseRejectionWarning: TypeError: Cannot target a non-object.
since i updated my quick db im getting this error on a very specific code
client.on("message", async (message) => {
if(message.channel.type === "dm") return;
let userwarns = await warns.fetch(`${message.guild.id}.${message.author.id}`)
if(!userwarns) userwarns = 0
if(userwarns > 1000000000000) userwarns = 1000000000000
warns.set(`${message.guild.id}.${message.author.id}`, userwarns)
})```
try it and see
that's not the prblem there
wait so what is the problem ?
if it didn't exist the error would be a reference error
Ah it's not documented in their "docs"
their docs have always been bad
so why do i get an error
when i use get i dont get error
their docs have always been bad
right tho
Did they always have docs?
As when I last used quick.db I had to use the console to figure everything out.
they did have, but not helpful
so why do i get an error
when i use get i dont get error
what is the problem with the code then ?
also you don't need await since it uses better-sqlite3 and is sync
sounds like the database structure is invalid, try deleting that value and setting it again
the warns ?
yes
yes
i deleted it from the message.guild.id and now its all working
why did it not work tho ?
the data in it got corrupted somehow
well
quick.db works by storing json objects in sqlite, whenever you set something, it checks if the existing value is a json object (as all values should be)
for some reason your's wasnt
hence why the error
i probably did somthing wrong without noticing
well, thanks Tim!
atleast its working
is that work if no can some1 give me example to do it
$.ajax({
method: 'POST',
url: `https://top.gg/api/bots/${client.user.id}/stats`,
data: {
server_count: client.guilds.cache.size
},
headers: {
authorization: 'toe_ken'
}
});
note i want to display my bot servers count in a webpage
you probably need to add to headers: content-type: "application/json"
${msg.id} gets the message id, is there a way to get the message link?
ok thx
Threading and Such is something I've never really touched, and JS even less so I need help with an A-Sync function. Basically it uses axios to grab a Dad-Joke from a website, but I have to call the pull request before the command is called, which causes issues in that you can't specify joke types, and it looks un-neat. Is there a way to call the a-sync function, and then wait until it is finished to send the joke.
something like:
message.channel.send(":load_emoji:")
joke = fetchJoke(joke_type);
message.edit(`${joke[0]} ||${joke[1]}||`);
in an async function you can await async function calls
Does It Go In the function or the function call?
async function doIt(){
message.channel.send(":load_emoji:")
await joke = fetchJoke(joke_type);
message.edit(`${joke[0]} ||${joke[1]}||`);
}
Ok
have fun!
thanks
One more dumb question how do you have the Bot mention a user/role without pinging them?
message.author.username will get the name
instead of a mention
Most things that you can "mention" in discord contain a name object
message.channel => message.channel.name
Is that what you were asking?
which library do you use?
discord.js
🤦♂️ I don't know why I assumed discord.js
lol
Even though this is a console.log() this will get their name without pinging them. If you want to mention them without ping I'm not sure that is a thing
.then(msg => console.log(`caught ${badWords[i]} fromJ ${message.author.username}, ${message.author.id}`))
Embed
@heavy anchor You mean like thi-- ^^
You can mention ppl in an embed without them getting a pong
I'm trying to find an example I've seen a bot that does it
I did not know that
Even mentioning roles or even @everyone in an embed doesnt ping
ok yes it was in an embed
Does \@ mention work like it used too?
yep
@Dr.Freeman
#8219
you can click on the popout and it shows the roles etc
but the person doesnt get notified
Interesting
@heavy anchor
This is a weird issue that I may as well ask while I'm here
I say "weird" but it's more me being an idiot
go on
I have a "serverConfig.json" file which will contain the settings for each server
(3gb file incoming) go on
But if I say something like:
client.config[message.guild.id] = {
"prefix": n_prefix
}
fs.writeFile("./serverConfig.json", JSON.stringify(client.config, null, 4), err => {
if(err) {
console.log(`Prefix update failed`);
message.channel.send("Error, couldn't set prefix")
throw err;
}else {
console.log(`Updated Prefix for ${message.guild.name}, ${message.guild.id} from ${prefix} => ${n_prefix}`)
message.channel.send(`Successfully updated prefix for this server to ${n_prefix}`)
}
});
It deletes everything else in that servers config
why are you using json to begin with
I'm not very familiar with Databases. Is it easy to learn
yes
i just took a look at the pokecord site
i mean they have a better site ofc because they can use js
but still
damn
im pretty sure its all css
yep
they have to detect how far you've scrolled to show the images at the right time
@mossy vine CSS does have animations
However for it go down when you scroll down that is most likely JS
@unique nimbus im 90% sure that is possible with html and css but looking at source it includes js
that's not possible without js
question how do i make it where the user and bot have to be in the same channel is it
if(!message.client.voice.channel === message.member.voice.channel) is that how its supposed to be
channel.id works just fine
also, it's message.guild.me
that's the bot in the message guild
ahhhh kk thx
const Discord = require('discord.js');
oops
oh well ill put my question after it i guess im not used to discord pc
im getting an error saying something is wrong with that line whenever i try to open index.js. The error looks like this: Line: 1 Char: 1 Error: Syntax error code: 800A03EA Source: Microsoft JScript compilation error
dont run the file by double clicking
still happens when i right click and press open if that answer was directed at me. Sorry if you were answering someone else
i was answering you yes
that is not how you should run it
open cmd or powershell, cd into your bots directory, and run the file with node
smh
what i find strange about it is that whenever i open visual code studio it opens automatically and thats fine. That error only comes up for my index.js but not package-json etc. And whenever i type "node ." into my terminal it just doesnt respond. No error or message saying my bot is online
do you have a main file specified in your package.json
yes i think i do. I wrote the package-json using CMD
so when i opened it in Visual Code studio all the code for that file was already written
also yes of course it only comes up on index.js and not package.json
json is not something you run
can you show the file
(plus you can always just use node index.js)
how much of it? because its about 120 lines
the package.json is 120 lines?
ill show the first 20 or so with the token crossed out with X's
no no
sorry i thought you were talking about my index
i wasnt lol
what error do u get
it was shown above
{
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "Ozone",
"license": "ISC",
"dependencies": {
"discord.js": "^12.1.1",
"dotenv": "^8.2.0",
"ms": "^2.1.2"
}
}
huh there is a main file specified thats weird idk just use node index.js then
i also have Package-Lock.json
you need some serious programming course
this
json is a configuration file that contains basic information about your project. you can open it in any text editor or by double clicking to see its contents
js is the actual code file, you can open it as text to view the code, to but actually execute the code you have to run in with node. microsoft jscript has nothing to do with javascript, its just the default program that windows tries to open js files with, because js files are also used in JScript which is a .net related language, not the javascript that node works with
because js files are also used in JScript which is a .net related language
TIL
Should i try to salvage my bot or just start over? Because the error says its the first character of my first line of the index file. But then if i start over, it might happen again since im new to discord.js
oh you mean "npm run index.js"? I've tried that and it comes up with an error
ill try that one but it might not work
npm run is a different thing, you can specify different scripts in your package.json to run and run them wiht npm run
PS C:\Users\Laptop\Desktop\discord bot> node index.js
it came up with nothing after it
no error or "The bot is online" message
did it just stop
which is what confuses me because at least an error would direct me as to whats wrong
Do you have nodejs installed?
lmao
yes
the real question
when you do node index.js, does it return to C:\Users\Laptop\Desktop\discord bot> or does it show an empty line?
yes otherwise that wouldnt be an issue 
it just doesn't respond
so an empty line?
then the client isn't ready then?
and when you press ctrl+C then it returns to C:\Users\Laptop\Desktop\discord bot> ?
@earnest phoenix off topic but i think your status just gave me a stroke
Every is saying something random
Lol
bot.login(token);
i have my token typed out above correctly so i dont think thats whats wrong
@earnest phoenix can you answer my questions? because what you are describing sounds exactly like what happens when your file is properly running
you can promisify it but there is a 90% chance you can do it in another way
I know that
which means everything is fine, and the problem is your code
show code
@quartz kindle i think the problem is the code. I think somewhere in my code is just crashing the bot
nope
@earnest phoenix its not crashing, if it was crashing, it would show in the powershell
then what do you want to do lmao
if its not outputting anything, it means its working correctly, you just didnt code anything in it to output anything
@quartz kindle maybe its the code for the message saying "the bot is online" thats not working??? Ill go check if my bot is online
cant help if you dont show your code
its not online. Sorry if this clutters the chat, ill just paste the code in without my token
ill make an account on it, paste all the code in then link it
you don't need an account
it doesnt need an account lol
how do i remove my bot from botghost?
reset your token ig
oh i mistook for paste bin sorry
but ive got it all ready now
i took screenshots so i wont clutter the chat (I used the snipping tool so they're not low quality hopefully)
then what do you want to do lmao
@mossy vine I have to download some files at the same time, so they're downloader.
could've used hastebin
can you link the hastebin?
