#development
1 messages · Page 984 of 1
should work @dapper lynx
why does a command handler have anything to do with getting something for a specific command?
@earnest phoenix either get some sort of database to store the channel name in or get a config file where you store it
command handlers do general tasks, commands do specific tasks
How can the bot knows when someone reacts to one of its messages?
Bruh i forgot to add node push to package.json and buildpack
ok ill try
@dusky mist depends on the library
Discord.js
@lusty quest where do i find the node push github repo?
reaction collectors
how did you push it to github?
i use the desktop client for my projects
or you can use VSC
Wait will the node push thing just auto work without having to add buildpack to heroku?
i never used heroku so idk but if they use the Github API it should if you push to your repo
If you have automatic deploys enabled on heroku, it will automatically push to heroku if you push to master
Wait what do i put for const?
line?
Hello how can I delete a specific role on a server? i am using discord 12.2
const fetch = require('node-fetch');?
yes
Do i need a module? If so where can i find the github repo for module?
OK thanks
then it should be in your package.json
Nvm it's https://github.com/bitinn/node-fetch
Need that for heroku buildpack
Anyone knows how to fix this?
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
I can't connect to my mysql database any ideas how to fix?
did you whitelisted your client in the database?
App not compatible with buildpack: https://github.com/bitinn/node-fetch
or you need to allow external connections
I get that in build log
Its not free lol
That's not that problem
The problem is, apparently node-fetch "isn't compatible with buildpack"
allow external connections
@tulip ledge do you have anything listening on port 3306 on your server?
idk
its a external server i think
127.0.0.1 is localhost
nope
So what is it?
but you can set your id as a value in a config
I have no idea @solemn latch like I told you my friends have the vps
Oki @lusty quest
then your friend should be the one helping you.
theres nothing we can do @tulip ledge
then call the id in the stuff where you need a bot owner only thing
then you should buy your own VPS
Nothing works
🤔
mariadb or mysql?
mysql
Is anyone able to help with my issue?
get a better host
That isn't the issue..
whos your host?
Heroku
its incompatible with buildpack right? is it a thing your Host adds?
@lusty quest u have an idea on how to fix my issue?
it can be a simple thing or something way more complex
if you cant provide us with details, we cant help.
either a blocked port
ok but its localhost
no not using.
How do I unblock the ports?
you need something on localhost to be on the port you are requesting
@earnest phoenix the error message say its already used
did you have 2 instances running?
@solemn latch wdym?
regen token then replace old token with new try that
Does anyone know of a repo for a heroku buildpack compatible node-fetch?
your requesting a connection to something, but you dont know if anything is there @tulip ledge
something has to be there, thats expecting your request
@lusty quest no i didnt
try changing the port
^
are u sure?
the error says the port is in use
only one thing can be listening to a port at a time @tulip ledge
ay two people with the same problem at the same time
what are the odds
Does anyone know of a repo for a heroku buildpack compatible node-fetch?
@dapper lynx is anyone able to help?
server?
I need help from someone who knows anything about Heroku..
if you can afford it get a Digitalocean droplet or a AWS vps or a google vps
I am not going to swap
Could also go for a raspberry pi if it's a light resource bot
I am perfectly fine using Heroku, i just need a way to get my reddit command to work, i know there is a way because someone who also hosts on Heroku has done it
id try a heroku support community, for heroku support
Weird that heroku doesn't support node-fetch
They could support node-fetch i just haven't found a link for it to work with buildpacks
or contact the Heroku support and ask what is supported
They might not support it but idk
then ask them 
usually asking is free
How do i contact heroku support?
my suggestion, click "find out why"
Parents don't allow me
then wait until your of age, and buy your own
can someone help me?
how do i make it so if i do .purge 1 it deletes the message .purge 1 and 1 message?
client.on('message', async message => {
let args = message.content.substring(prefix.length).split(' ');
if (!message.member.permissions.has('MANAGE_MESSAGES'))
return message.channel.send('You need the "Manage messages" permission to use the delete command')
switch(args[0]) {
case'purge':
message.channel.bulkDelete(args[1])
}
})
increase the purge amount by 1
message.delete()
message.channel.bulkDelete(args[1] + 1)
What
its an extra query
Why would you do tbat
@solemn latch ty
It just means you get more rate limits
@solemn latch ty so much i've been trying for a hour
@solemn latch how many can it delete at once?
i think its 50
ok
i havent checked the limit tbh
youd have to run multiple bulk deletes if i remember right
i think discordjs.guide covers that
can you send me a link?
https://discordjs.guide/creating-your-bot/commands-with-user-input.html#number-ranges
it doesnt actually cover it.
but it should be just running bulk delete as many times as it takes to get to the entered number
the max is also 100, not 50

@solemn latch help
instead of deleting 1 message
it deletes all
from less than 14 days
Is someone more having troubles with glitch?
const amount = parseInt(args[0]) + 1;
client.on('message', async message => {
let args = message.content.substring(prefix.length).split(' ');
if (!message.member.permissions.has('MANAGE_MESSAGES'))
return message.channel.send('You need the "Manage messages" permission to use the delete command')
switch(args[0]) {
case'purge':
message.channel.bulkDelete(args[1]+1)
}
})
that is the code
i used
@solemn latch Created the phpmyadmin database but didn't do anything
In the switch case i guess
but thats an on message statement
it would be running any time any message is recived
oh nvm
duh
switch

@long yew i recommend u to rewrite this code because most of it is wrong
U check if the user have permissions before u enter the switch case
@dusky mist how should i order it all?
i need help how to set up private dm for discord.js v12.2.0
user.send()
First of all i recommend u to use command handler instead of switch case
the entire discordjs guide actually helps a ton.
reading the entire thing helps a lot.
https://discordjs.guide/#before-you-begin
Does anyone know of a Heroku compatible node module i can use for a reddit meme command?
I'm having a lot of trouble finding one..
I would contact heroku support
I can't seem to be able to contact i don't exactly know how, plus that could take ages and there is no guarentee at all that they can help.
i doubt youll get your answer any quicker by asking every 10 minutes for an hour 🤔
esp in an unrelated community
I've asked twice just to double check if anyone could help
Make my own what?
^^
reddit api client
api's are fun
I literally would not know where to begin or how to implement to my bot
research!
Like i genuinely wouldn't have a clue how to
And i can't find any way to get anything to work with Heroku
@dapper lynx what you trying to do?
Except already compatible modules
when you get assigned an assignment at school, do you just give up and say "i don't know this, give me an F" or do you do research on the subject
I'm trying to implement a command for my bot which gets a meme from r/memes but i can't manage to make one that also works with Heroku
@dapper lynx what you trying to do?
@solemn latch so like this
client.on('message', message => {
if (message.content === Prefix + 'JoinBot') {
const embed = new Discord.MessageEmbed
user.send()
.setTimestamp()
.setTitle('This Is the Bot Link')
.setAuthor('This Code Is By Xp And P O U T I N E')
.setDescription('https://discord.com/api/oauth2/authorize?client_id=721775900949086240&permissions=8&scope=bot')
.setColor(15844367)
.setFooter(message.author.tag,message.author.displayAvatarURL());
message.channel.send(embed);
}
});
well, are you trying to send a pm to the user who did the command?
ya
client.on('message', message => {
if (message.content === Prefix + 'JoinBot') {
const embed = new Discord.MessageEmbed
.setTimestamp()
.setTitle('This Is the Bot Link')
.setAuthor('This Code Is By Xp And P O U T I N E')
.setDescription('https://discord.com/api/oauth2/authorize?client_id=721775900949086240&permissions=8&scope=bot')
.setColor(15844367)
.setFooter(message.author.tag,message.author.displayAvatarURL());
message.author.send(embed);
}
});
thx
np
heres an entire heroku support page

Is there any way to make a pre-existing node module compatible with heroku buildpacks?
id look at that support page
Because that support link doesn't say anywhere how to
🤔
I already looked over it for like half an hour and i can't find anything relevant to my issues
there are entire sections for installing packages
It doesn't really explain how to get a non compatible module working with it though
uh im not sure @north hollow

Or "heroku-postbuild": "ng build --prod" // this will be run on Heroku
I literally have no clue
then your best bet is contacting their support
because the other option, is i contact their support 
Your whole question is whether there is a compatible meme api?
have you considered not running on trashy ass hosts
I am physically unable to pay for stuff like google cloud and stuff, even though they do a free trial i think
I don't exactly have a lot of money currently
It costs 0 for a year of GC or AWS
const results = await youtube.searchVideos(search, 1);
songInfo = await ytdl.getInfo(results[0].url);
song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
duration: songInfo.videoDetails.lengthSeconds
}
Cannot read property 'title' of undefined
theres also the option of doing basic work for people, make a fiver account and do a few jobs, in two jobs you can get a years worth of VPS
I can't do that currently either, i can probably later in the year but still
I'm just trying to see if i can get everything working on Heroku, once i know for sure it's a no go i will start trying to work my ass off to pay for good hosting
my hosting provider is like $30 a year.
There are people who make $30 a week grinding gp in runescape 
But honestly for the time being i don't see a point in paying for a good host if my bot is only currently in 5 servers which 3 of them are my servers anyway and i don't really have good reputation for bot making or a bot that stands out just yet

My bots current main feature is music so not a good start
im guessing you have no machines you can selfhost on
Hence i'm trying to implement reddit memes
heroku seems like a terrible platform, i would just wait until something makes more sense
I technically do have a machine i can self host but only my pc or laptop which is not ideal
i need help how to set up private dm for discord.js v12.2.0
elaborate on set up
Who were you asking? If you asked me, selfhosting on my pc or laptop honestly isn't practical at all for me
Laptop is a chromebook with 4GB ddr2 ram i believe, i think more likely ddr3 but i am not sure, it would run via linux which would be better than windows probably, but it's slow when using linux stuff and it would require i use an unfamiliar coding app on a laggy machine
And pc just sucks up too much power
"unfamiliar", What do you currently use?
Yes you can.
Well not on my Chromebook i can't
Depends, If you're directly use chrome os then maybe not
Plus my other statement would still stand, it would be very laggy
4GB should be fine for most tasks.
It's honestly not a very powerful machine whatsoever
The cpu is not good at all
And 4GB ddr2 isn't fast
I'm on about the machine in general, not running the bot
Can someone help me with a bot
most discord bots really use no resources
Linux apps crash a lot so i could lose a lot of unsaved progress
practically no resources
wut
No its with creating a bot
How does one host a bot on a rasbery pi?
I made the bot but i need help with adding commands
what language @bitter harness
Wdym
what language is the bot in
Go learn how to code
English why
..
@bitter harness be serious what langue
i'm sure most programming languages are in English
Written in English™️
skyblock4life, what programming language are you using
Host Your Website on Raspberry Pi: Raspberry pi is a low cost development board by the raspberry foundation,for this tutorial i am using the distro provided by adafruit that can be found at http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v...
ENGLISH
Yeah just like
If your command is hello
the bot says hello back
Love to code like that tbf
english is the language you speak, not the programming language
Search up "Programming language" pls
Ok thanks @digital ibex
How do i check language
@bitter harness Don't make a bot if you don't even know what a lanague is
I code in czechoslovakian
^ thats impressive
🤣
Can i code on phone
How
why are you guys making fun of a guy who doesn't know what a language is? at one point we didn't know what it was.
yes
Pls tell .e
@bitter harness yes, but it's not good
don't try to code on a phone
and google up what a programming language is and what they look like
A language is whut someone speaks like chinese or spanish
no
no
that's a language
yes
a programming language is another kind of language
Skyblock do you have any knowledge on programming
hence the word programming
No i dony lite
youtube courses are a double-edged sword
yeah
Huh
watch socratica's python course
Okay I will give you some examples-
js
var hello = 'hello world'
console.log(hello)
py
print("Hello world")
css
<p>
<button onclick="location.href='0';">
Top.gg
</button>
</p>
Json
"Hello": "World"
You should try learning a programming language before asking.
it's pretty fun to watch
Can u dm me link zsnails
In simple terms: Programming language is like a language that computer "speaks" so you choose a programming language e.g. javascript, c++ etc and you code using said language
@bitter harness I can't atm
tldr
are you bad at maths or anything related to logical problems? if so, programming is not for you
Ok thx
id start here
https://www.codecademy.com/learn/paths/code-foundations
codecademy didn't teach me shit, i recommend https://sololearn.com 😎
They should teach programming languages on Duolingo 🤣
codecademy just confused me lul
get an exception and they'll kill your family
codecademy is the place you go when your unsure what a language is 
it covers extreme basics
ye
so i used sololearn
There are many places you can learn programming from. Codecademy is kind of gross but I learned Kotlin on Hyperskill (which won't be as good in a few months)
imo, its easier and you progress more
🤔
@dapper lynx you didn’t practice your JavaScript code today Alabama do it or the bird will come to your House
i suggested the one that explains stuff like what programming languages are, scope, and what syntax means
that ain't no css
Dude has to start somewhere
@dapper lynx you didn’t practice your JavaScript code today Alabama do it or the bird will come to your House
@halcyon galleon Oh no, i am sorry 😳
Lmao
i fucking hate computer science
https://kyoya.why-am-i-he.re/NCd1tu how can i fix this?
sxcu.net free ShareX uploader
:>(
stop making so many requests
How and why are you making so many requests.
im not making so many requests!
computers don't lie
i dont know how its happening
Well let's see it's coming from dblapi.js
yes.
So you somehow got rate limited from the API (which lasts like an hour to my knowledge)
What can i do?
every time that error comes up, its a new request, how often is it coming up?

vote lock commands?
what can i do else with dblapi
you're probably checking for votes too often
also votelocking 🤢
yeah :/
so what i need to do?
do it less
i can't fix this?
either stop votelocking because that's scummy or cache vote data
or i will do it less
you can send 60 requests a minute,
ideally, youd do much less than that
yeah i think so
thanks
help
How do I do that if args[1] has 2+ letters and not 1 letter return something
(Node JS)
i dont understand the question
like if (args[1] == 2 letters or more) {.........
Question for github webhooks to discord, do u need to make two different webhooks for two different repositories or can you use the same webhook url? Please ping if you have an answer
you can use the same url
if (args[1].length >= 2)
you didn't know?
alr
I don't like python :p JS is sicko

What do you think about hosting a small bot on a Raspberry Pi 3?
its an good investment from what i heard
it probs isnt
1.5k servers/gb ram
So for a private bot its enough
Yes
Okay thank you
yeah, you could even use a free hosting server then tbh
if youre planing to make it public don't tho
I used glitch. But they are bad
paying for a cheap vps is good
^
i recommend hetzner or ovh
how do i make sure my bot can ban a member
you should send as few bad requests as possible, otherwise so many will have your bot banned from the api temporarily
.bannable on a member will tell you if the user is bannable by the bot
how do i set a member
you should send as few bad requests as possible, otherwise so many will have your bot banned from the api temporarily
@solemn latch I have never experienced this / maybe discord.js will check it first idk
its a lot of requests to get blocked
its better to do it without sending bad requests
if you can
1.5k servers/gb ram
@fleet mason - I've got bots in 1.5K+ that average 130MB RAM :-/
but how do i set the user that's being checked
I don't cache members
How do you stop caching members?
if (!message.guild.member(user).bannable) return message.reply('You can't ban this user because you or the bot has not sufficient permissions!');
that returns SyntaxError: Invalid or unexpected token
f
I don't use presence/member intents for one
just do !user.bannable
If a message is sent to a guild, it'll have a member property.
fs.readdir('./commands/', (err, files) => {
if (err) console.log(err);
let jsfile = files.filter(f => f.split('.').pop() === 'js');
if(jsfile.length <= 0) {
console.log('Je ne trouve pas la commande');
return;
}
jsfile.forEach((f, i) => {
let props = require(`./commands/${f}`);
bot.commandes.set(props.help.name, props)
})
console.log(jsfile.length + ` commande, à bien été charger`)
})```
message.member - member of who sent it
for a user which isn't in the server, how can i get their presence info?
in eris
can't find anything in the documentation but i do know its possible, any ideas?
dont bots that do that get denied?
do you use discord.js or something else
in eris
no they don't
i guess its better at memory optimization?
its better for a lot of things, not just that
first reply of a fun bot command i'll add to my bot
cat pictures
okay i normally use giphy and tenor
what on?
@west raptor is it possible to DM you since you declined a bot I'm a second owner on?
if(user.bannable){
user.ban(banReason).then(() => {
const banConfirmationEmbed = new Discord.MessageEmbed()
.setColor('#' + randomColor)
.setDescription(`✅ ${user.tag} has been successfully banned!`);
message.channel.send(banConfirmationEmbed); // Sends a confirmation embed that the user has been successfully banned
})}
if (user === message.author) return message.channel.send(`You can't ban yourself`) // Check if the user mention or the entered userID is the message author himsmelf
if (!user.bannable || !message.guild.permissionsFor(message.guild.me).has("BAN_MEMBERS")){
const banConfirmationEmbed = new Discord.MessageEmbed()
.setColor('#' + randomColor)
.setDescription(`This person has not been banned, probably something to do with permissions.`);
message.channel.send(banConfirmationEmbed); // Sends a confirmation embed that the user has been successfully banned
}```It always returns "this person hasnt been banned"
@earnest phoenix sure
Alright, I believe your DMs were blocked when I tried originally
try now
Why do you have the ban checks after the ban command
and no checks for user/bot perms
i have
just not in that code
but actually i just moved that
for fitting it in discord
Is it the database CPU or the server CPU that caused the database delay? I need to know which to upgrade.
database CPU? wdym
How do I get pm2 logs to show colour?
pm2 start my-app.js -- --colors
async function run(){
await message.author.send(embed)
}
run()
} catch (error){
message.channel.send("I wasn't able to DM you.")
}```
it doesnt catch the error
^ The try statement still won't catch it since it's async.
You'd need to await run()
Or you could just use .catch directly on .author.send()
i fixed it
my thing isnt in a async so i cant do that
just made a async function with the try inside
how do you check if message author has a certain role
You'd need to check the message member/guild member's .roles.cache.
oh ok
h
I am waiting for my bot to get approved
yes
yes
kinda
yes
k
cool
have fun
(Assuming they have the permission)
Can someone help me with Vultr VPS? I try to install discord.py as a dependencies
What do i do?
client.messages = new Enmap({name: "messages"});
client.voice = new Enmap({name : "voice"})
const key = `${message.guild.id}-${message.author.id}`
client.messages.ensure(key, {
user: message.author.id,
guild: message.guild.id,
messages: 0,
mentions: 0,
images: 0,
lastSeen: new Date()
})
client.messages.math(key, "+", 1, "messages");
if(message.mentions) client.messages.math(key, "+", 1, "mentions");
if(message.attachments > 0) client.messages.math(key, "+", 1, "images");
Okay so I wanted to know what core features a bot should have. I know there's a lot of things, but it's hard to just think of what literally every bot does, so I'd appreciate some input/a list of features a good/decent bot should have
there isn't a standard
bots are like art
they are art
do whatever you want and what you feel like your bot is supposed to be
build from your imagination
that's exactly what people dont want, a rehash of a bot that already exists wont get very far
a lot of the stuff that most bots already do is done and it's done really well
that's why you gotta make up your own stuff
you cannot control how anything is displayed on end user's screen
I want like
That is just a display error
Can I increase the size of pictures or whatever
you can but it won't do anything
Coz the 2nd one looks neat
the client will always resize it relative to the screen size
Ok thanks
Why do people make Discord webhooks to announce people who voted?
Is it possible to put headers in the Discord webhook URL, maybe they just point it to their API?
How would I make it execute a Discord webhook?
you need a middleware to receive webhook data from DBL and reformat it appropriately for a discord webhook
that requires having an active webserver
Hi
How to use puppeteer? im trying to make a screenshot command, but i dont know how to send the message of the screenshot gotten
check examples folder https://github.com/puppeteer/puppeteer
database CPU? wdym
@pale vessel my MongoDB database has a separate CPU and doesn't use the hosting server's CPU
can anyone tell me good resources from where I can master bot development, (from starting till end)...?
@raw ravine what language do you use or wanna use?
@earnest phoenix brother, i am really confused between .js and .py.
Both are good but I want to know which has better customizable options and with resources to master them
For bots you'll probably have to go for what you find easier because they all just get info from the discord API which means it's most likely the same thing but just different languages which means something could be easily done in one but not the other but they both just get stuff from discord API
they are legit the same in functionality
ok so for now good resources for discord.js?
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
idk why but i just feel like putting yt as one of them feels just right
thanks a lot brother... means to much for me!
you're welcome!
Hey
In here.. he putted a video in his discription.. does anyone have the script so i can make one the same but different video?
you can use markdown and HTML/CSS to edit your page
Yes.. I usually do..
but Idk how to insert the video.. so do you have a script for it.
I want to insert the video like the top same size.
Embed YouTube Videos - A simple html guide. An easy guide and cheat sheet for beginners to learn HTML, covering several topics on the basic HTML tags you are likely to need when learning how to make your own website
if someone has the script.. please kindly do let me know by pinging.
http://www.simplehtmlguide.com/youtube.php
@lusty quest Thank you.. ill be sure checking it out
Embed YouTube Videos - A simple html guide. An easy guide and cheat sheet for beginners to learn HTML, covering several topics on the basic HTML tags you are likely to need when learning how to make your own website
https://lmgtfy.com/?q=html5 video&iie=1&ovr=1
@earnest phoenix 👍
did you want to have the code run mutiple times? or did you want to execute something in your function?
well i have a giveaway command but idk how i prevend from the bot of winning
i can use if(winner.id = client.user.id) but that is once and not infinite
just filter parcipipants (u => u.id !== client.user.id)
@restive furnace that looks for it, it doesnt delete it
right?
show me an example please
kk
my code btw its too long xD
let ids = ["132", "822", "013"]; // lets say that "132" is our client id
let filteredIds = ids.filter(id => id !== "132");
console.log(filteredIds) // Output: [822, 013]```
you can try filtering 822 or 013 too
how will i do that in my case
and see its working
i literially just said
let filteredP = paripipants(id => id !== client.user.id)
Why my bot can not get guild.owner of this server? It is always null when my bot receive MESSAGE event.
Owner is not cached
Well, that helps a lot! THX! Can I fetch guild.members manually? I know I can get the owner ID from guild.ownerID.
Can someone help me with this error:
(node:11016) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'content' of undefined
The code is here: https://pastebin.com/eDtYmGqM
fetchUser sounds like what you want
Hello
Hi
english
Can someone help me with this error:
(node:11016) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'content' of undefined
The code is here: https://pastebin.com/eDtYmGqM
Is that supposed to be a message edit event?
Can someone that knows a decent amount of discord.js DM please? I prefer talking in DMs if that isn't an issue, its about a purge/clear command btw
I have problem
this stupid vsc
is saying identifier settings has already been declared
and I can't do anything about that
SyntaxError: Identifier 'settings' has already been declared
←[90m at Module._compile (internal/modules/cjs/loader.js:872:18)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:790:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:703:12)←[39m
←[90m at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)←[39m
←[90m at internal/main/run_main_module.js:17:11←[39m
[nodemon] app crashed - waiting for file changes before starting...
this is error
Press enter twice
oh tysm
Why are there three arguments being passed with the event and the first being message
Yes but what is message defined as cause the event should only provide old message and new message
I'm starting to feel like I'm hitting my breaking point just trying to figure out how tf to run discord.js properly on Linux and its driving me CRAZY.
aren't those optional packages
Mhm
@sick comet lol what are all those files
@coral trellis I removed the message but its still not working
Can someone tell me what the presence intent and server members intent actually do and are responsible for?
can anyone tell what is the ping command in python...I tried everything but it is now working
@earnest phoenix without presence intents, you will not receive presenceUpdate events, not be able to fetch members with presences, not receive initial presences at login, not be able to access user's statuses and activities
without guild members intent, you will not receive a list of members at login, you will not receive guildMemberAdd/Remove/Update events, you will not be able to fetchAllMembers
Can someone help me with weather-js
I wanna send the 'current' result but I'm not entirely sure how this works
Show the code you have written so far
Okay
case 'weather':
weather.find({search:
msg.content.slice(8),
degreeType: ('C')
}, function(err, result) {
if (err) console.log(err);
let resultSTR = (JSON.stringify(result, null, 2));
let location = 'location';
var locationR = resultSTR[location];
console.log(locationR)
msg.channel.send(locationR)
});
break;
how can i do like
i have a json and i want the ${} in it from ` in the json strings and i want my script to read
{
"a": "`${client.user.tag}`"
}
for discord.js
backtick
i know now
replacing the " with ` wont change
that will make an error
or y i know
thanks
i understand
wait nvm
`${client.user.tag}`
```yields what error exactly?
What aren't you allergic to
I'm not a JS or node dev either
that's no surprise then
the backtick and string interpolation is not a thing in json
owk
no, this won't work in a pure json file
a json file is purely for data storage, it is not javascript and has no access to javascript variables or functions
the only way to have dynamic data stored in a json file is to use placeholders, and replace them when you load the file
for example ```js
// json
{
"a":"%%USERNAME%%"
}
// script
json = require("myfile.json")
json.a = json.a.replace("%%USERNAME%%", client.user.tag)
How can i make an api with express like .../sos?text=asjobojs?
should be in req.query
oh confused url and query parameter there
but it's both explained there
req.query?
yes
req.query.yourparam
yes
Ok i will try thx
Not working anything. - WORKED!
i was creating my database with mongoose
this is my code
module.exports = {
init: () => {
const dbOptions ={
useNewUrlParser: true,
autoIndex: false,
reconnectTries: Number.MAX_VALUE,
reconnectInterval: 500,
poolSize: 5,
connectTimeoutMS: 10000,
family: 4
};
mongoose.connect('mongodb://localhost:27017', dbOptions);
mongoose.set('useFindAndModify', false);
mongoose.Promise = global.Promise;
mongoose.connecotion.on('connected', () =>{
console.log('Mongoose connection successfully opened!');
});
mongoose.connection.on('err', err => {
console.error(`Mongoose connection error: \n ${err.stack}`);
});
mongoose.connection.on('disconnect', () => {
console.log('Mongoose connection disconnected!');
});
}
};
and it shows this error
^
TypeError: Cannot read property 'on' of undefined
at Object.init (C:\Users\PC\Desktop\DsBot\util\mongoose.js:18:22)
at Object.<anonymous> (C:\Users\PC\Desktop\DsBot\index.js:110:17)
at Module._compile (internal/modules/cjs/loader.js:1176:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47```
connecotion -> connection
omg ty im blind
gg api is dying again
lol
question: is there some tutorial or sth like that about using Discord to log in on a web page? I'd like to create a dashboard, but I've got no idea how or where to start (not a web developer, but only client so far)
search for OAuth2
alr
and another question: is it recommended to run bot and webserver on the same server instance or rather split them?
running them together is probably easier, but if the bot is down, the website will also be down
so having separate processes with a shared database is usually the way to go
yeah def separate processes. I was wondering about the "physical" instance of a server, like a gcloud compute engine instance.
thx, I'll look around the web and see what I can find 👍
nothing wrong with having them both in the same machine, unless the scale is huge
nah, it's on 121 guilds now and pretty specialized (obtain info from some game's API), so I guess it won't have to scale that much. Other bots serving a similar purpose are at max on 150 guilds rn.
yeah, having separate machines is only needed if your bot is like in 100k+ servers
at that point you start getting frustrated at your own growth instead of happy lmao
client.on('message', async message => {
let args = message.content.substring(prefix.length).split(' ');
if (!message.member.permissions.has('MANAGE_MESSAGES'))
return message.channel.send('You need the "Manage messages" permission to use the delete command')
switch(args[0]) {
case'purge':
message.channel.bulkDelete(args[1])
}
})
``` When using this and doing .purge 1 it only deletes the command how can i make it delete a message and the command i put in?
You could delete the message with the command first. That's how Dyno does it.
so where would i put the command message.delete() ?
right before js message.channel.bulkDelete(args[1])I guess
yes
ok thanks i'll try that
How can i delete a channel, or delete all channels in a discord server
K
do you know how i can increase the purge limit from 100 to 1000?
You can't... Even if you can, it's api abuse... Api abuse is not good
Hello everyone ,I was having trouble figuring out how to remove all reaction from a message I tried alot of thing none of them worked can someone help me ?
with discord.py*
@earnest phoenix dyno does 1000
I tried it :/ I guess my bot didn't have the permission to use it i'll try again thank you ! 😄
@long yew the only way is to run bulkDelete multiple times in a row until the target number is reached
with a loop and a bit of math
You can't... Even if you can, it's api abuse... Api abuse is not good
@earnest phoenix api abuse?
Yea
Dyno does?
It uses tactics and ways to prevent api abuse... Waits until it purges the first 100 messages by bulkDelete then does Another bulkDeletes one by one as it avoids api abuse by it @earnest phoenix
hm ok
How can I check if a number in javascript is odd without using the remainder operator. The dumber the solution is the better
function isOdd(n) {
return n == parseFloat(n) && !!(n % 2);
}
``` try this
Without checking the remainder
function isOdd(n) {
n = Math.abs(n) // to make it work for negative numbers as well
while (n > 0) {
n -= 2
}
return n == 1
}```
Is this dumb enough? 😄
anyone have any ideas of good commands to have on bots?
What's wrong with just doing !(n % 2)
@long yew the less is better. having a ton of commands can be a bad thing. If you can try to specalize on one thing
Could someone help me with why my role changes are only showing 1 role not affected by a role change in my guildMemberUpdate code:
Trying to get it to list when a person is added or removed from a role
Currently it detects when someone is added, but it doesnt show the role the person is added to.
Discord.js v12
Editor/IDE already underlines the incorrect brackets
@mental spade Why are you saying a role has been removed whenever the newmember contains the oldmember's role?
i have a message update command which logs when message gets edited but i keep getting this error can someone help??
The oldMessage probably isn't cached
everytime i tested it i make sure to send a fresh message and edit it
from my index.js
did you restarted the bot between the tests?
How are you registering the messageUpdate listener?
i am using nodemon which restarts everytime i save
require('./events/messageUpdate')(message, oldMessage, newMessage);
});
messageUpdate only has 2 parameters, old and new
so i must remove message?
Log the token
I removed message from the code and its working but now how do i ignore message edited by bots?
Literally Wondering what can be wrong there
Guys how i can add a domain to nodejs server
What's wrong is I changed the token and used the new token
@earnest phoenix use nginx or apache
idk
but i want to use a nodejs server
@lusty spade Check whether the message author is a bot
I dont really use them, my idea of a Web server is express/fastify for nodejs
yes
but i cant use message so how?
Hello
and it is local host
Domains need to point to the IP of your server
yes
@lusty spade oldMessage?
hello Umm there is a sqlite error what should i do.....?
Have you got a domain?
yes
Maybe tell us what the error is?
oh ok thanks
@trail finch https://domain.con is a domain
Have you also got a hosting solution?
kk
yes
Go to your hoster's dashboard and set it up
ok
Hang on, asking my crystal ball what your error could be /s
is there a way you can only allow yourself to do a command? if yes how? I can't seem to find it anywhere (I'm using discord.js)
Hm
is there a way you can only allow yourself to do a command? if yes how? I can't seem to find it anywhere (I'm using discord.js)
@spark breach yep
its easy
Check whether the message author's id is your id
yes
hm
ohhhh oki, ty
so i was asking that how to do the catch command...?
@spark breach im a js dev and how to set datas for each pokemons and enable catch command as im making a pokemon bot
try{
//do stuff
}catch(error){console.error(error)}
What "catch" command?
in where dude
hm
the pokemon catching
oo u too making pokemon bot??
Cause everybody seems to be creating pokecord clones rn
yeh
yeah
so for example this: (or did I do something wrong?)
if(!message.author.id('553649764177149972')) return message.channel.send("Sorry you can't use this command!");
im just creating for my server
@spark breach Try it out, but looks good
so i need some helps in it
@spark breach Try it out, but looks good
kk I'll make a command real quick
message.author.id isn't a function
wHy DiD i PiNG mYsElf
i tried to find it on google but failed
message.author.id isn't a function
oh oof
ooo
Oh derp, missed that
what do I need to do then?
cmon someone help plz
Hm
It's a property, use good old ===
i am in the next line after beauver maybe
kek
It's a property, use good old ===
ah oki
😉
i ve got some ffrnds here but they arent cming
if(!message.author === '553649764177149972') return message.channel.send("Sorry you can't use this command!");
so this?
Not quite
hm
Negate the equality comparison
oh oki
Hm
Also, you are still checking the id, not the author object
@trail finch Stop it please, makes helping others difficult
ok sorry
Also, you are still checking the id, not the author object
oh makes sense yeah
@spark breach use !==
when it will be my turn can you plz ping me ;|
what is your issue?
if(message.author.id !== '553649764177149972') return message.channel.send("Sorry you can't use this command!");
Don't spoon feed please
:d?
if(message.author.id !== '553649764177149972') return message.channel.send("Sorry you can't use this command!");
I'll try it, ty
umm i want to make a pokemon bot so i need the catch command help
np
define catch
Do shards have their own API limits?
Not try-catch, the catch command
umm like pokecord after the pokemon spawns then the catch command to catch the poke
Write the command
which one
The one you need
catch
is it like
get a idea how you want to aproach it and then write the code for it
like?
Keep track of what pokemon spawns and use the command's parameter to do your checks
const catch ={catch}
cmon i aint a dev
xD nvm
maybe its a to large project for you RN. try to learn some more before you start bigger stuff
Learn the basics before making a bot
umm ok
Does anyone know an easy way to get a default server image based on the name?
you have the server name and want to get the image of the server?
hey guys how do i change the background colour? html <body style ="background-color:lightblue"> this doesn't seem to work
Use CSS
The above link shows how to customize the body using CSS
yep thanks guys
i use css example but the background did not work
you have to overwrite existing classes
find them with inspect element
ight ill try that
@earnest phoenix Hey, you should make a video on how to change top.gg colour. It would be supper useful
hi, im having a little issue with css
how can i make the blue bit end where the lines are?
anyone got any ideas?
Change the padding?
i change the padding and it moves the text instead of the blue bit
Can anybody tells me ping command for python
Because I tried many thing and it doesn't work

@digital ibex text-align:center on parent, display:inline-block;background:blue on child
anyone know how to discordjs v1.12 create roles with admin perms
kk
ok so now what?
Depends on the library you use @earnest phoenix
anyone know how to discordjs v1.12 create roles with admin perms
@inland aurora when the bot has admin perms too
@inland aurora bots shouldnt have admin perms
Your bot won't be approved here if it does @inland aurora
@inland aurora just in General?
Your bot won't be approved here if it does
@solemn latch uh pretty sure admin perms are allowed unless im misunderstanding, but mods doesnt tolerate of for example, needing admin perms just to send messages.
like a moderator command that is !createrole admin perms: 8
you can only add a link
for the image next to it
so how do i add the author's pfp there
anyone knows?
@inland aurora can you help me?
@earnest phoenix I don't know what you mean, when you said "Hey, how can I make a command who is create a channel as Username’s-apply and with selected perms?"
you want to change the pfp of the bot?



