#development
1 messages · Page 1916 of 1
It’s actually a good idea to play around with a database and collect some experience if you already got the time for testing things anyways
i did
timeout: 5000,
and 5000 = 5s but it is counting as 1 hr 23 mins 20s
https://media.discordapp.net/attachments/906399068408905758/906399408990584852/unknown.png
https://srcb.in/ObTfL8deb6
line 69 onwards
Unix format
?
Actually, it's probably even less precise than unix nvm, it's definitely unix
Check the input time unit
Ye, totally unix
camelCase
🐪
🐫
@earnest phoenix no ads please, thx.
I sent it here by accident, it was bad
client.on("guildMemberAdd", member => {
console.log('member detected')
member.guild.channels.cache.get("906309395439304715").send(new MessageEmbed(
{
title: `Welcome <@!${member.id}> to the server!`,
description: "Make sure to check [#906308769368125543](/guild/264445053596991498/channel/906308769368125543/) and verify at [#906308242630639636](/guild/264445053596991498/channel/906308242630639636/)",
footer: {
iconURL: "https://cdn.discordapp.com/attachments/906456481589768192/906456916723638282/Cloud_Zone_Blurple.png",
text: "CLOUD ZONE"
},
color: "#43B581"
}
))
})```
There is a empty message error....
ah
I'm used to 12.5.3
¯_(ツ)_/¯
Hmm no
Still the error
thanks
Works
Poor @ user
does that even exist
Yep
Then user doesn’t exist ig
@surreal sage @carmine topaz
Tell them reason for pinging instead of randomly pinging 
The title can not contain a mention
As well as the footer
The description can contain a mention as well as fields

:/
i reinsalled it and it still ha all my plugins etc
i supposedly closed it while it was updating
a category counts as a channel right
I want to cache.get a category
does a category fall under guild.channels?
extends guildchannel
ight it does
const embed = new Discord.MessageEmbed()
embed.setColor("RANDOM")
embed.setTimestamp()
embed.setFooter("Your KPOP dealer!")
const keys1 = Object.keys(carddatabase)
const prop1 = keys1[Math.floor(Math.random() * keys1.length)]
const keys2 = Object.keys(carddatabase)
const prop2 = keys2[Math.floor(Math.random() * keys2.length)]
const keys3 = Object.keys(carddatabase)
const prop3 = keys3[Math.floor(Math.random() * keys3.length)]
embed.setDescription(`${message.author} is dropping cards! Lets bake it for 20 minutes!\n\nAfter 20 minutes you can claim ONE card by clicking the corresponding emoji:\n`)
let emoji1 = await message.channel.send(embed, {files: ["./cards/"+prop1, "./cards/"+prop2, "./cards/"+prop3]}```why is this sending me [object, object] and then the 3 images?
I am trying to send the embed with the 3 images inside the settdescripttion
nope doesn't work
I am on v12
how to get the id of a channel that just was created
channelCreateFunction.then()?
The vsc thing that shows the properties ect doesn't work properly
Can't see the shit
I want to fix my ban command where if u have the permission to ban, u can ban also members with a role higher than your.
How can I check the role position?
role.position
but I still don't know how to fix this command, lol.
I should put the roles inside an array and check?
Get the role of the member you are going to ban
.position that and calculate if its higher then the person that bans the member role
btw member.roles.highest.position
afaik you can't put multiple images in 1 embed
@rustic nova
Yup
really?
yes
how is this done then?
it's not an embed.. but still trying to figure out how it's done.
that's generated image, combining 3 images into 1 image
AHA! Can probably do the same using jimp
How can you delete the pin message using the latest discord.js?
I'll find a way, don't respond yet ty ❤️
how do i actually use jimp to put 3 images next to each other?
I tried finding their docss but they have no articles about this subject.
are you searching for "jimp combine images" or "how to make a gacha game discord bot with jimp"
jimp combine images
they are all about compositions and adding layers
Yeah it doesn't really do the job for me
it literrally composites 2 image layers onto each other
but i want it to be next to each other
you take one base image and layer 3 other images on top of each other with a specific offset
layer the small squares on top of the red square
then figure out the math to have the final thing centered
yeah i could also just make it easier by using a join-images package
god forbid you try to solve a problem one time
How do you make a interaction button disabled after it has been pressed?
respond with an edit response and give it a button of type disabled
Could you give a snippet?
Cause I can't find the shit in docs
nvm i got it
int component
^
TypeError: SpotifyPlugin is not a constructor
?
client.distube = new DisTube.default(client, {
emitNewSongOnly: true,
plugins: [
new SpotifyPlugin({
parallel: true,
emitEventsAfterFetching: false,
api: {
clientId: "x",
clientSecret: "x"
}
})
]
});
if (target.permissions.has("ADMINISTRATOR"))
I don't get why this doesnt work
Component.set* doesn't seem to give a effect.
Any solution?
discord.js version?
13
ok
13.3.1
Is it necessary that { should be put on a new line in C#?
code?
nvm, I've fixed it, ty same
ok
no but its a c# convention
sweaty c# devs will probably make comments if you put it on the same line
I'm a sweaty js dev
you ever go back to a codebase after a couple months and have no idea wtf is going on
couple minutes for me
I wrote so much code and I have no idea what any of it does
I think he meant the other way around
it only takes me a couple minutes to forget wtf my code does
might be worse in top.gg's case
its fine not to admit
i dont comment my code, so every single time i have to relearn what it does
I have a ton of comments and I still don't know what I'm looking at
though it's slowly coming back to me
xD
yes very helpful comments
xD
hello other Tim 
hullo
that is an interesting code style for that return block 
also interesting borrow
what's wrong with it?
can't you manually expire a token?
not my website
you're double borrowing for no reason
and the styling Is just a pet peeve, if you stack the attributes like that then I tend to prefer doing
let foo = self
.creds
.clone()
.try_read()
.map(...);
return Ok(foo)
oh I probably wasn't borrowing it at first and forgot to remove it when I changed the method signature
literally anything is fine
1
what do you mean by that
the data is persisted directly to the filesystem so you can do as many reads as you want but only 1 concurrent write
sqlite is usually enough for most people's needs
sqlite libraries handle queueing writes for you
if you're going to be on a single process sqlite is fine. It's easy to migrate the data on it to other relational dbs if you need to switch things up later
currency bots lol
What lang?
Js then
Also, when using sqlite don't multithread write ops
You can have multiple parallel processes for read operations
But keep write operations synchronized
The issue with sqlite and pretty much any other file-based database is that only 1 write operation can be happening at my single time
pretty sure the node sqlite lib should be handing write queues for you
There is
unless your bot is sharded
Don't recall the name tho
Are u using a writing queue?
Actually, show the code where that error happened
@modest maple do you do CI/CD in github actions? how do I setup rust builds so they don't take 10 million years lol
idk what you're building but my average build time on there is like 5 minutes or so?
that's a lot 😦
Are u using transactions?
oh no 1.56?
what
but my epic captures
Idk how to explain what is a transaction
But like, if you forget to close it after writing it might hold the database hostage
I compile in release mode on my CI because the unittesting is too long otherwise

search engine testing and indexing test 😉
my dockerfile builds fail cuz sqlx can't connect to the db I'm so sad

name: Rust
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build main
run: cargo build --verbose
- name: Run main tests
run: cargo test --release --verbose -- --test-threads 2 ```
le simple ci
I also need to build a dockerfile though
I mean yeah, for the sqlx connect issue at build time is a lol
just done use compile time checks in build ig 
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: '35 8 * * *'
push:
branches: [ master ]
# Publish semver tags as releases.
tags: [ '*.*.*' ]
pull_request:
branches: [ master ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: chillfish8/lnx
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1.9.0
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v2
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
``` my docker ci is very basic
sqlx prepaer seems like it's working
how much concurrency are you talking about? sqlite can easily make hundreds of writes per second, if not thousands
use WAL mode and set synchronous=off, also use better-sqlite3 if node.js, not sqlite or sqlite3
That's why I thought abt open transactions
Sqlite is hard to hit two writes at the same time
I mean its impossible
outside of a new connection per write
but that still has a lock
also sqlite transactions are per connection so it can be a lil iffy
if your sqlite is still being overloaded, you can also implement eventual consistency
what i like about sqlite is that its easy to configure it and scale it your own way
I used to use sqlite fully in memory as a caching db
The I'd unload it onto the main db each hour or before restart
Shit is so small it doesn't really matter how much data u put in it
ye
and because its in-process and uses mmaps and shit, its way faster than any thing that uses sockets or tcp
like redis
Such that most dbs use sqlite internally somehow
Be it for settings or plain caching
why doesn't
const Channel = client.channels.cache.get("1234567890");
``` work anymore?
i mean its been working in my bots for the past year and a half
and now it returns undefined
Check your channel ID then
is the id hardcoded?
and which one is not working?
both
one sec
also which version of djs are you using
run: async function(client, message, args){
if( swearWords.some(word => message.content.toLowerCase().includes(word)) ) {
message.reply("sorry no swears").catch(error => {console.log(chalk.red('[ERROR]') + " COULD NOT SEND MESSAGE " + error); });
}
else{
let msg = message.content.split(" ");
message.delete().catch(error => {console.log(chalk.red('[ERROR]') + " COULD NOT DELETE MESSAGE " + error); });
message.channel.send(message.content.slice(6)).catch(error => {console.log(chalk.red('[ERROR]') + " COULD NOT SEND MESSAGE " + error); });
}
}
``` this code has not been altered in a year
idk some version of v12
and what is the issue with this code?
channel id is undefined
Am I blind? I don’t see you getting the channel ID anywhere
there is no channel id in that code?
it’s not me then phew
Lol
one sec
my files aren't that organised
if (command === "say") {
const Channel = bot.channels.cache.get("1234567890");
if (!Channel) return console.error("Couldn't find the channel.");
Channel.send(message.content.slice(9)).catch(e => console.log(chalk.red('[ERROR]')+` could not send message: ${e}`));
}
``` this is the one
You sure your var is bot in this case not client?
Dat casing tho
this is from a year ago
So I'm trying to make a modmail system but for some reason the channel collector is collecting the same messsage. Any help would be great!
const discord = require("discord.js")
module.exports = {
name: 'modmail',
aliases: ['mail'],
execute: async (client, message, args) => {
const mes = await message.channel.send("I have sent you a dm.")
const config = require("/home/runner/Bot2/Handlers/config.json")
message.author.send("Start typing to chat with the moderators.")
.then(async (msg) => {
const filter = m => !m.author.bot;
const collector = await msg.channel.createMessageCollector({
filter,
});
const channel = await message.guild.channels.create(`${message.author.username}s-modmail`, {
permissionOverwrites: [{
id: config.mainrole,
deny: ["VIEW_CHANNEL"],
}, ],
})
collector.on("collect", m => {
channel.send(`${m.author.tag}: ${m.content}`)
const filter = mm => !mm.author.bot;
const channelcollect = channel.createMessageCollector({
filter,
max: 1,
});
if (m.content == "?mmclose") {
m.reply("Modmail will be closing.")
collector.stop()
}
channelcollect.on("collect", async mm => {
if (mm.content == "?mmclose") {
return channel.delete()
}
m.author.send(`${mm.author.tag}: ${mm.content}`)
console.log(mm.content)
})
})
})
.catch(error => {
mes.delete()
message.reply("Something went wrong. Make sure your dms are open. If this happens if when your dms are on then dm !Kweeper#8053")
})
}
}
I don't know why this happen because I've set the max messages to 1 and the dm collector max to 1 but it breaks.
Oh nooo 4s to scroll up again 
lol
is that channel id a channel from your guild?
where is the channel from?
Oh how I love to read code in mobile
help because im dying lmao
Imagine if someone created a site for showing code to others...
/s
https://stackoverflow.com/questions/69864577/why-is-my-message-collectors-collecting-the-same-message
or just see this lmao
the ID there is of the general channel in a server the bot is in
lol iOS doesn’t even have colors in code blocks wtf
Skill issue
lol
you dont await channel.send() so the collector is created before the dm is sent
oh lmao thanks i'll try it
are you in that server? can you confirm that channel still exists?
console.log that guild's channels and check
Somebody may deleted it and added a new one
its there i just updated it incase it changed or somthing but nope still the same error
could u tell me what line is it on lmao
aight thanks
console.log the guild's channels
no
only found out about this error whilst working on another bot that posts individual lines from a txt file to a sertain channel and it uses the same channel id thing
and yes all the ids are correct for both bots
the other bots code is
for await (const line of rl) {
const Channel = client.channels.cache.get("760176465513414697");
const link = ["https://"];
if (!link.some(word => line.toLowerCase().includes(word)))return
console.log(`Line from file: ${line}`);
sleep(5000)
}
If u use many repeated operations it might be handy to make controller classes (or files whatever)
Like, instead of having 30 "SELECT * FROM user" just make a file and make a function that does it
did you log the guild's channels?
Less places to change, easier maintenence
console.log(client.guilds.cache.get(guild id here).channels.cache)
Good, that's a good habit
i mean i just coppied the ID from the channel and pasted it in both the bot and I are in the same server and bothe have write perms in the channel
I cringe when I see 6764649 repeated sql queries all around the codebase
thats not why im telling you to log them
just do it
put the console.log code just before the .channels.get() code
...
thats a completely different error
that has nothing to do with channels
or the problem you were describing
that error means client is undefined
bruh
but it is defined though
Aaaaand we came all the way around to the start
junk.js line 27
or else the other parts of the bot wouldnt work
show junk.js
ok so that error means the guild doesnt exist
i put the consol log in the other place two but it didnt work their iether
if the guild doesnt exist, neither do all its channels
but it does
are you using intents?
whats that?
thought those where for when you wanted to see when member joined and left
do you have new Discord.Client({ ws: { intents: ... } })
cuz thats privalaged or somthing
?
i tryed using intents ages ago when the guild.user.add/remove got broken but it never worked so i just commented that out and lived with some stuff not working
i mean i have another bot that doesn't have intents but it can list the servers and channels in those servers just fine
If u didn't appear here this year you'd probably suffer when your messages suddenly stopped having content
?
i mean on of my other projects has a command that just returns "cannot send an empty message now when i cwant it to repeat somthing
Message content will be a privileged intent
It is already
But they're giving a grace period
wait what
After it ends, all bots without it will receive only blank messages
why
Except its own messages or those which ping the bot
thats literally gonna break everything
It is
so why do it
Are u still asking why for discord choices?
lol
I stopped when they rebranded the site
ah so im not the only one that detests the rebrand
Another why moment
i mean its not that bad but the logo being a circle and the new colours are what really annoy me
the shade of blue hearts m,y eyes
and the green doesnt match
omg 😭 after 2 years of building 600mb nodejs dockerfiles I finally have a normal size image

and you would have thought they would have fixed the fact stuff doesn't match up
and the fact that when using a 4:3 ratio monitor nothign is a circle anymore
looks fine on mine as well
im on the app lol
Me 2
infact i think the circl issure is just my monitor just in the screen shot they look alright
What does this:
let user4Sucks = client.users.fetch(player4).then((user4) => {
});
Return? I am trying to use user4.voice.setChannel(<some_channel_id>), but user4.voice returns undefined.
Var
use await
That too
fetch returns a Promise<User>
Guys can you help me? My bot is crashed
2021-11-06T15:54:11.346531+00:00 app[main.1]: /app/node_modules/discord.js/src/client/ClientDataManager.js:81
2021-11-06T15:54:11.346549+00:00 app[main.1]: guild.channels.set(channel.id, channel);
2021-11-06T15:54:11.346550+00:00 app[main.1]: ^
2021-11-06T15:54:11.346551+00:00 app[main.1]:
2021-11-06T15:54:11.346551+00:00 app[main.1]: TypeError: Cannot read property 'id' of undefined
It's not really about supporting things or not, more like different browsers have default settings for various elements.
Like Apple handles tables, font-sizes, p and other elements differently than other browsers do, especially talking about the default padding/margin.
ah okay. thx
Apple always breaks everything
oh. I may be stupid
It's not breaking but handling the elements differently
Send the full stacktrace
At least their default style
To fit into the Apple ecosystem
That's why you can disable most of their webkit pre-settings
also why am i getting friend requests from bot accounts that aren't even in server im in
banned here
they were scam links
ah
I'm still having trouble moving users to a VC. Even when the bot is Admin and every single user is in a VC, user.voice returns undefined.
let user1 = client.users.fetch(player4).then(async (user) => {
// Do stuff
// Wait because moving user to a newly created VC
setTimeout(async function () {
if (!user.voice || user.voice === "undefined") {
// This always happens
console.log("Could not move players to the voice channel.");
return;
} else {
await user.voice.setChannel(channel1ID);
}
}, 4000);
});
user.voice is not a thing
oops. edited
also, you're trying to use user but you defined it as user1
if (!user.voice || user.voice === "undefined")
"undefined" is already covered in !user.voice
oops ill fix that to
And undefined isn't a string
aight
enough also(s)
A l s o
im calling that piece of code inside a function tho. how would i make that function async?
Function() { can be expressed as () => {
function someFunc(message, userId) {
let userMember = client.users.fetch(userId).then(async (user) => {
});
oh. thanks thats helpful
Unless you're using this (which for most js coders isn't even heard about), arrows are just fine to use everywhere
Inline yes, nobody uses arror expressions to define a function, NOBODY
hot
Nobody uses arror
lol
I do
Not arror
not arror but arrow
adding profile notice for you: very weird guy
lol

Would this be the correct syntax?
const function someFunc = async (parameters) => {
// do stuff
}
ewww
half of bot developers don't know how to code
Change function to const ig
async function KahuwakabunkSuchs(param1)
{
// explode
}
Found the c# coder
java actually
but im not that experienced with either langs lol
i came from html/css/php
Java is not allowed in this channel, move to the right channel
#trash-development
lmao
what do you mean i thought pasting stack overflowanswers into one big file counted as coding?
The java resistance is here to free this server from the grasps of dynamically typed coders

Come to strict typing comrade, enjoy the detailed coding habit
public static void main ftw
funny to see java getting flamed more than js
vood
Js flames itself
No need to try
At least that's true

xD
alyway how am i suposed to get a channel by an ID if the bot cant access guilds anymore
It can, u just need the right intents
how do i get those?
And refrain from using cache inside ready event
that was for debugging
Since it's more likely than not to not be cached yet
did you do the test i told you to do?
console.log(client.guilds.cache.size)
in your ready event
thats important to figure out if the problem really is a missing intent, or if it just a broken guild
2 guilds?
that is correct its only a testing bot account
and one of those two guilds is the guild you are trying to access?
its in my test server and my mates server two
yeah
i have tryed multiple channels
all are unfindeable
console.log(client.guilds.cache.get(guild id here))
if thats still undefined, do console.log(client.guilds.cache)
do all servers my bot is in have to reauthorize in order to allow the bot to create slash commands in their server?
Sorry I know I asked this recently but having this:
let getUserVarIdkWhatToNameThis = await client.users.fetch(player1).then(async (user) => {
setTimeout(function () {
var channelID = message.guild.channels.cache.find(c => c.name === "Game " + game + " Team 1").id;
if (!user.voice) {
// Couldn't move user
} else {
user.voice.setChannel(channelID);
}
}, 3000);
});
user.voice always returns undefined. If I use user.member.voice though, user.member returns undefined. How would I fix this?
only servers added after the last migration wave
Oh you're using then(), my bad, not need to await it then
discord did a mass migration last year and gave all existing servers the slash command scope to all bots
Didn't see that
ok thanks
its not undefined
await and .then are two ways of doing the same thing
the guild was found
mb. yea just read FakE's msg
ok, so list its channels
yeah
Even after removing await user.voice still returns undefined
I feel we are repeating the shit the other one said continuesly
Oh you're using then(), my bad, not need to await it then
user.member returns undefined though
ohh. to fix this would i just call the var itself (let someVar = await <stuff>)
no
you need to stop using client.users.fetch()
as that returns a user object
and instead use guild.members.fetch()
A Member object is associated with a guild, a User object has no association with a guild (Just saying)
which returns a member object
That’s why you can’t use User objects to perform methods related to guilds
alr. thanks for the help
hey all, when I restart my bot, I get a guildDelete event for 2 guilds. They have unknown attributes, but I have their ID's. They don't appear in my database of known guilds. Any way for me to understand why I'm getting this event?
Could be unavailable guilds. Make sure to check if the guild is available before running any code in your guildDelete event
They can always be unavailable
when some one dms the bot does it count a guild? or just a channel
text channel
ah
guild is not present then, never
if they're unavailable, why are they signaling an event?
(same 2 guilds on every restart)
broken guilds
2021-11-06T16:38:13.698546+00:00 app[main.1]: > node server.js
2021-11-06T16:38:13.698546+00:00 app[main.1]:
2021-11-06T16:38:16.691389+00:00 app[main.1]: /app/node_modules/discord.js/src/client/ClientDataManager.js:81
2021-11-06T16:38:16.691409+00:00 app[main.1]: guild.channels.set(channel.id, channel);
2021-11-06T16:38:16.691410+00:00 app[main.1]: ^
2021-11-06T16:38:16.691410+00:00 app[main.1]:
2021-11-06T16:38:16.691410+00:00 app[main.1]: TypeError: Cannot read property 'id' of undefined
2021-11-06T16:38:16.691411+00:00 app[main.1]: at ClientDataManager.newChannel (/app/node_modules/discord.js/src/client/ClientDataManager.js:81:36)
i believe someone said they were soft-deleted guilds
guilds that were deleted but are still within a 30 day revert window
you anredy posted that befor ago
i cant send all
you posted that before already, post the associated code
ok thanks peeps
Obviously channel is undefined
you are using discord.js version 11 which is very old and no longer works. the current version is version 13
lol v11, how do you know that? the syntax?
v11 🤨🤨🤨🤨🤨
Alright so I want my bot to auto role when a member joins but I want the auto role to be set so it my case they have to run k autorole (the role) and it will set that servers auto role. Role to that role however I’m unsure on how to do this can anyone help
yes
ClientDataManager.js doesnt exist since v12
how to upgrade?
He’s a walking djs doc
Sudo
I love it
from 3 years ago
you need to uninstall discord.js then install it again. and you need to rewrite all your code
aha
because a LOT of things are different between v11 and v13
omg
so be sure to read the v13 guides
also make sure you have node 14 or somthing installed too
Node 16
sudo n v13 @daring geyser
16+
Lmfao
For v13 you need node 16+
oof
I was on node 14 until recently when I decided to finally upgrade
But I don’t use djs so that wasn’t really a problem for me
when i upgrade my server I'll ipdate node
How dare you.
planning to use debian cuz centos is eol
Now I’ve just gotta make sure I don’t fuck up with any unhandled promise rejections 
sad
now it's an actual coding language I'd say
node was too lenient, errors must feel like errors
panic and despair is necessary to create solid progs
Agreed
Requires a lot more testing on my end for updates now though
I got a 404 unknown message from discord and it crashed my bot
Lmao
you talking about when you get an error but the program doen't actually crash cuz that annoys me
i just have my bots running in a screen session
how am i suposed to knwo discord broke the api again if the bot just spamms the console
That’s not true
What highlighting should I choose for this code in pastebin?
That’s deprecated in higher node versions
The language highlight

Your program will crash if you fail to handle those errors in the future
bruh do you not even know what language you are coding in lol
js
Hastebin or whatever that shit called, may be better than pastebin
but its logs
so set it as js then
thought we already established that the code wasnt working cuz you are using a package thats almost 4 years outdated
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
discord.js v13 requires node.js v16.6+
okay
For promises, should I be adding a .catch() on every single one in case it fails...? Seems counterintuitive to do that, so I’m probably wrong.
Yes let me just perfectly think of all possible cases while writing my bot
if the promise has a chance of failing, .catch it if it can be ignored on fail, or await it if the fail should interrupt the rest of the code
or a combination of both
for example ```js
let a = await x().catch(() => null);
if(!a) return;
i installed the discord.js 13 and node 16, but package.json is still old, i need to do npm init?
depends
if you have native packages that need compiling, they have to be reinstalled
other than that, you should probably check the ones you use to see if they need updating as well
It's probably easier to create a new project.
possibly yes
Is it good thing moduling everything?
how do i enable the message content intent on a bot?
Guild messages
i did the thing in the dev portal but i cant find the name for the intent
ah cheers
const client = new Discord.Client({
intents: [new Discord.Intents('32766')]
});
And bum you have all intents
yeah but i dont need all of themthough
so: ```js
const bot = new Discord.Client({ intents: ["GUILD_MESSAGES"] })
Calculate your intent as bit
And use this
Your code line will seem more clear
saving that link thanks
Np
if you are using discord.js v12, intents are not mandatory, you dont need to set them, you'll just get the defaults
in v13 they are mandatory, you need at least GUILDS and GUILD_MESSAGES
eitherway this is not what was being talked about before, about message content being disabled
starting from april 2022, message.content will be behind a new intent
and without that intent, you will recive messages with no/empty content
this is because discord wants you to use slash commands instead of message commands
one of my bots relyes on having acces to the message content so ima have to rewrite it at some point
yes
i gave up on the other thing and just wrote 2k lines from a txt file into various discord channels to be sorted
What's it's purpose?
its called notebot and allows a user so save a message that can be read later, intended uses are for:
> saving a list of prefixes for bots if the server has lots of them
> saving a rules list that can be posted anywhere instead of just telling peopel to "go look at the rules channel"
> people also use it to save todolists and reminders
yeah well i doubt that it will ever get over 100 users and if it does i'll just make another one with exactly the same code
and if discord doesn't like it they can suck on my 20 alternative accounts
its only in16 servers atm and its been up for almost a year now
selling a tts bot for 20$ if anyone is interested dm me
price can be lowered to 15$
mm yes a bot that does the exact thing thats built into discord its self
revolutionary
sorry to break it to you bud,
>i google dyno
> free moderation bot
also sorry to break it to you,
putting a ad to sell a bot in a server where almost ever person has made a bot isn't that good on an idea
especially with an idea that's been made hundreds of thousands of times
at this point anything that you can make a discord bot do has already been done
unless you are making a privet bot
omg
my bot is the first of it's kind. there are some copy cats now, but they dont have all the features
mine is still unique as far as i know
you know stars are actually aliens rightr?
what's the array look like?
["asdfasdfasdf", "asfasdfasdfasdf"] like this?
["1234567"].map(str => str.slice(0, -3))
yeah nvm, he's faster
["aaaz", "bbby", "cccd"].map(x => x.substr(0, x.length - 1));
FakE likes it complicated
oof
funny that slice already know the length
it's going to make a new array. the original array will not change
slice likes to help
const newArray = ["1234567"].map(str => str.slice(0, -3));
We don't see what u're doing without code
xD
async func
sync readdir
ths sync will still be non blocking if the async call isn't awaiting
promises are like actors or threads
blocks the promise. jk
Isnt it length?
maybe
Langdhauuuuu
I have question
x calls y function
y calls z function
So when you call x you will call z is it good idea?

Cnsöfmksmfmsmdms
Yes it makes
You never heard of classes or OOP?
I have message and slash command and i am lazy to code all shit twice so i did it
dunno why "it" it's a bad idea to use
Buda %99 cpu usage
that second it lol
i want to clean and use loop instead of this amazing yandere dev code but im lazy lmao maybe one day
Okay is good than?
oh my god
for()
thats for 2 different image parts from embed
But it seems more op
Use it
what in the name of...
lets just say i learned from yandere dev

but it works tho so its good enough for now
and my bot has not fallen from the free host yet
This article shows how object lookups can sometimes be used as a more maintainable alternative to if statements. Selecting a matching value The code below determines the travel speed based on the mode of transport that was selected. var speed; if (modeOfTransport === "car") { speed = 40; } else if (modeOfTransport === "train") { speed
number 5 is my embed 
i should use this for my embed?
use that idea. you'll have to change it a little since you are doing > and not ==
But that should be data driven
u mean <

you see them flipped 
so make an object that represents all the info in the if conditions. then write code based on that object. then all you need to do is update the object to add more features
the level ifs could be replaced by an array
I have this code
async function ping(i) {
i.reply(ping)
}
slashCommand
module.exports = {
name: ping
run:
ping(i)
}
messageCommand
module.exports = {
name: ping
run:
ping(msg)
}
since they can be used as indexes
I meant that
what if the game is superstition and doesn't want level 13? i guess it could be a sparse array
And why you didnt use canvas
the canvas only supports rasterize images
And ?
they dont scale
if only you had a type system that would simply tell you what broke
Tuple arrayts const [elo, image, color] = tuples.find(t => data.elo < t[0]) ?? [data.elo, defaultImage, defaultColor];
Obviously would require setting up the tuple array with all the data (in elo order!)
cosnt tuples = [
[1000, 'imgur url', '#666666'],
[1100, 'imgur url', '#666666'],
[1200, 'imgur url', '#666666'],
// etc
];```
see ads above
Is that what that is? Lmfao
No I commissioned it.
does anyone here know how can i get all intents in discord.js?
For 13?
yes
const client = new Discord.Client({
intents: [new Discord.Intents('32767')]
});
And bum you have all intents
Ping komududa vereyimmi :D
both v12 and v13 use typescript and they are still having an issue. types dont magically fix everything. they "help" with the simplest of things
if i update to node 16 will d.js v12 stop working?
Yes
Discord.js v13 is available and only supported for nodejs v16
Wait nodejs upped a version
v17
16.6+
16 is now lts
@quartz kindle nice pfp
ty
hello
can you help me plz
the bot does not start
@earnest phoenix
I did
edited script
const client = new Discord.Client();
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.once('ready', c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
client.on("message", message => {
if (message.content === "!ping") {
message.channel.send("Pong.")
}
})
client.login('blablabla')
You are declaring client twice
bruh
const client = new Discord.Client();
client.once('ready', c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
client.on("message", message => {
if (message.content === "!ping") {
message.channel.send("Pong.")
}
})
client.login('blablabla')```
is good ?
Missing the message intent now but should start
Do you have discordJS installed
and in debugger the app send message
i dont use
i use only terminal
yes in terminal
@earnest phoenix
Update node version
npm i node@latest || npm i node@16.13.0
judging by the fact that its saying that discord.js is the issue i ould guess that node or d.js is outdated
Iam not pretty sure if djs 13 works perfect with node 17
from quart import Quart, render_template, redirect, url_for
from quart_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
import os
app = Quart(__name__)
app.secret_key = b"random bytes representing quart secret key"
app.config["DISCORD_CLIENT_ID"] = os.environ["clientid"] # Discord client ID.
app.config["DISCORD_CLIENT_SECRET"] = os.environ["clientsecret"] # Discord client secret.
app.config["DISCORD_REDIRECT_URI"] = "https://discord-thingymabob.benchurton.repl.co/callback" # URL to your callback endpoint.
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
discord = DiscordOAuth2Session(app)
@app.route("/")
@requires_authorization
async def index():
if not await discord.authorized:
return await render_template("index.html")
user = await discord.fetch_user()
return await render_template("profile.html", useravatar=user.avatar_url or user.default_avatar_url, username=f"{user.name}#{user.discriminator}", guildcount = len(await discord.fetch_guilds()), friendcount=len(await discord.fetch_connections()))
@app.route("/login/")
async def login():
return await discord.create_session()
@app.route("/callback/")
async def callback():
await discord.callback()
return redirect(url_for(".me"))
@app.errorhandler(Unauthorized)
async def redirect_unauthorized(e):
return await render_template("index.html")
if __name__ == "__main__":
app.run("0.0.0.0")``` returns ```py
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response.``` on login
how to fix?
ok thx
Him
him
Idk python so even didnt read your issue lol
@earnest phoenix
lmao
same
node .
what is the best alternative for discord.py?
using another language
Using javascript
^
??
type it in console
im noob
i casn tell lol
Yes i noticed that

you posted that laready
He get it again i think
ah
because i don't want to learn javascript, is there any other option?
Python for discord should not be used as the forks aren't major and could be prone to many bugs/security issues.
Use JavaScript or any other language. You should have a look here: https://gist.github.com/Rapptz/4a2f62751b9600a31a0d3c78100287f1
C++
i mean no one is activly updating the py version so you will have to change languages or learn how to patch d.py yourself
But best option is js because its fast and flex
slightly faster tho
enhanced discord.py or nextcord
both work pretty much identical
wouldn't trust either of them
nextcord works great
i heard from nextcord, pycord but i don't trust them.
I still use discord.py lmao
Then use js
me too
you speak french ?
Yes i can use translator
no
dis moi ton problème mec
i know a little bit of french
i difficulte to translate my idea
@earnest phoenix is french i think and i hope
*Bonjour madame, comment vous vous appelez ?
is not " tu " is " vous "
french version 2 confirmed?
tu is for friends, family and other
tu is formal
I think so
" vous " is for respect
I updated last before 5 years ago
Why tf i ask for name to my friend
french is easy, except everything about french
" Tu vas bien " = you're doing well ( for friends )
" vous allez bien " = you are fine ( for you boss in work )
French pronounce is kinda hard
french is difficult
conjugate verb is hell
for that i develop a conjugator in my bot
if you talk to someone you don't know, use " vous "
Like es gibt in german?
Bruh i alr dont ask her name if she is my friend
[2021-11-06 22:08:34,464] ERROR in app: Exception on request GET /callback/
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 190, in _load
signing_input, crypto_segment = jwt.rsplit(b".", 1)
ValueError: not enough values to unpack (expected 2, got 1)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1467, in handle_request
return await self.full_dispatch_request(request_context)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1492, in full_dispatch_request
result = await self.handle_user_exception(error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 968, in handle_user_exception
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1490, in full_dispatch_request
result = await self.dispatch_request(request_context)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1536, in dispatch_request
return await self.ensure_async(handler)(**request_.view_args)
File "main.py", line 31, in callback
await discord.callback()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart_discord/client.py", line 163, in callback
return jwt.decode(state, current_app.config["SECRET_KEY"], algorithms="HS256")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 119, in decode
decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 90, in decode_complete
decoded = api_jws.decode_complete(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 149, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 193, in _load
raise DecodeError("Not enough segments") from err
jwt.exceptions.DecodeError: Not enough segments``` how to fix 
i don't know german. unfortunately
And my learn french application teached me as that
for your friends is " tu "
My point is i dont ask my friends their name
can you put the code?
i sent it before iirc
^

Hey! How do i add a number option for slash commands?
I've tried .addNumberOption, but it says its invalid
options:
[
{
name: "unique_number",
description: "A very unique number.",
type: "NUMBER"
}
]
its not level system its a stats command that takes info from api
I'm new to typescript, trying to switch to it with my existing code, what's the proper way to get rid of the error?
the proper way is to stop mutating types you don't own
go construct a context object and put the stuff commands need inside there
type CommandContext = {
client: Client
buttons: Buttons
guild: Guild
}
then you can just pass that around to your commands
function someCommand({ buttons, client }: CommandContext) {
// whatever
}
and pull out whatever you want
Could you give the code you have on this?
nvm, figured it out with .addIntegerOption
Thanks
Nice!
tfw you spend more time fixing typescript errors than actual program errors
wdym as fast
JS is only fast to write
are you using discord.js builders?
yes.
When u wont somthing fast, use compiling languge like rust
if you make it an integer option, only whole numbers can be used
im not sure why slashCommandBuilder.addNumberOption(...) isnt working
ik, and whole numbers works fine
alr
I have a for loop. I want to check if a certain word is in a database.
How could i safely if else it none word was found:
for (const key in carddatabase){
if(key == test[0][1]){
const embed = new Discord.MessageEmbed()
embed.setColor("RANDOM")
embed.setFooter("Your daily dose of KPOP!")
embed.attachFiles([`./cards/${key}`]);
embed.setTimestamp()
embed.setDescription(`Name: ${carddatabase[key].name}----Group: ${cardatabase[key].group}----Collection Number: ${carddatabase[key].number}\n`)
message.channel.send(embed)
}else if(key !== test[0][1] && (I NEED AN ARGUMENT HERE SO THE BOT DOESN`T SAY THIS MESSAGE FOR EACH KEY THAT ISN'T THE SAME){
}
}```
If u don't want the bot to send any message of there is no key, just remove the else if as a whole
i do want to send a not valid message
you just wanna send one message after the loop if one or more keys wasn’t found?
Declare a Boolean variable before the loop starts and assign it as false
Inside the first if statement make the variable as true, indicating that the for loop has found the word in database
After the loop, check if the variable is false, if it's still false then send that single message that u want
Or if u want to check if one or more keys is not found, make the variable true inside the else if block, and then check if the variable is true outside the loop
you are so damn smart
thanks
another way is to use returns
for(...) {
if(found) return message.channel.send("found")
}
return message.channel.send("not found")
does js have inverse sin?
i plotted it into a calculator which returned 30 while js asin returned 52.xxx
oh wait js gives the answer in radians doesnt it
that precision sucks ass
pretty close
fr
rads are better for computation i guess
computing in degrees would likely need a ton of control rules and shit
rules?
@quartz kindle you know how you are smart and all
jwt.exceptions.DecodeError: Not enough segments
[2021-11-07 01:09:52,600] ERROR in app: Exception on request GET /callback/
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 190, in _load
signing_input, crypto_segment = jwt.rsplit(b".", 1)
ValueError: not enough values to unpack (expected 2, got 1)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1467, in handle_request
return await self.full_dispatch_request(request_context)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1492, in full_dispatch_request
result = await self.handle_user_exception(error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 968, in handle_user_exception
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1490, in full_dispatch_request
result = await self.dispatch_request(request_context)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart/app.py", line 1536, in dispatch_request
return await self.ensure_async(handler)(**request_.view_args)
File "main.py", line 28, in callback
await discord.callback()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/quart_discord/client.py", line 163, in callback
return jwt.decode(state, current_app.config["SECRET_KEY"], algorithms="HS256")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 119, in decode
decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jwt.py", line 90, in decode_complete
decoded = api_jws.decode_complete(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 149, in decode_complete
payload, signing_input, header, signature = self._load(jwt)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jwt/api_jws.py", line 193, in _load
raise DecodeError("Not enough segments") from err
jwt.exceptions.DecodeError: Not enough segments```
make sure your jwt token is valid
A valid JWT has three segments separated by dots: <base64_encoded_header>.<base64_encoded_payload>.<signature>
will do
spent 1 hour debugging this 

Tu as toujours besoin d'aide ?
INSERT INTO table (column1, column2) VALUES (2, 'poggers');
class Helpcmd(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def help(self,ctx):
self.client.help_pages=[page1,page2]
buttons = [u"\u23EA", u"\u2B05", u"\u27A1", u"\u23E9"]
current = 0
msg = await ctx.send(embed=self.client.help_pages[current])
for button in buttons:
await msg.add_reaction(button)
while True:
try:
reaction, user = await self.client.wait_for("reaction_add", check=lambda reaction, user: user == ctx.author and reaction.emoji in buttons, timeout=60.0)
except asyncio.TimeoutError:
embed = self.client.help_pages[current]
#embed.set_footer(text="\n\nTimed out")
await msg.clear_reactions()
else:
previous_page = current
if reaction.emoji == u"\u23EA":
current = 0
elif reaction.emoji == u"\u2B05":
if current > 0:
current -= 1
elif reaction.emoji == u"\u27A1":
if current < len(self.client.help_pages)-1:
current += 1
elif reaction.emoji == u"\u23E9":
current = len(self.client.help_pages)-1
for button in buttons:
await msg.remove_reaction(button, ctx.author)
if current != previous_page:
await msg.edit(embed=self.client.help_pages[current])
@help.error
async def on_error(self,ctx,error):
if isinstance(error,commands.CommandInvokeError):
await ctx.send("Missing Permission: Manage Messages")
@finite quiver
Is it js?
no py
Py is dead If I'm right
I will check yr code in my pc
hmm
d.py is dead but there are active forks of it iirc
but discord.py was litt
If discord.py is dead should I move on to java ?
👀
js is gud for discord bot
java idk
Ok
anyone knows how can i fix this
i want that this help cmd should work without manage msg perm
it says missing permission
lemme check that
No need to compile and most improved discord bot libary
How to set different cooldown for different users?
Maybe change reaction with buttons
Current code: Only whitelist
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def example_command(ctx):
await ctx.send("Hi")
whitelist = [762143182250442773, 987654321]
@example_command.after_invoke
async def reset_cooldown(ctx):
for e in whitelist:
#to whitelist a person:
if e == ctx.author.id:
example_command.reset_cooldown(ctx)
#to whitelist a channel:
if e == ctx.message.channel.id:
example_command.reset_cooldown(ctx)
#to whitelist a guild/server:
if e == ctx.message.guild.id:
example_command.reset_cooldown(ctx)
#to whitelist a role:
if e in [role.id for role in ctx.author.roles]:
example_command.reset_cooldown(ctx)```
@carmine topaz ```Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
i need to change lib for it
@royal pawn
client.cooldown.set(`${member.id}_${command.name}, 1000`)
Like?
bot.cooldown.set(${551120440584699904}_${help}, 1000)```
Yes







