#development
1 messages · Page 918 of 1
do the first he found
us is nit found in the countries code
yes
but in api write US is a country code
look
oh it work
200 was not enought
so i used data.Countries.length
guess I'm a total noob right now, but I just want to send an avatar url with my bot. But displayAvatarURL() gives a .webp link or something
Does any one know how to use sportify to play music?
still not showing the image itself
still not working
.avatarURL({dynamic: true})
changed size, filetype
pls I know how to use docs, but how I'm reading it the dynamic value is only useful when having gifs
What are you trying to do?
I just want the image to show in chat
like the very simple .displayAvatarURL of v11
my web dashboard keeps giving me https://corynth.xyz/cdn/WLsKzJGG.png any idea why?
(when logging in)
How i get the second mention?
Is there a way to have the bot do an auto restart of it has an error?
Every now and then I get “Discord-API error”
how do i make a music bot
🥺
How i can get stats about a player in league of legends?
you use what's called an api
Ok ty xd
does anyone know how to Get a message now like this in DJS 12?
try {
var response = await msg.channel.awaitMessages(
msg2 => Number(msg2.content) > 0 && Number(msg2.content) < 11,
{
maxMatches: 1,
time: 10500,
errors: ["time"]
}
);
} catch (err) {
console.error(err);
var noresponse = new Discord.MessageEmbed()
.setTitle(":exclamation: | No one is responding")
.setColor("RED")
.setAuthor(message.author.username, message.author.avatarURL);
return void msg.channel.send(noresponse);
}```
u mean with a message collector
@sterile minnow maxMatches is now max I believe.
it is
wasnt it always
okay i'll try
(serverQueue.connection.dispatcher.end("Stop command has been used!"),
await serverQueue.connection.dispatcher.end(
"Prepare for trouble. And Make it double"
),
(node:1463) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'end' of null
da heck
Guys can i add icon into description with markdown?
or the other method how can i do that
- .flat(2)
- ^
-TypeError: fields.flat is not a function
``` Help me
Question, how can I have the bot see what type of status i have? ex: online, idle, dnd
(if you can answer, please ping me)
I need something that allows me to give a role to a user that has successfully filled out a form on my website. What is the easiest way to achieve this? I have thought of having a field that requests the user for their Discord ID. I would then send the the field containing their ID as a webhook to Discord and then I would have to somehow create a bot that would read this ID and assign a role to the user. But Discord doesn't make it easy to share IDs, especially on Mobile, it's actually simple on Discord even if a bit hidden. So what other ways would you recommend to achieve this?
Question, how can I have the bot see what type of status i have? ex: online, idle, dnd
in which lib
I need something that allows me to give a role to a user that has successfully filled out a form on my website. What is the easiest way to achieve this? I have thought of having a field that requests the user for their Discord ID. I would then send the the field containing their ID as a webhook to Discord and then I would have to somehow create a bot that would read this ID and assign a role to the user. But Discord doesn't make it easy to share IDs, especially on Mobile, it's actually simple on Discord even if a bit hidden. So what other ways would you recommend to achieve this?
@lapis ocean
oauth, https://discord.com/developers/docs/topics/oauth2
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
require your users to sign it with discord before filling in the form
yo
i need help
how
to make bot say guild name in dm
so liek
Welcome USER To GUILDNAME
library?
python
bot.guilds.cache.memberCount
@heavy marsh check the docs? cache is a collection
thank you discord for messing that up
ahhh ...
python
Welcome USER To GUILDNAME
how to do that
when someone joinsd
joins server
in which lib
i have done this
bot.guilds.users.cache.size
@bot.event
async def on_member_join(sean):
em = discord.Embed(title='Welcome')
em.set_author(name=f'!WELCOME!')
em.description = ('Thanks for joining this awesome server')
em.set_footer(text='Bot made by: seañ#1718')
em.colour = (0xFF0000)
await sean.send(embed=em)
i have this
you know you can type what you're trying to say in one single message and not send 10 different messages to get the same point accross
stop spamming
guild name
you get passed the guild normally
bot.guilds.users.cache.size
@heavy marsh that returns the size of the collection
?
normally the member and guild
Nope thats is for me
oh 😦
you get passed the member object @limber flume
you can get the guild from the member object
e.g
member.guild
and you can get the name from that
why am i so dumb
i mean it would help if your var names wernt trash
calling somthing sean makes zero sense
[09/05/20 20:27:01] [ERROR] (node:22) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'cache' of undefined
hmmm
member.user.username?
Yes
bot.guilds.users.cache.size
[09/05/20 20:27:01] [ERROR] (node:22) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'cache' of undefined```
the
server
thing works
@modest maple
thanks for helping
can u do member.user?
the guilds property on the client is a GuildManager; https://discord.js.org/#/docs/main/stable/class/GuildManager
member.mention
can you stop spamming and collectively just type what you're saying in a single message holy
yeahhhhhh
we are not spamming?
no turn noti off
fuck u
^
why are you here?
hmm
its not funny
no
@earnest phoenix Be nice.
@limber flume Quit line spamming, send your messages in one.
@ember atlas why ? why i need to be nice? Why?
stop using your mental disorders as an excuse
@earnest phoenix Because I said. And continuing to be rude will cause further punishments so I suggest this all be dropped.
If no one here needs development support anymore, go to #memes-and-media
its not a eczxuse i do have it
@earnest phoenix Don't start that either
excuse
i know because i've been in a class with a dyslexic student lol but line spamming doesn't correlate to dyslexia
Doesn't mean you comment on something like that.
@ember atlas so, Alright i will be silent.
so uh
lets rewrite this conversation
whats the difference between x & ~y and x - y
erm
thats a bitwise operator i dont get
(node:82289) UnhandledPromiseRejectionWarning: SyntaxError: missing ) after argument list
this.client.shard.broadcastEval(`
(async () => {
let channel = await this.channels.fetch("${this.client.compile_log}");
if (!channel)
return;
const embed = new MessageEmbed()
.setTitle('Compilation Requested:')
.setColor(${(!!success)?0x00FF00:0xFF0000})
.addField("Language", ${lang}, true)
.addField("URL", ${url}, true)
.addField("User", ${author.tag}, true)
.addField("User ID", ${author.id}, true)
.addField("Guild", ${guild.name}, true)
.addField("Guild ID", ${guild.id}, true)
.addField('Code', '\`\`\`' + ${code} + '\n\`\`\`\n');
if (!success)
embed.addField('Compiler Output', '\`\`\`' + ${failoutput} + '\n\`\`\`\n');
channel.send(embed);
})();
`);
am I dumb?
reeee
yeah because i was doing stuff like 24 & ~8 which is 16 and 24 - 8 is 16
so yeah nvm
So amm in discord.js v12
bot.uptime = bots uptime
But is there a way to get the uptime of the messaged shard?
Ok nvm got it
hello i need coding help library python'
what do you need help with?
how to make it so
@bot.event
async def on_member_join(sean):
em = discord.Embed(title='WELCOME !!')
em.description = (f'Thanks for joining {sean.mention} to {sean.guild}! We Hope You Have A Nice Time Here')
em.set_footer(text='Bot made by: seañ#1718')
em.colour = (0x574ea7)
await sean.send(embed=em)
they can change the
message
Bruh i quit visual studio code by accident and now its gone from the taskbar (image) and it doesnt even seem to exist anymore wat
you need a database to store the message
how to
so that users can customize it
@earnest phoenix close it from task manager
i suggest not going there for now
i dont know how to do that
interesting
@limber flume it's a pain thing to make
damn
yes
hrm
only malwarebytes, discord etc
"Application does not exist"
reinstall
but i didnt even uninstall it
!Code:
message.channel.send({embed: {
image: message.author.avatarURL
}})
- Error:
image: message.author.avatarURL(),
^
TypeError: message.author.avatarURL is not a function
!!Info:
Discord.js | v12
Help
but the program doesnt launch if i make a shortcut
somehow it looks like the .exe is corrupted
but theres nothing that corrupts it on my pc tf
I need something that allows me to give a role to a user that has successfully filled out a form on my website. What is the easiest way to achieve this? I have thought of having a field that requests the user for their Discord ID. I would then send the the field containing their ID as a webhook to Discord and then I would have to somehow create a bot that would read this ID and assign a role to the user. But Discord doesn't make it easy to share IDs, especially on Mobile, it's actually simple on Discord even if a bit hidden. So what other ways would you recommend to achieve this?
What if my form system does not allow for oauth? @earnest phoenix
Any other smart ways to achieve this?
other than them inputting the id (which you can't really verify if it's actually their id), nope
Oauth would be the only way to truly verify it
or you can create a form like what discord bug testing uses, and have the bot accept that command
Can anyone help me
hi there
const isEven = (n) => {
return n % 2 == 0;
}
let printMsg = (evenFunc, num) => {
const isNumEven = evenFunc(num);
console.log(`The number ${num} is an even number: ${isNumEven}.`)
}
printMsg(isEven, 4)
what is that
i couldnt understand what it was
im trying to learn things I dont know and I couldn't understand what it was
it checks if number is even
% is modulus
Alright folks, I got it working, but I have serious concerns about safety. My goal is to send an embed with player information to a different shard. I have a snippet that works as intended, but unfortunately that means I'd be sending user input through broadcastEval. There has to be a better way of doing this. Any advice?
let e = `
this.supportServer.postCompilation("${code.replace('\"', '\\\"')}",
"${lang}",
"${json.url}",
"${msg.message.author.tag}",
"${msg.message.author.id}",
"${msg.message.guild.name}",
"${msg.message.guild.id}",
${json.status == 0},
"${json.compiler_message}");`
This call builds the embed that I need; and I need this to be called by all shards, but I can't think of a safe way to do it.
@tight forum what you dont understand? it looks rly simple
@earnest phoenix @amber fractal I didn't say I want to verify it.
I guess I could replace \" with \\\"?
There's no reason I would need to verify.
i know pangloss but I have been working for 15 hours
if you had an internal api running on all shards, you could send commands to it and tell it what shard to run it on I suppose
cant feel my brain anymore
n%2 == 0,
means only even numbers are going to be returned
I wouldnt do any eval with user input
someone can input another user's id, don't you think thats a bit of a safety concern? @lapis ocean
@tight forum yeah, np, just let me know if u need an explanation
@amber fractal what exactly do you mean by internal api
@earnest phoenix not at all, I want to give them a role, the form already is secure enough.
tyvm mate
234703377999593472 hereby apply for moderator
an actual server running across all shards, like an api just for each individual shard
My only problem is associating the 1. Person who Fills out the Form WITH 2. Person who has joined my server.
you could also specify port ranges if you want to do that so you wouldnt even need to provide that shard you want to run it on and instaed send it to the specific port
I wanted a better flow, because it's complicated to ask for people's Discord ID, especially when the vast majority are joining for the first time.
oauth is the only way to know it's actually them
But that's just what I think of first probably not even the best way 
so basically an mini rest api for that call
otherwise i can go ahead and pretend i am thaun for example
@earnest phoenix so what? If you pretend you are thaun, thaun gets the Role and you don't.
The Role is to give access to the server basically.
and you have someone that didnt apply for whatever having a role
what if it's malicious
I can't imagine of a possible attack vector like that.
At least not that I would worry about.
i would report your bot as buggy if your bot gave me roles for no reason
As long as the form is secure it's alright.
the form is not secure when they can manipulate the data
@turbid bough but imagine this is a form that charges $1,000,000 ?
Imagine it's a paid community.
uh?
Unless you hack the form there's nothing to worry at that stage.
No, but people will have a code.
code?
an only otp code which only that one user can use to confirm their identity they own the discord account?
@amber fractal do you happen to know of a way to send messages directly to a guild, skipping discord.js caches?
I know it was possible in v11
@turbid bough yes, except that the code is not tied to a user. It's single or limited use in some fashion
The've changed lots of their internals since then, so old methods don't work
because if I could hit the endpoint directly I could just serialize the embed
You could make the api call yourself, which isnt as difficult as you might think. But I would think all guilds are cached anyways
I like the Oauth idea, just can't apply it. I have webhooks though
im not sure how oauth and webhooks connect together
Yeah they're certainly all cached, but not on the shard I need it to be cached on 😄
oh
I think hitting the endpoint myself is the best solution here
Me neither, not the point. The system I have can pass the data via webhooks to Discord, that's my point. But I don't think I can use Oauth.
if you dont want to touch d.js just use a webhook
I also thought of passing the Discord ID as a URL Query parameter, but how would I do that?
The form could catch the parameter.
But no idea how to pass the Discord ID as a URL parameter or if there's even a way to achieve that.
what language do you use?
and what api for the website
or whatever idk what i should call it
I am not even a developer.
Else I would code an oauth solution
I am just looking at my options and then see what I have to learn.
im confused, you dont have a bot?
This conversation assume I could build the bot, because I will learn.
But I don't want to learn and then discover I can't do anything .
I still want to learn of course, but wouldn't prioritize it.
I am thinking high level here, to see which technologies I have to learn and what I have to connect with what to make this work.
you can practically use anything.
I know, I am trying to see what would fit what I have now. Because of course, one could always build anything from scratch.
its not important to learn everything, but once you got the basics of programming, you can pretty much use everything
Yes, but it's not practical at all to try to do everything.
Learn everything + do everything.
I found this: https://pathfix.com/
well, if you want to know how to make a secure and a good program, that would require learning many things
I wonder if this could help me create an oauth solution that can extract the Discord ID
But I need some special servers or something no @turbid bough ?
Some SSL Wizardry or whatever, lol sorry for the ignorance
if you need to host your own website/bot, then yes, you would need your own server, or buy one.
Not ssl, Oauth
Sorry for that
well, you just need to do a https request with the specified information
basically
you have an url to discord oauth, it includes a redirect back your website
discord oauth url is where you would login with discord
then once you logged in, the site will visit that page with a query code, which you can do to get access to a key
You make it sound very easy
it is
I actually have a bot on my Discord that does some OAuth magic like that.
Not coded by me of course.
you just send some data to discord, and then you get data back
const connection = await message.member.voice.channel.join();
const dispatcher = connection.play('./../../assets/random.mp3');
dispatcher.on('finish', () => {
console.log('Finished playing!');
});
So I'm just trying to play some random audio file from my assets folder right but when the bot connects it doesn't really play and just consoles finished playing.
I have installed:
Node-opus
ffmpeg-static
ffmpeg
@ me if you can help ❤️
I need some code running on a server I guess.
yeah
Could I do that with a webhost? That has PHP or something?
PHP or nodejs
I guess I could grab some php script that does that maybe no?
there is documentations on discord that tells you what data you can send to get access token, and with that token you can use that to get user info.
So the way I see that it could work is, the script would pass an oauth request to Discord, the user would authenticate, and then it could extract their Discord ID, and then it would redirect the user to a URL with the DiscordID in the URL QueryStrings and then my form would catch that
uhh maybe not in the url
And then the form would send the ID as a webhook to Discord, a bot would read it and assign the role to the user
the oauth is sent from discord. not to.
Why not in the URL? This way it would work with my current system
in your website, you link your login button to this link for example https://discordapp.com/api/oauth2/authorize?response_type=code&client_id=157730590492196864&scope=identify%20guilds.join&state=15773059ghq9183habn&redirect_uri=https%3A%2F%2Fnicememe.website&prompt=consent
and with that, once logged in it will send a query data to the website you are using.
So Discord sends data to that link right?
discord sends data to this link for example: https://nicememe.website/?code=NhhvTDYsFcdgNLnnLijcl7Ku7bEEeee&state=15773059ghq9183habn
and then you use your webserver to parse that code to get an access token
Basically I need a server to catch that data right?
yes
Looks like a webhook
well yes it kinda works like that
but you cant use that data for anything, so you would have to add login
you can read more about it here: https://discord.com/developers/docs/topics/oauth2
What do you mean "add login"?
logic*
Ah, yes of course
I guess it would be quite simple
Catch the Discord ID and redirect to a URL with that ID as a query string
you dont need to redirect with a discord id with a query
you can just use a session for that if the form is on the same website as where you set your oauth
I use a service to create forms. I'm not sure I can do that or why I would do it that way.
They have this feature at least.
Im not sure what service you use, but if that service allows users to login with oauth and validating the form's request, then it should be fine?
anyone used mysql.escape()? for some reason im getting errors using this
connection.query("INSERT INTO reminders (user_tag, msg, date, epoch, user_id, channel_id) VALUES('"+reminder.user_tag+"', '"+connection.escape(reminder.msg)+"', '"+reminder.date+"', '"+reminder.epoch+"', '"+reminder.user_id+"', '"+reminder.channel_id+"')", function (err, result, fields) {
if (err) throw err;
});
specifically around connection.escape(reminder.msg)
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test @night raptor'',
@turbid bough I think it doesn't. That's why I am trying to work it out this way. Should work just fine with a Query String no?
discord oauth does not work with query strings except from the authorization code
if you want to validate who want to send that form for example, you would need server code to compare to send that.
but im not sure
What goes into the auth header for the discord api?
@turbid bough What I was thinking was that the script on the server would redirect the user to a url with Query Strings
[Symbol(Response internals)]: {
url: 'https://discordapp.com/api/v6/channels/568172962855911435/messages',
status: 401,
statusText: 'Unauthorized',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
that wouldnt work if you are using oauth
it basically makes oauth useless
other than obtaining data
the form itself on the server would need to use the oauth
https://thsinterfare.is-inside.me/3WBVKtbx.png
How does the bot get this year?
it's 2020..
Even if you say it's the start of UET, it's not, so I question how it got this.
new Date().getYear() ?
Date.Now().getYear() ?
why did you new Date(Date.now())?
yeah i wonder that too
ikr it's the same
cause Date, isnt that a struct?
It's in v11
v11 js?
The Date class is built into js
what
has nothing to do with d.js
@turbid bough why useless? I don't understand why it wouldn't work.
Why would the form need to use the Oauth?
If you are hooking up a website form upto a discord bot that is going to do changes to a user, the form would need oauth for security etc.
its not that its required to
but its very reccomended
@pale vessel https://img.thaun.dev/f2bh0.png
yeah
is utc even important
no
on year
i mean if it's 31 dec
@turbid bough I'm just worried if it would work or not. I'm not so worried about hacking. If someone hacks it will be very obvious and the consequences wouldn't be nefarious.
The value returned by getYear is the current year minus 1900. JavaScript 1.2 and earlier versions return either a 2-digit or 4-digit year. For example, if the year is 2026, the value returned is 2026. So before testing this function, you need to be sure of the javascript version you are using.
idk, it would probably work
just add 1900 and you got the year
you can also save the time by adding "Full"
Is it possible to edit descriptions on dbl after you uploaded it?
Another solution would be to give them a code generated by the system, that is shown to them upon form submissions and/or email. And then they would input that code in the server.
how to react to message using emoji id across shard?
My bot @sick ibex randomly stopped working. It was working just fine until now. Now it doesn't do anything, except put this error in the console when I try to run a command
2020-05-09T22:31:04.215919+00:00 app[worker.1]: at /app/node_modules/node-fetch/lib/index.js:272:32
2020-05-09T22:31:04.215921+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-05-09T22:31:04.215921+00:00 app[worker.1]: at async Client.<anonymous> (/app/index.js:40:18)
2020-05-09T22:31:04.215968+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
2020-05-09T22:31:04.216031+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Somebody help?
website prob broke
What website?
https://disease.sh/v2/all
It's returning html, not json
Same here
you should check for errors before parsing
I did it :D
Since when is v13 out 🤔
Since i forked discord.js xd
actual v13 is gonna be ts rewrite tho and it's barely been started
I forked the commit hash before managers were imtroduced
Imported a few bugfixes from later commits and called it v13.0.0
Its mstly for my own bot anyways xd
Nice major version change for patches lol
V12.0.0-dev wasnt a major change
actual v13 is gonna be ts rewrite tho and it's barely been started
@smoky spire can I get a source please
@delicate zephyr
Yes they did
djs is a trainwreck
is like trying to fit a elephant on a hamster
My fork is pre .cache managers with futur3 commits
it should be way more modular than it is and the caching is garbage
no control
all or nothing
And the worst cache is the presence cache
The day we can disable caching
presence cache is so niche
the better
3GB memory/3 day uptime
280MB memory/3day uptime PRESENCE_UPDATE disabled
even eris doesn’t have good caching control
there is no mainstream js lib with even mediocre caching
Mainstream no
@earnest phoenix not surprising
but tbf, Tim made a decent for of discord.js
Not just that, its per MEMBER
AND USER...
One member in 8 guilds = 9 presences of the same person with different ids in guild
Its awful
Like fr why
tbh
the only thing you should be caching
is the custom statuses / game statuses
can anyone save me from this hell dependency injection
otherwise just store the online/dnd/away/offline in a cache with only ids
presence update alone was making me go over the bandwidth limit on my vps
I wanted to cache the statuses, not everything everywhere
So i got rid of all of them instead
i would cache absolutely nothing but I need message cache for edit handling to work
check out contabo
/mo
contabo is good but they rejected my details and asked for my id
Nono contabo bad tho
so I can’t use them 😂
its good for starter jens
Try galaxygate, no bandwidth limits but theyre sorta half out of stock rn
@white anvil if not check out https://oneprovider.com they do Really cheap dedis
With over 140 datacenter locations in the world, OneProvider is your one stop for dedicated server hosting solutions in the location of your choice.
trainwreck of a provider
but you can request
Its where rythm is hosted at though
and they'll do it

so??
wym galaxygate is good lmao
lets not have a host war
Bruh..
someone send me money for the ryzen vps
right after luke said that lmao
Its uptime is better than discord's LMAO
Stop. Final warning.
ok epic
No ur supposed tosay ok luke
either way I only have 200gb bandwidth limit on my vps
which is fine by me
im so conservative of what I send and receive with my bot that I only use like 1/10 of that a month
I only have messages intent
it’s not rlly unlim
it is lol
they will eventually throttle u
They dont 
all hosts do
oneprovider hasnt since i started using them
we've had 1000/1000 the entire time
if u push it too much they will
well yea
if you start using 1000/1000 for a month straight
granted I don’t need a dedi
On provider dedis are fairly cheap for the low end ones
I have a 2-core intel xeon and I use about 10% of that on average
and youre paying 2 quid?
how much ram
storage?
o
you can’t have a dedicated machine at that price that is cost effective and also performant
we use this one https://img.ichigo.uk/n3bTvCTF3zxV.png
that’s probably okay
Its been doing great
hetzner sell $30 dedis with 2gb ram btw
why
- hexa core ryzen
windows...server?
oh
that vswitch
why does JS use string for ID's but Discord.Net use ulong's??
yea
all I do on my pc is write shit c and watch YouTube
won’t even be able to take it to uni when I go this year
too bulky
need laptop
it’ll just sit in an attic losing value daily until I graduate in 4 years and it’s worth $20
:D
lul
crazy usage
Pretty much guarantee that if most of the traffic on your dedi comes from discord bot, 1.9TB of it is presences
do u not track presences
I do
does anyone know how to limit how much discord.js can cache? it tends to overload my vps if it doesnt get restarted for a few days
I just use the raw data
wdym
setup my own caching
why lmfao
o tru thanks
ah
Or just make your own lib
why
pointless
waste of time
it’s such a challenge to make a good library from scratch that is really not worth it if what you want can be achieved with existing libraries
Well atleast there wont be shit to complain at, because it'd be your own shit then
and in 99.99% of cases it can
I mean. yea, but like you learn a lot
or if you want custom shit use a gateway and rest handler and build from them
which is why I tried origionally
I learned a lot from reading the source for https://github.com/detritusjs/client-socket ngl
interesting stuff
How do I automate testing of my bot?
seeing how zlib is implemented
Like with unit/e2e tests
My bot is in discord.py
(if anyone has experience with it in some other language/library, I'd love to hear it)
you replicate discord's api
does anyone have experience with how best to implement ratelimit buckets using js
im not so proficient at promises that I know how to do it lol
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:1047:16)
at Module._compile (internal/modules/cjs/loader.js:1097:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74
:12)
at internal/main/run_main_module.js:18:47
can some one dm me with help please
@twin smelt haven't seen your code and haven't used js in a while but you probably forgot or accidently deleted a ) at the end of a function's argument list
@next remnant const Discord = require('discord.js');
const bot = new Discord.Client();
const token =
bot.on('ready', () =>{}
console.log('This bot is online');
})
bot.login(token);
i removed the token
I’m only starting in development and I’d like to know how with discord js create unique variables for each server
Use a database
whats wrong here?
@smoky spire thx
I hope that is not your real token
@tight bough some people also use a json file.
no
@twin smelt please be careful. You posted your token
Please reset your token and be careful about posting any code here beforehand
Can i use the emoji from another server with webhook?
Bots can use any emoji from any server they're in anywhere
But this a webhook
Oh misread the question
You probably would only be able to use the emojis in that server but I'm not 100%
@smoky spire, thanks for answer
what ?
yes..?
check the docs 
also ur actual like status message is a normal string
so template literals dont work
use ``
yeah !
I want to insert an array in mysql but I don't know how.
just convert it to a string/join them
Hello, I'm trying to make it so that when my bot replies to a message, it also attaches a gif. I have the link for the gif, but the only way that I know of making the bot show the gif is by sending the link. I don't want the link to be visible
So, basically, how do I make a bot post a gif without posting a link
Here is the line that I currently have the bot using :
message.channel.send('https://cdn.discordapp.com/attachments/708845028713300111/708871257847758869/8e96ceec5152605463bf264b1ad18bda.gif')
I'm using Visual Studio Code with Discord.js
Here is the rest of the command if you need more context:
case 'hello' :
message.channel.send('Thank you for greeting me. Hello to you, too! 😄')
message.channel.send('https://cdn.discordapp.com/attachments/708845028713300111/708871257847758869/8e96ceec5152605463bf264b1ad18bda.gif')
break;
If you have any ideas, please @ me
@reef heath
Look at the examples shown. You can attach local files or even urls (Which is the better method to save bandwidth)
urls is the better method?
https://discord.js.org/ is discordjs's documents I recommend you have a look through it if you ever are looking for a feature you require in your bot.
sending a file via a url yes
Hello.
because you arn't uploading the file everytime someone sends a command that the bot responds to.
right.
since it's already uploaded.
if you look for it yes.
how can i stop this?
there were commands, I forgot
it shows like that constantly
it's telling you it's starting the app, and is saying they turn off projects that are inactive to keep glitch running fast.
basically so that you can't run a bot or something off their servers
Do you have this command that should be like this?
This is a command to be thrown to bot.js, but I don't have this command, can you help?
I'm still confused on what your talking about.
Oh the glitch app isn't starting?
that's a glitch problem probably. Run the code locally, makes it a lot easier for developing anyway
The boat is running now, but the logs are not in place, they keep turning.
honestly I wouldn't really bother with Glitch, I recommend moving to a local environment
let app = require("express")();
app.listen(8080)
app.get("/",(req,res)=>{res.send("OK")})
I was talking about these codes.
I got the problem fixed :D
hey, my code has 1 error and it's bugging me. i'm not sure if it's doing any damage, though, but i don't know how to fix it, either.
in this line: switch(args[0]){
it underlines "switch" and says " ',' expected "
dude use fucking code blocks smh
it's not that hard
like
it's literally ```language here
code here
```
switch(args[0]){
//command "help" - Pulls up a list of the bot's commands
case 'help' :
message.channel.send('__Here is a list of my commands__:')
message.channel.send('"**a.help**" - Pulls up a list of my commands.')
break;
}```
wow
that's great! thank you!
anyways, it underlines "switch"
and says that it expects a comma
show the code before it
const Discord = require('discord.js');
const bot = new Discord.Client();
// token allows the code to send content to the bot. It's like an access password.
const token = '(not showing bc private)';
//set bot prefix
const PREFIX = 'a.';
//make bot online: open terminal (ctrl + ~) make bot online (node .)
//make bot offline: open terminal (ctrl + ~) make bot offline (ctrl + c)
bot.on('ready', () =>{
console.log('bot is online')
})
//bot only responds to messages that start with "a."
bot.on('message', message=>{
if(message.content.startsWith('a.') == false) return
let args = message.content.substring(PREFIX.length).split(" ");
}
switch(args[0]){
//command "help" - Pulls up a list of the bot's commands
case 'help' :
message.channel.send('__Here is a list of my commands__:')
message.channel.send('"**a.help**" - Pulls up a list of my commands.')
break;
}
//tells the bot to log in with the token
bot.login(token);```
the switch statement isn't inside of the message listener
wdym? i'm really new to all of this
switch (stuff) { }```
is this: { } message listener?
The switch isn't inside the event
so
message-event { switch (stuff) { } }``` is how your code would look if the switch was inside the message listener
OH
thanks
sorry for being a dumbass
let's see if that fixes things
It created 9 new errors 😦
okay hang on hahah
{ switch(args[0]){
//command "help" - Pulls up a list of the bot's commands
case 'help' :
message.channel.send('__Here is a list of my commands__:')
message.channel.send('"**a.help**" - Pulls up a list of my commands.')
break;
} }```
i'll bold errors?
i'm trying to run a loop with this
with open('/path/to/data.json', 'r') as a:
data = json.load(a)
bot = commands.Bot(command_prefix="REEE")
async def update_statuses():
await bot.wait_until_ready()
while not bot.is_closed():
guild = bot.get_guild(433011085369409551)
owo = guild.get_member(365255872181567489)
yoshi = guild.get_member(488532005206884353)
spood = guild.get_member(585225058683977750)
data["avatars"]["owo"] = owo.avatar_url_as(format="png")
data["avatars"]["yoshi"] = yoshi.avatar_url_as(format="png")
data["avatars"]["spood"] = spood.avatar_url_as(format="png")
data["statuses"]["owo"] = str(owo.status)
data["statuses"]["yoshi"] = str(yoshi.status)
data["statuses"]["spood"] = str(spood.status)
json.dump(data, open('/path/to/data.json', 'w'), indent=2)
print("Statuses updated")
await asyncio.sleep(30)
bot.upstats = bot.loop.create_task(update_statuses())
and nothings happening
show the error
Not necessarily
lemme try that
not defining it worked
alright
i dunno whats happening but i can't write to my json
👀
Some one pls help me
My bot keeps resetting it's token 😦
I can't get it to come online 😦
anyone wanna collab ?
@shut inlet on what?
If I'm honest, I hardly know anything, but I'm a very hard worker
heres my youtube (not advertisement)
just dont
why would we need it
anyways i need some help
if i have this ```
module.exports = {
config: {
name: "say",
},
run: async (bot, message, args) => {
let text = args.join(" ");
if(message.content.includes('@everyone') || message.content.includes('@here') || message.content.includes('<@&') || message.content.includes('<@'))
return message.channel.send('No pings allowed!').then(msg => msg.delete(5000));
if(!text) {
message.reply("tell me something to say!")
};
message.delete();
message.channel.send(text);
}
}``` how would I make it so that if someone edits there message then the bot would edit the message with there updated message on the bot
their
client.on("messageUpdate", require("./message.js").run) or whatever
couldnt i do if(messageUpdate) ?
no
yeah ik im just lazy
why do u put async if u dont use await :/
no because old message is the first param
eh
if i have this ```
module.exports = {
config: {
name: "say",
},
run: async (bot, message, args) => {
let text = args.join(" ");
if(message.content.includes('@everyone') || message.content.includes('@here') || message.content.includes('<@&') || message.content.includes('<@'))
return message.channel.send('No pings allowed!').then(msg => msg.delete(5000));
if(!text) {
message.reply("tell me something to say!")
};
message.delete();
message.channel.send(text);
}
}``` how would I make it so that if someone edits there message then the bot would edit the message with there updated message on the bot
@astral yoke
First of all: the function u included has nothing to do with editing messages. Secondly, a bot can not edit the messages of other users. Nobody can.
No no, not edit there message, when you do db!say hi then edit it to like db!say hello it would also edit his message to catch up with the edited one
do you know what i mean
they mean that if you edit a message the message event will fire
sorry bout that
you mean their message
there a place - the apple is right there
their possessive noun - that's their car
they're literally means they are
im debating on wether i should use mariadb or postgresql (i think thts wht its called) for my bot
@steel drum depends on what ya doing
on one hand im pretty sure postgresql provides better preformance but mariadb provides bult-in clusterization management stuff
i dont know if i want to look THAT FAR in advance to worry abt bot clusters
I use a mLab mongoDB for prefix storing
im more interested in storing
alot of data
like each user can get "cards"
and have it all in some sort of table
for easy filtering & stuff
I'm trying to get all members of all servers, bc bot.users.size return an incorrect number, i have try to do something like this
bot.guilds.forEach(g => {
console.log(g.memberCount)
});
But it's returning a list of all servercount, someone know an another method?
how big is your bot?
Create a variable sum with value 0
on each iteration, add memberCount to it
if (message.content.startsWith(prefix + "t")) {
const GIFEncoder = require("gifencoder");
const { createCanvas } = require("canvas");
const fs = require("fs");
const encoder = new GIFEncoder(320, 240);
// stream the results as they are available into myanimated.gif
let stream = encoder.createReadStream();
message.channel.send({
files: [{ attachment: stream, name: "myfile.gif" }]
});
encoder.start();
// use node-canvas
const canvas = createCanvas(320, 240);
const ctx = canvas.getContext("2d");
const background = await Canvas.loadImage(message.author.displayAvatarURL);
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
encoder.addFrame(ctx);
encoder.finish();
message.channel.send(stream);
}```
im trying to figyre out how to add text but its not working
ctx.fillText("t", canvas.width / 2.5, canvas.height / 1.8);```
i tried to add that but then it would send the image at all
TypeError: require(...) is not a function at ["console", "command", "event"].forEach(x => require(`../handlers/${x}`)(bot));
why does this happen
what are you requiring it for
my handlers
also what's up with these 02 avatars
me?
its a different folder
called handlers
which the handlers
command
console
and event
not working
how to fix
how are we supposed to know how to fix if we don't even know what's not working
also, seems more suitable in #topgg-api
ok
how can I check if an image is a gif format and without using filenames
you can check the file's header text
k
Can anyone help me with HTML coding?
Don't ask to ask
I have added login system on my website i want to make it fetch user's server bot is in
Just like Dyno and mee6, it shows user's server after login
How can i do it? Anyone help me with an example pls
Or even youtube, many many MANY good tutorials.
you cannot do it with raw html
you cannot do it with just frontend
you need a backend server to handle authentication
can anybody please help me with sending a simple avatar image with a normal message (no embed) in d.js v12. I don't know what they did but I've never struggled so much with such a simple thing
MessageAttachment()
embeds down?
image and thumbnail
@summer torrent thanks, it's finally working
how big is your bot?
@wanton nova 163k members
But only shown 70k
Create a variable
sumwith value 0
on each iteration, add memberCount to it
@slender thistle
bot.guilds.forEach(g => {
var sum = 0
const total = sum + g.memberCount
console.log(total)
});
Something like that should be work?
well
sum = 0
first iteration: sum = 5 (membercount = 5)
second iteration: sum = 10 (membercount = 10)
You're resetting the sum variable every time an iteration happens
lmao
@earnest phoenix var before the foreach
also it might spam your console depending on the number of guilds
yeah but i just want only one number
bot.guilds.forEach(g => {
const total = sum += g.memberCount
console.log(total)
});```
Okay so, that shit work
That shit do work
is this valid sql syntax, it says i have an error near "?"
let sql = "UPDATE timezones SET user_tag = ?, user_tz = ? WHERE user_id = ?";
let inserts = [tzData.tag, tzData.tz, tzData.id]
connection.query(sql, function (err, result, fields) {
if (err) throw err;
});
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, user_tz = ? WHERE user_id = ?' at line 1
the purge command
bot.shard.broadcastEval('this.uptime')
Will give this that shard uptime? - I mean the command works but does it give the proper shard uptime?
I am using v12 of discord.js
cache ig
ig?
cache - where?
hmm ok
That's not a thing, you have it right
?
The code you sent is good
But I dont think I get the correct uptime
Cause like a few minutes ago my shard disconnected and resumed
But still shows the same uptime
Because the uptime is on the client and not the shard
Idk
hmm
I mean
@heavy marsh using discord.js?
Internal sharing I presume
If so you can use process.uptime since each shard is its own process
so bot.process.uptime
Nope it shows NaN
how do i make the try; jump to catch if there is no match?
try{
console.log("update 1")
let sql = "UPDATE timezones SET user_tag = ?, user_tz = ? WHERE user_id = ?";
let inserts = [tzData.tag, tzData.tz, tzData.id]
connection.query(sql, inserts, function (err, result, fields) {
if (err) console.log(err);
console.log(result)
});
}
catch(err){
console.log("insert 1")
let sql = "INSERT INTO timezones (user_id, user_tag, user_tz) VALUES(?, ?, ?)";
let inserts = [tzData.id, tzData.tag, tzData.tz]
connection.query(sql, inserts, function (err, result, fields) {
if (err) throw err;
});
}
it returns this in result, when no match is found
OkPacket {
fieldCount: 0,
affectedRows: 0,
insertId: 0,
serverStatus: 34,
warningCount: 0,
message: '(Rows matched: 0 Changed: 0 Warnings: 0',
protocol41: true,
changedRows: 0
}
These functions are also available on the base Discord object. https://discord.js.org/#/docs/main/stable/class/Util
const Discord = require('discord.js');
const str = '`Hello world`';
console.log(Discord.cleanCodeBlockContent(str));
=> TypeError: Discord.cleanCodeBlockContent is not a function
How?
are you sure youre on the right version
yes I'm on v12
@tawny ledge no, docs say its available on the Discord object
definitely
ok
^


