#development
1 messages Β· Page 1428 of 1
Forgot about that stupid rule
makes organizing roles a bit harder imo since if you want bots below members you have to move their own role above people
who are you kicking
mashiro
try to .catch() after .kick()
maybe you get more info tho xD
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:57) 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: 1)
(node:57) [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.
(node:57) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:57) 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).```
did you solve it?
not
my Bot had only the kick permission and worked fine
anyone know a way to dynamically update all documents to match new fields from the model?
mongodb^ js
mongoose?
@fervent goblet try the update method
it should update all documents found/matched
hmm ok
id: users.userId,
allow: ['VIEW_CHANNEL', `SEND_MESSAGES`],
})))``` ```Unhandled promise rejection: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.``` its meant to put the channel perms for two users in array?
guys anybody having problems with ytdl-core as well?
how would we do something like this;
db.fetch(money)
db.fetch(bank)
total balance: money + bank```
just an example, not actual code fyi
i just want to add two db values
together
and print that
Have you tried it already?
File "c:Users\Name\Documents\Visual Studio Code\Bot Name\core.py", line 84
SyntaxError: unexpected EOF while parsing
(Py)
Whats that?
syntax errors probably
My file is 83 lines long btw
There's probably some block that's not lined up right
wrong line terminator maybe?
How can i fix it?
Parser tried to read line 84 cause it expects something but got EOF
Aha
Check your code and make sure all the code blocks are lined up right
EOF = end of file btw
how do you set the bot status to idle or dnd? i tried client.user.setStatus('dnd') but that didnt work (discord.js)
it isnt working
await client.user.setPresence({ activity: { name: '=connect-4 in ' + client.guilds.cache.size + ' servers' }, status: 'dnd' }).then(console.log);
i have never seen a bot with dnd or idle so idk if its possible or not
it is
there was a person with the same issue yesterday
maybe an issue with djs
wheres UserStatus?
How come it says remove is undefined
Probably because there was an error in msg.guild.members.fetch
you could try logging err in the catch
u need to do msg.guild.members.cache.fetch
no you don't
members.fetch(...) is correct
I don't see why it'd say remove is undefined, because if an error did occur, it would say something like Cannot read property 'roles' of undefined
remove is never going to be undefined it's a method
roles however, can be undefined
Maybe fetch produced an error that wasn't thrown
oh wait yeah it would just say Cannot read property 'remove' of undefined
not a topgg question but, when i got a server with alot of emojis etc [example; :lots:] , and my bot joins the server, can i use the emoji :lots: in the other servers
not good explained
Yes, it should be in the format <:name:id>. If the emoji is animated, it should look like <a:name:id>
dayum thanks
and your bot needs to have "use external emojis" permission in the servers where you want to use them
is there a possibility that i can limit a command to 1-2 people. for testing commands
i suggest limiting it to the testing server instead
or better yet, not limiting it at all
or what are you referring to? something like -eval?
like adding commands to the bot.
you can check for the author id before running the command
hey guy, I have a problem where I download google-images module, I did coding and stuff, but after that when I run node, it show the error cannot find module ./package How can I fix that
I have package.json in myfolder, I don't get the reason of the error
Check path
@haughty mirage but I have package.json there.
right here- @opal plank
im gonna take a wild guess and say you using something like inside a commands folder
before I install google-image
I just uninstall the module because of the error, let me reinstall it
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001A3884CFA60>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001A389FF0B80>``` whats this error?
bruh lmaook
i dont have much experience with aiohttp but i think it's because you didnt close the session
Can I host 2 bots on 1 VPS?
ofc
π
Why don't give role to all server member
message.guild.members.cache.forEach(M=>{
M.roles.add(role)
sleep(100)
})```
Can someone help me installing java15 on my debian 10?
you're getting ratelimited and avoid forEach when you can
Anyone doing the Advent of Code?
check out https://adoptopenjdk.net/releases.html
What is JVM @earnest phoenix ?
java virtual machine ig
debian is linux
oh ok
if you dont want to bother with the tarball
And how do I install it after I downlaoded it
But how can I install it? I downloaded this package
Check my custom status 
did you download the tarball or the package
tarball
Bro this code just send message for some member not for all how i can change it
I only see Mac version
think this is better defined
@earnest phoenix It does work now...But i only can use one version at the time....So I cant use my old Java 8...It says that I have to choose
So I chose 15
How can i say that specific things start with java 8?
hm, never had a use case where i had to have two different versions
tried googling?
nah not yet....Also I used another tutorial istead of yours...Maby I should use yours so I can use both versions
This website looks different then mine
Because mine does only show mac
What is this page?
which package?
same page different JDK version
openjdk-15-jdk
https://packages.debian.org/sid/openjdk-15-jdk
@earnest phoenix Can i just use the 15 from adoptopenjdk and use the installation from jdk14?
π€ what
ok so "apt-get install openjdk-15-jdk" ?
Could not be found
did you update apt-get
sudo apt-get update
that's weird
it should work
hmmm
I am gonna restart my Server
It says anyway that it cant find that @earnest phoenix
@earnest phoenix ```sudo apt-get install OpenJDK15U-jdk_x64_linux_hotspot_15.0.1_9
Would that work?
i mean, i don't know, try it and see
nvm doesnt
but the first command should've worked
hmm
even the guide here https://techoral.com/blog/java/install-openjdk-15-debian.html says to install that package
how would i do multiple intervals but in an order? this one gets all funky setTimeout(function(){ msg.edit('test1'); }, 5000) setTimeout(function(){ msg.edit(test2') }, 15000) setTimeout(function(){ msg.edit('test3') }, 15000); });
hmmmm.
you could put the setTimeout call inside the function of the last setTimeout
or have some value in the outer scope that tracks how many times the timeout has fired and do the appropriate action
@earnest phoenix maby upload and then say apt-get install ./FileName?
holy moly they're up to java 15?
π€·ββοΈ
i can quickly spin up an ubuntu image to see if it works for me
ubuntu runs on debian
ah ok
Step #1: Download @earnest phoenix
I think it has to be on the computer
/server
it doesn't
?
it's saying not found?
yes
are you on debian sid?
debian sid?
or what distro are you on
distro?
of linux
Im an on Debian 10
ubuntu/debian
Debian 10 Buster....Thats the only thing i know
buster only has up to openjdk11 in their repo
And 9?
The problem is that i have a lot of things which I spent many hours to work
on the server
are you using java 15 features?
yep
yikes
What am I going to do now?
you probably just gotta keep trying to install from source like you were doing
but I dont know how if its not finding it
I got it last Time...But i could only choose between 8 and 15
And not use both
buster doesn't have 15 in it's official repo
and 9?
whattttt
or are you talking about debian 9
debian 9
only debian sid has openjdk 15
and bullseye
but they're not stable releases
debian sid is (unstable) and debian bullseye is (testing)
and what about installing oracle java 15 on my Debian 10?
are you sure you want oracle java?
whats wrong with that?
I thought oracle charged money for jre on servers
IDK
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
- 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/jdk-13.0.1/bin/java 1091 manual mode
Press <enter> to keep the current choice[*], or type selection number:
This was last time
just with 15
How can I say both?
actually, what java 15 features are you using?
Lamda express or what its called and for the rest i dont have the Name in my Head
lambda expressions are java 8 features
you can just use any version of jdk after 8
Text Boxes
oh text blocks
yes
My Project was Java 8....A Friend told me to upgrade to 15 and I did it and i liked it -_-
Now i hate it
I guess you have an option to remove those and replace them with the old style string literals concatted with +
You could also try to get a docker instance running with jdk 15 already installed if you're comfortable with learning docker
Or just keep trying to get openjdk 15 installed on buster somehow
nah im not
The funny thing is....I did it last time...The bad thing is...I had to choose between java 8 and 15....And I need both
JDK 15 can run java 8 bytecode
this actually looks promising https://www.linuxuprising.com/2020/09/how-to-install-oracle-java-15-on-ubuntu.html
I already tried it
where are you stuck?
The problem is , it wants me to choose one java version. It says i have to choose between Java 8 and Java 15....And i need both
But my Java 8 Minecraft Server doesnt work then hahaha
I tried it and it didnt work
that's weird
yes
what's the error there
IDK my cloud just says that its not working lol
This video guide to install java JDK in your ubuntu system from scratch including environment setup.
The steps and commands used in the video:
Install Java JDK
- Download java JDK
- Install Java
$ sudo apt install (FILE_NAME)
$ ls /usr/lib/jvm
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/(JDK_VERSION)/bin/java 1
$ s...
Thats the Video who helped me installing java 15
if you have multiple versions of java installed, the java command can only point to one of them
check if you still have jdk 8 installed somewhere
I have
you'll just have to change your minecraft server launch command
The location of the java binary for jdk 8
?
/usr/lib/jvm/ somewhere in there
likely it'll be /usr/lib/jvm/your JDK 8 home dir/bin/java
ls your /usr/lib/jvm/ and check if 8 is there
/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
sweet
now replace java in your minecraft server launch script with /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java
screen -RS CloudNet /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:MaxPermSize=256M -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:-UseAdaptiveSizePolicy -XX:CompileThreshold=100 -Dfile.encoding=UTF-8 -Xmx456M -Xms256m -jar launcher.jar
Like that?
uh probably
8
oh well then change your minecraft launch command back to how it was
i did
does it work?
the minecraft yes
My start.sh for my Bot lookes way different
Fuck
I build it with distZip with Gradle
Its like that
what's your jdk15 dir
/usr/lib/jvm/jdk-15.0.1
π
# Determine the Java command to use to start the JVM.
# if [ -n "$JAVA_HOME" ] ; then
# if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# # IBM's JDK on AIX uses strange locations for the executables
# JAVACMD="$JAVA_HOME/jre/sh/java"
# else
# JAVACMD="$JAVA_HOME/bin/java"
# fi
# if [ ! -x "$JAVACMD" ] ; then
# die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
# Please set the JAVA_HOME variable in your environment to match the
# location of your Java installation."
# fi
# else
# JAVACMD="java"
# which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
# Please set the JAVA_HOME variable in your environment to match the
# location of your Java installation."
# fi
JAVACMD="/usr/lib/jvm/jdk-15.0.1/bin/java"
I just commented out the logic that checks if JAVA_HOME is set
then manually configured the JAVACMD to use your jdk15 directory
ok
So I am using MySQL, how would I call for my database to get the custom prefix of a server? Here is my current code:
function getPrefixFunction(message, sql) {
const prefixes = [
`<@!${message.client.user.id}> `,
`<@${message.client.user.id}> `,
message.client.user.username.toLowerCase(),
sql.guild.prefix,
];
let thePrefixValue = null;
prefixes.forEach((prefix) => {
if(message.content.startsWith(prefix) || message.content.toLowerCase().startsWith(prefix)) {
thePrefixValue = prefix;
}
});
return thePrefixValue;
}
const prefix = getPrefixFunction(message, sql);
if(!prefix || message.author.bot) { return; }
Do I call for my DB connection inside of the function or how would I call to my DB?
You could probably cache the prefix as you need them then update both the cache and DB when it changes
@tranquil drum when do you think will Java 15 release official for Debian 10?
I don't think it will
whaaaaat
I'm trying to keep everything on my DB as I can.
I think people in industry who need jdk 15 will just use docker images
It'll be in both
unless you don't want to cache at all
damn
in which case you'll have to call the DB at least once per message
IDK how to cache so I'ma keep it in the DB.
Still new to programming but have made a lot of headway.
If you're using js you can just create a new object in some scope where both your getPrefixFunction() and the handler for your prefix change command exists
let guildPrefixCache = {}
Thx @tranquil drum for your help....I think i would cry if havent got it hahaha
just kidding
But i would be sad
But THX for your help. Im going to bed now
After 15h of programming xD
ur a machine
nah im lost as fuck
I reworked my whole bot and wrote it in SQL in one day without knowing this language....
Welcome to programming!
After a couple of hours I realized I need prepared statements hahaha
Thx but thats a normal day for me hahaha
So guys...Im away now
Same here .
thx and c ya
Have a good night.
Lets just start with a DB call, before the const of prefixes do I just call for my db connection again?
do you close your db connections as you finish your queries?
uh i'm not sure what you mean by that
botdb.query(`SELECT * FROM server WHERE serverid = ${message.guild.id}`, async (err, results) => {
function getPrefixFunction(message, sql) {
const prefixes = [
`<@!${message.client.user.id}> `,
`<@${message.client.user.id}> `,
message.client.user.username.toLowerCase(),
sql.guild.prefix,
];
let thePrefixValue = null;
prefixes.forEach((prefix) => {
if(message.content.startsWith(prefix) || message.content.toLowerCase().startsWith(prefix)) {
thePrefixValue = prefix;
}
});
return thePrefixValue;
}
const prefix = getPrefixFunction(message, sql);
if(!prefix || message.author.bot) { return; }
});
Do I do this?
Or will it just die when this is done
ah
if you put the function in there then you can only call it inside that query
you'll have to put the query inside getPrefixFunction
Okay.
and probably use a callback since botdb.query also uses a callback
Ohhhhhh I didn't know I could do that.
That helps a lot.
// If the messagr author is a bot or doesn't start with the prefix
async function getPrefixFunction(message, sql) {
await botdb.queryPromise(`SELECT * FROM server WHERE serverid = ${message.guild.id}`).then(async function(results){
const db = results[0].prefix;
const prefixes = [
`<@!${message.client.user.id}> `,
`<@${message.client.user.id}> `,
message.client.user.username.toLowerCase(),
db,
];
let thePrefixValue = null;
prefixes.forEach((prefix) => {
if(message.content.startsWith(prefix) || message.content.toLowerCase().startsWith(prefix)) {
thePrefixValue = prefix;
}
});
return thePrefixValue;
});
};
const prefix = getPrefixFunction(message, sql);
if(!prefix || message.author.bot) { return; }
There we go, now I feel like progress is being made.
Whats a developers license and do you need one to make a bit
Alrighty
@tranquil drum just a heads up chief
@tranquil drum Do you know how I can change the background of my Bots Top.geh Page?
HTML code.
You can use HTML <style> tags and put custom css in there
just make sure it doesn't obscure and interfere with existing buttons on the page and be aware of epilepsy inducing elements like flashing or rapid color changes
Yes but I am not familier with it And i have an online Code where Snow Is flying around but I donβt know how to transfer that to my Bots Background
as long as that code is pure css it will work
THATS the Code
I need to add a background lol.
@tranquil drum What do I have to change to make it work on my Bot page?
do you know how css works?
No π¦
then i suggest learning some basics first
its not too hard
for example, learn how selectors work
then you can inspect element on the top.gg page and find the right selectors
it should be apt-get install libopus0 opus-tools but i get the root error
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
How do i install opus without root permission?
I am already using them.....But I dont know how i select the background because i donβt know the name of it
inspect element
Literally said it.
Tried that....
then try better
Ok
Quite literally.
You can't install things with apt-get without root or su
have you got sudo?
can you help me do it? i am in a situation where i cant get su
do you have docker on the machine?
idk what that is
what is this machine you're running on?
what do you need libopus for
something.host console
update node
to v12 or higher
π€·ββοΈ
package managers always have old versions
you need to install from the website, or using nvm
So I am doing
pool.query(query, (err, res) => {
if(err) return console.log(err);
pool.end()
})```
in my afk file, and it gives me error of `Error: Cannot use a pool after calling end on the `. When exactly am i supposed to close the connection.
This is postgres

const { Pool } = require('pg')
const pool = new Pool()
pool.query('SELECT $1::text as name', ['brianc'], (err, result) => {
if (err) {
return console.error('Error executing query', err.stack)
}
console.log(result.rows[0].name) // brianc
})```
This isn't much different that what I am doing π€
This is my code
const query = {
text: "INSERT INTO afkTable(id, msg)values($1, $2);",
values: [message.author.id, afkMsg]
}
pool.query(query, (err, res) => {
if(err) return console.log(err);
pool.end()
})
Still confused what you are pointing out to
~~@earnest phoenix ~~
ah
You made me think I was doing everythign wrong
alright thx that's a good resource
how can i import a file? py
What kind of file. A python file? A JSON file? A text file? I'm sure you know how to use import as that's quite primitive.
ye a python file
i know how to
but its in the same folder
i want to import example.py in main
import example?
uuhhh
i tried that it gave me an error but mightve been for something else
lmao
alr thanks
What was the error?
nah its something i know how to fix
i have a list of things i need to pull one from
but i got that
thanks
alright
Think of the scope in the file.
If you have: ```py
file: funcs.py
def say_hi():
print("Hi!")In your other file, you should be able to:py
import funcs
funcs.say_hi()
You could also `import funcs.say_hi` to import only the function I believe.
ye
umm its in a class tho
so i need to pass in self iirc
self.funcs.say_hi?
class normalquest(commands.Cog):
def __init__(self, client):
self.client = client```
lmao i really need to do some more basic py
i understand libs and stuff
but i need to get a hold of sort and lambda and shit lmao
You shouldn't need self.
You could do import funcs.normalquest, and now you have access to the normalquest class.
VPS
Extension 'cogs.quest.quest' raised an error: ModuleNotFoundError: No module named 'itemlist'
@sudden geyser
sorry for ping
i did import itemlist
its not a module
its a file
show you directory tree pls
oh god that censoring
?
Can someone help?
player = None
for voiceClient in client.voice_clients:
if voiceClient.guild == message.guild:
player = voiceClient
if player == None:
await message.channel.send("You must be playing audio to pause.")
return
player.pause()
await message.add_reaction("π")
```when i use the pause command, it causes the bot to leave. what is wrong here?
show all code
What file are you trying to import itemlist from
thats all the code
quest.quest
@client.command()
async def pause(message):
player = None
for voiceClient in client.voice_clients:
if voiceClient.guild == message.guild:
player = voiceClient
if player == None:
await message.channel.send("You must be playing audio to pause.")
return
player.pause()
await message.add_reaction(":thumbsup:")
quest file
@drifting wedge
Importing looks from the project root directory.
oh
So your import should look like import quest.itemlist
yep
how long is the waitlist for privlidged intents?
a couple days / weeks
lmao my file path is a fucking mess lmao
i have like 10000 images in my bot folder
and shit
i need to get my shit together
oh wow. ok thanks. i already reached out to discord staff. hopefully they reply
lmao
Extension 'cogs.quest.quest' raised an error: ModuleNotFoundError: No module named 'quest'
import quest.itemlist
I wanna make my bot message
In every server
That it restarted
Once it crashes and node process restarts
Automatically
Not manually
Not every server tbh , the server he was playing music in
@client.command() gives you a Context object, not a Message object
you can get the message in Context.message
Is there any way I can make my bot leave the VC in every server which he has joined
Like he is in testing 1
In this server
That's no censor...
It's dark matter visualized
Could anyone remind me how to know if the user mentioned is a bot?
what language/library
get the mention and check if it's a bot or no
You can do this
const user = msg.mentions.user.first()
Now check if it's a bot or no
Using user.bot
if(user.bot) return // thid will do nothing if bot is mentioned
That was exactly it! Thanks!
Anytime brother
if (serverQueue.loopall === true) lMsg = 'On'
if (serverQueue.loopone === true) lMsg = 'Once'```
Hello !
I have no idea what to define lmsg as
(node:2264) UnhandledPromiseRejectionWarning: TypeError: canvacord.Spotify is not a constructor
at Object.exports.run (C:\Users\User\Pictures\Oppa\No workspace\commands\Information\spotify.js:31:12)
at module.exports (C:\Users\User\Pictures\Oppa\No workspace\events\message.js:82:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2264) 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: 1)
(node:2264) [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.
msg.mentions.users.first()
is there any way to get the author of a deleted message?
yes
wait you tryna code a message delete logs?
no a sniper bot
no worries ^^
Has anyone here actually setup a DBLWebhook using Heroku?
I have everything working locally; however, I can't seem to get it to work in Heroku. It binds correctly, but I can't seem to get any payloads from the test event.
If you have, what was your ending url for heroku?
I physically typed in:
http://{app-name}.herokuapp.com:{port}/dblwebhoook
Here's the output from Heroku:
2020-12-04T03:01:20.700782+00:00 heroku[worker.1]: Starting process with command `node .`
2020-12-04T03:01:21.393377+00:00 heroku[worker.1]: State changed from starting to up
2020-12-04T03:01:24.384882+00:00 app[worker.1]: Webhook running at http://0.0.0.0:{port}/dblwebhook
anyone pro on using canvacord here?
Hello, people. My doubt is a little difficult to explain, but I will try. If I create a variable that stores 5 values of a search, but after selecting one it will delete the rest. Is there a chance that another person who is executing the same command will lose data from his variable because the other has already finished his research and deleted the data? Or is everything done very fast and one ends up not interfering with the other?
That entirely depends on the scope of the variable @haughty bough
If the variable lives per that user's request, it can't be intercepted by another user's request. Like Thomas said, it matters on the scope of the variable.
globals π
(node:2264) UnhandledPromiseRejectionWarning: TypeError: canvacord.Spotify is not a constructor
at Object.exports.run (C:\Users\User\Pictures\Oppa\No workspace\commands\Information\spotify.js:31:12)
at module.exports (C:\Users\User\Pictures\Oppa\No workspace\events\message.js:82:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2264) 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: 1)
(node:2264) [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.
Help pls
For example, if I have a variable called tick and set it to true/false on every command, I'd need it to live for longer than the user's request. Then, another user's command can intercept it.
TypeError: canvacord.Spotify is not a constructor
See line 31 of commands\Information\spotify.js
Understand. In my case, this variable is within a class that is accessible to everyone on the server
Can I share something not related to bot development here, but related to js
i will send code
Yes
Let's learn how to make a VM and Compiler in JavaScript! - https://github.com/EliteDaMyth/JS-VM-Compiler
@sudden geyser
if (message.author.bot) return
let user;
if (message.mentions.users.first()) {
user = message.mentions.users.first();
} else if (args[0]) {
user = message.guild.members.cache.get(args[0]).user;
} else {
user = message.author;
}
let status;
if (user.presence.activities.length === 1) status = user.presence.activities[0];
else if (user.presence.activities.length > 1) status = user.presence.activities[1];
if (user.presence.activities.length === 0 || status.name !== "Spotify" && status.type !== "LISTENING") {
return message.channel.send("This user is not listening music");
}
if (status !== null && status.type === "LISTENING" && status.name === "Spotify" && status.assets !== null) {
let image = `https://i.scdn.co/image/${status.assets.largeImage.slice(8)}`,
name = status.details,
artist = status.state,
album = status.assets.largeText;
var card = new canvacord.Spotify()
.setAuthor(artist)
.setAlbum(album)
.setStartTimestamp(status.timestamps.start)
.setEndTimestamp(status.timestamps.end)
.setImage(image)
.setTitle(name);
card.build()
.then(buffer => {
canvacord.write(buffer, "spotify.png");
let attachment = new Discord.MessageAttachment(buffer, "spotify.png");
return message.channel.send(attachment);
})}
}
How would I make a bot know when its disconnected by a user?
Virak what can you show where you defined canvacord and what version of the library you're using? It looks correct.
what library are you using?
I am using ytdl-core
Library means discord.js/discord.py or Eris or etc.
:x: | An error encountered: Error: play(havana) encountered:
Status code: 429
Explain why this happens. Im using distube's example bot.
I tried to centre-align an h1 in my long description but it's showing as left-aligned. The p which I aligned along with it is aligned properly though. It seems to work fine in my editor.
429 - Too many requests
What are you trying to do
Did you just run his example w/o checking what's going on?
'cause you probably need an API to interact with YouTube Search feature
I ran the example with the command handler.
DisTube needs an api key?
I don't even know what Distube is
its like lavalink
Oh ok I see
Oh yeah ok you don't need an API key
Ok
how can i enable them ?
U need to request em to discord support or smth
smth and em means ? @supple oriole
@earnest phoenix As you can read, you need whitelisting for those privilegied intents
You had to ask them in the verification process
where to ask ?
@paper cliff For the 429 error, it says I need a youtube cookie
say, smth and em means ? @supple oriole
what,
@earnest phoenix something
em ?
@supple oriole Yes, it's almost like an API key in fact
const client = Discord.Client()
const DisTube = require('distube')
client.DisTube = new DisTube(client, {
// You can read how to get it in the documentation
youtubeCookie: '<Your YouTube Cookie>'
})
So how do I get one.
I tried googling
@paper cliff whats discord email adress ?
@earnest phoenix dude just look on the internet
https://dis.gd/report has a field for privilegied intents I think
Write an email there.
yes it is
// You can find this by going to a video's watch page, viewing the source,
// and searching for "ID_TOKEN".
// 'x-youtube-identity-token': 1324,
I don't understand o-0
Basically, you just get the cookie by going on the youtube.com website with your account
Yes. @oak cliff made a leaderboard that I'm currently killing it on: 1069015-af2456a5
Hey guys
I am trying to use https://www.npmjs.com/package/spotify-url-info
const song = await getPreview(args[0])
const songname = song.title
This is my coode
Keep getting this error
The code works fine on runkit.com
Error is on line 321 which is - const song = await getPreview(args[0])
my .json
{
"suite": ["s", "d", "h", "c"],
"1s": "781383820733710376",
"2s": "781383847174471680",
"3s": "781383879344521238",
"4s": "781383909207572530",
"5s": "781383945744547871",
"6s": "781384004602429460",
"7s": "781384215547215903",
"8s": "781384241300111361",
"9s": "781384270912028724",
"10s": "781384305275961365",
"11s": "781384334648934400",
"12s": "781384358459736095",
"13s": "781384462981922826",
"1d": "781383820666601492",
"2d": "781383847089668096",
"3d": "781383879037550603",
"4d": "781383908771627019",
"5d": "781383945807331328",
"6d": "781384004548952124",
"7d": "781384215606067240",
"8d": "781384271046246401",
"9d": "781384271046246401",
"10d": "781384305590665236",
"11d": "781384334346158114",
"12d": "781384358434439189",
"13d": "781384463048638464",
"1h": "781383820313755670",
"2h": "781383847111688192",
"3h": "781383879445184582",
"4h": "781383909119229972",
"5h": "781383945995812874",
"6h": "781384004690903060",
"7h": "781384215551410186",
"8h": "781384241425547275",
"9h": "781384270945583146",
"10h": "781384305704173579",
"11h": "781384334346682401",
"12h": "781384358673907712",
"13h": "781384463007350824",
"1c": "781383820476678174",
"2c": "781383846897123369",
"3c": "781383879118290964",
"4c": "781383909119754240",
"5c": "781383945547415553",
"6c": "781384004519723028",
"7c": "781384215203807253",
"8c": "781384241429872700",
"9c": "781384271087534081",
"10c": "781384305489477642",
"11c": "781384334506196992",
"12c": "781384358463799346",
"13c": "781384462948106260",
}
is giving me this error for some reason:
SyntaxError: /home/runner/Aperture-Bot/commands/resources/pc.json: Unexpected token } in JSON at position 1559
at parse (<anonymous>)
``` but I dont think anything is wrong
Lol
Hi, I try to get who is voting my bot unfourtunately its not working can somebody help
language?
js
const DBL = require('dblapi.js'); const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' }); dbl.webhook.on('ready', hook => { console.log(Webhook running at http://${hook.hostname}:${hook.port}${hook.path}); }); dbl.webhook.on('vote', vote => { console.log(User with ID ${vote.user} just voted!); });
this is the one which i used
3x ` gives you a codeblock -> easyer to read
did you set a webhook url at your bots page?
yes
did you set a password on your bots page? (same as webhookAuth)
Nope
@fiery creek Are you running this on your local machine?
By the way here is a codeblock syntax:
```js
console.log('Codeblocks example')
```
Yes
local is not that easy. did you know your external ip adress or did you use a VPN?
I tried but still no respose buddy
IP Address I KNOW
if you dont pay extra for your ISP contract you probably have a shared IP -> will not work
kk
either use a Server or a VPN to get a IP adress. then add to your webhook url on top.gg the correct ip adress
k thank u
Behind your local machine it won't work that easily
Your router has a firewall that prevents you from exposing your webserver to the public
And anyway it's not recommended to open ports to the public on your own PC
Any one knows a good npm package to search things on yt... I'm making a music bot with ytdl core but i need a way to search videos by names
Use yt api
k
Also check this out.
I searched on Google and this popped up
(you won't need a key for this)
https://www.npmjs.com/package/usetube
oh thats even better
Scraping is legal as long as you are respecting protected routes for that site. Scraping for public information is fine.
it's against YouTube TOS to scrape data from their site though
Technically they should yes.
It depends on the legal definition of a "public search engine" lol
hello i did a reaction role system, only there is a problem if the bot restarts then it doesn't detect the reaction.
can it be solved somehow?
the message is no longer cached. cache it again or use the reaction events
How do i fix this?
(node:2264) UnhandledPromiseRejectionWarning: TypeError: canvacord.Spotify is not a constructor
at Object.exports.run (C:\Users\User\Pictures\Oppa\No workspace\commands\Information\spotify.js:31:12)
at module.exports (C:\Users\User\Pictures\Oppa\No workspace\events\message.js:82:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2264) 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: 1)
(node:2264) [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.
Ping me if you know
somehow it is possible that you do not have to re-enter the response MSG on each server each time you restart, so the old response message will work anytime you restart
well you try to use a non existing constructor
store the message id in a database and then fetch it after a restart
if (message.author.bot) return
let user;
if (message.mentions.users.first()) {
user = message.mentions.users.first();
} else if (args[0]) {
user = message.guild.members.cache.get(args[0]).user;
} else {
user = message.author;
}
let status;
if (user.presence.activities.length === 1) status = user.presence.activities[0];
else if (user.presence.activities.length > 1) status = user.presence.activities[1];
if (user.presence.activities.length === 0 || status.name !== "Spotify" && status.type !== "LISTENING") {
return message.channel.send("This user is not listening music");
}
if (status !== null && status.type === "LISTENING" && status.name === "Spotify" && status.assets !== null) {
let image = `https://i.scdn.co/image/${status.assets.largeImage.slice(8)}`,
name = status.details,
artist = status.state,
album = status.assets.largeText;
var card = new canvacord.Spotify()
.setAuthor(artist)
.setAlbum(album)
.setStartTimestamp(status.timestamps.start)
.setEndTimestamp(status.timestamps.end)
.setImage(image)
.setTitle(name);
card.build()
.then(buffer => {
canvacord.write(buffer, "spotify.png");
let attachment = new Discord.MessageAttachment(buffer, "spotify.png");
return message.channel.send(attachment);
})}
idk never used canvacord
how to do that π
check who ive answered lol
Cookie header used in request, but unable to find YouTube identity token
What does this mean 0-o
is there any library of nodejs that have shards and uses 100mb ram for 1k servers
Thank bro 200IQ
look into discord.js-light if you want to use JS. but if you want to go more efficent use C# or C++
canvacord.Spotify() is not a thing
@lusty quest djs light have shards ?
I fixed it.
d.js light is just normal d.js but with most caching removed. i still use some caching and run about 100MB ram with 300 Guilds. compared to normal js that ran with about 300MB while serving 80 Guilds
in my case djs use 300 mb ram for 39 server after 5 hours of uptime
yea its the caching
d.js light is way more ram efficent
the Dev of the lib is also here on the discord
What do i change to then?
R.I.P
@lusty quest did you ever uses C# or C++ to develop discord bot ?
started to learn C# recently to write discord bots with it. If you have questions in C++ ask Brain his bot is in C++
This user ? 189759562910400512 @lusty quest
the Moderator yes
just ask... I'm sure Brain isn't the only one who knows C++ here
there are more but this is the only one im sure who uses it
@cinder patio you use C++ ?
yes, I've used it
@cinder patio curretly using ?
I haven't made any bots using C++, but it all depends which library you're using, what you cache, and how you're handling memory, just using c++ won't solve all your performance issues

just to say so 100MB ram for 1k guilds could be unrealistic tbh
its maybe possible if you cache nothing and dont use stuff that renders to the buffer
π€
I mean, if you don't cache ANY data coming from discord, then 100MB RAM for 1k guilds sound realistic even in node.js
is there any way i can decrase my bot proformance?
why did you want to make it slower?
you mean increase?
on js. use d.js-light and disable all caching.
will use next to no ram
but will be a pain in the ass to use
@lusty quest everything works ?
not everything. you cant do some stuff
like permission checks
atleast the easy way
like ban kick av works ?
Switching to c++ without any prior knowledge of c++ is not a good idea
we talk about js
Well he asked about c++ beforehand
i started using js when i dosent know anything about it
kick and ban works but you if you want to check permissions it will become annoying
@lusty quest like errors or tells everything wrong ?
um
Best way to handle permissions in discord.js-light is catching the errors and just assume the bot doesn't have the required perms.
its normal d.js but without any caching
are you using djs light ?
yes
well every permission check will be false bcs its not cached.
you could workaround it by fetching the spezific stuff you need for it first
you don't do permission checks.. you just try to do the thing and catch the error
@lusty quest if i put everything true in this.. everything works perfectly without using that much ram as djs ?
cacheGuilds: true,
cacheChannels: false,
cacheOverwrites: false,
cacheRoles: false,
cacheEmojis: false,
cachePresences: false
});```
this will work. if you want to check permissions enable roles and overwrites
If you put true for everything then it's just like discord.js
um
i where thinking on stuff like kick and ban that you want to restrict to certain permissions
wait nvm
yea just try/catch will work
since it will error out if you dont have permissions
but config commands will be a different thing i guess
but it won't error if the person who requested the ban/kick doesn't have the right permissions
well what about py ? how much ram it use ?
py is not the most efficent language. if you want to have more efficent code use a compiled language
um
i dont get why are you wanting to cut down so much on ram usage
like for 5$/Month you get a VPS that can easy run normal d.js with 2 shards
cause i cant afford more than 500 mb vps
use d.js light. it will be good enough. if you can grow larger bcs of hardware restrictions i guess there will be the end for you at the point.

i use D.js light with currently ~300 Guilds and the bot uses about 100MB ram. i dont think with 1k guilds i will get past 500MB
even tho iΒ΄m planning to switch to C#
what about eris + discord.js
d.js-light uses less ram
how can i exactly load an old message?
MY CODE not working
client.guilds.cache.get('781508242828165150').channel.get('781508242828165150').fetchMessage('784332080645537792');
const { MessageEmbed } = require('discord.js')
module.exports = {
name: 'voiceStateUpdate',
async run(client, oldState, newState) {
if (oldState.channel && oldState.channel.members.size === 1 && oldState.channelID === oldState.guild.voice.channelID) {
const channel = client.queue.get(message.guild.id).textChannel //error in here ReferenceError: message is not defined
const e = new MessageEmbed()
.setColor('RED')
.setDescription(`I will disconnect if no users join my voice channel after 1 menutes`)
var em = await channel.send(e)
setTimeout(() => {
oldState.channel.leave()
em.delete({timeout: 2000})
}, 60000)
}
}
}
``` help me
channels.cache.get()
undifend channels
make sure the id of the channel is true
not a function```
the channel is good and the message is both the guild
```js
client.guilds.cache.get('779669294472626227').channels.cache.get('781508242828165150').fetchMessage('784331384587550760');
because fetchMessage is not a function
@earnest phoenix
i don't fully understand a fixed message i want to load after bot starts
working
client.channels.cache.get('781508242828165150').messages.fetch({ around: '784339411323846687', limit: 1 })
.then(async msg => {
console.log(msg)
})
)
π
all you need to do is use .messages.fetch('784331384587550760') instead of your .fetchMessage() since that is old.
okey
bot.on("message", message=>
{
let args = message.content.split(" ");
if(message.content.startsWith(`waheguru`))
{
let time = args[1]
if(!time)
{
return message.channel.send("Please Specify Time")
}
if(!args[1].endsWith("d") && !args[1].endsWith("h") && !args[1].endsWith("m") && !args[1].endsWith("s") )
{
return message.channel.send("you need to use d(days), h(hours), m(months), s(seconds)");
}
let gchannel = message.mentions.channels.first();
if(!gchannel)
{
return message.channel.send("you havn't specified the channel")
}
let prize = args.slice(3).join(" ")
if(!prize)
{
message.channel.send("please enter a prize");
}
gchannel.send(":tada: **NEW GIVEAWAY** :tada:");
let gembed = new Discord.MessageEmbed()
.setTitle('New Giveaway')
.setColor("RANDOM")
.setDescription(`React With :tada: Top Enter The Giveaway \n Hosted By **${message.author}** \n prize:${prize}`)
.setThumbnail('https://cdn.discordapp.com/attachments/774196226278293506/782981284329685033/61d82e93fe3f27d3b8a035e464415bb2.gif')
.setTimestamp(Date.now + ms(args[1]))
.setFooter('Will End At')
let m = await gchannel.send(gembed)
m.react("π")
setTimeout(() => {
if(m.reactions.cache.get("π").count <=1)
{
return message.gchannel.send("i cant select a bubble gum bitch");
}
let winner = m.reactions.cache.get("π").users.cache.filter((u) => !u.bot).random();
gchannel.send(`**congratulations** ${winner} you have won the ${prize} \n **now please DM **#6226**`)
},ms(args[1]))
}
})```
whats wrong with it
what's the error message
await in async
It's channels not channel
already solved
row 1
bot.on("message", async message=>
@earnest phoenix you need also fetch the channel iirc
what?
you want to load a message into the cache. after a restart you also need to load the channel into the cache
does it load doesn't it?
because it works perfectly on 5 servers
client.guilds.cache.get('779669294472626227').client.channels.cache.get('779681718746611722').messages.fetch({ around: '784308522506125332', limit: 1 })
.then(async msg => {
})```
why what's the problem
to quote an old teacher of mine idk what this is but its crap
but why would it be if it works perfectly
you have a duplicated line to start with
?
and if I take one off it will be good for you
if it work its fine its just wired
works perfectly I don't understand what's wrong with it
you go the way client -> guild -> client -> channel -> message.
its valid
but just wired
guild also got a channel Manager, the client Channel manager contains all channels the Bot is handling while the Guild Channel Manager all guilds in the one Guild you used.
you get what im on right?
you could also use client.channels.cache.get() instead of fetching the guild first. since it ends up using the same Manager
i understand it bothers you but it still works for me and i need the guild id separately
its your code so i dont have to care
why are you bullying me
?
what bothers you in my code
Are these IDs fixed, do they ever change if you run the code in a different server for example
channel ids are unique across discord itself
but i guess with increasing size of the bot fetching the large map with all channels could become inefficent
good anyway i don't want to argue with me so good and ready
Assuming they don't change, you can just remove the first part and start with client.channels.cache.get(...
the map that gets the guild first only loads the map that contains the channels for this one guild.
justify if I don't replace what happens
idk how the performance of the code gets affected if a bot serves 2500 Guilds in one shard.
but its possible that the larger map could affect it
Discord.js caches all channels regardless so you can just use .get() on the client.channels.cache collection
mostly bcs the map could easy contain a few million ids
but old messages doesn't cache unless I ask for it
messages only get cached when send
const dbl = new DBL(process.env.TOPGG, { webhookPort: 5000, webhookAuth: 'password' });```
What to write in password?
generate a random sting
-> #topgg-api
thx π
but yea the way he gets the channel is valid but he wants to use it this way
i am asking for an old messaget because of reaction role
@earnest phoenix
client.guilds.cache.get('779669294472626227') -> you get your <Guild> object from your <Client> object
<Guild you just got>.client.channels.cache.get('779681718746611722') -> you get your <Channel> from the same <Client> object you just got your guild from you can get your <Channel> object straight from your <Client> object instead -> client.channels.cache.get('779681718746611722') and fetch the message from that
Ugh the way you fetch your message is correct but the way you get your channel object isn't
but I think it's so good now
then if I have a problem with it I will fix it
but it works so i don't understand what's wrong with you
your code will contain unnecessary parts.
That it works doesn't mean it's the best way to do something
and?
Β―_(γ)_/Β―
it may not be the best method but for me it is good now
use partials to get reaction on old messages
i guess that is what bothering you π€
lets say the channel you want is in your kitchen, instead of going to the kitchen to get it, you're leaving your house from the backdoor, going all the way around the block, enter your house again from the front door then enter your kitchen to get it. thats essentially what your code is doing lol @earnest phoenix
sure it works, but why go the all the way around then you can just go directly there?
You saying you wouldn't cut through the roof instead?
I'm disappointed
(In JS, that would be raising a custom exception for no valid reason and handling it with normal code)
Wkwkwkwkwk
go to the airport, steal a plane, fly over your house, jump, parachute, land on your roof, dig through your roof with a shovel, fall into the kitchen, grab channel, win.
π
β€οΈ
before doing anything i want to make sure is it possible to make autorole if someone is streaming a specific game (discord.js)
Using the presenceUpdate event, I think it should be possible
alright sounds good
how can i resolve this
if youre using the correct data structures, it wont be affected much if at all
by correct data structures a map/hash map, or even an R/B tree based storage is fine, so long as its not any type of O(n) array
i was pretty close to 2500 guilds per shard in mid september
when i hit 10k, and i only had 4 shards
well, i was at 9800
but i was away on holiday and couldnt scale it up π
good to know
but the idea was that the client.channel Manager contains all Channels the bot is serving vs client.guild.channel where the map only contains all channels of the guild. idk how performance wise the impact is if you run at 2500 guilds
js Maps are good until about 10 million keys afaik
read speeds get significantly reduced at around 12-13 million
and it crashes at 15-16
write speed starts slowing down at 4-5 million
i guess its fine then. if of the 2500 guilds each got 50 channels you reach at max 125000 keys in the map
by that point, your client.users.cache will likely be at 500k+
if you use fetchAllMembers or have presences enabled
there's an interesting package on npm called megahash
its a Map implementation in c++, the dude made benchmarks until 1 billion keys
i dont think with a discord bot you will get close to need this
unless you use internal sharding with 100+ shards xD
if you can afford a 30k$ server to run it ok
process.on('SIGINT', signal => {
for (let channel of client.guilds.cache.filter(g => g.me.voice.channel).map(g => g.me.voice.channel)) channel.leave();
console.log(`Process ${process.pid} has been interrupted`) process.exit(0) })
My bot doesn't leave VC when I restart the nodejs process
i want to know sometimes the messageUpdate event fires up when a message is being sent , how do i fix it?
check if the message was just created by comparing the timestamps
but i dont think messageUpdate should fire on a sent message
@delicate shore u can try this:
for(let i of client.voice.connections.array()){
i.channel.leave()
}
or alternatively:
for (const [, i] of client.voice.connections) {
//...
}
Hi
I have a problem, how can I block the emojis or weird characters in the args? as well as isNaN but so that it returns true if they are letters or false if they are not letters
Please I need help with that
you could use regex to detect such stuff
Look, I'll explain, it's a search command with an npm but if you send emojis, the bot shuts down. It is a problem that I need to solve but now
Ok
wtf, why [, i]?
@halcyon linden yo hablo espaΓ±ol, que necesitas?
thi is a coomand in .js for ban !!!
if(message.content.startsWith("d.ban")){
var BanUser = message.mentions.members.first();
if(!message.member.hasPermission("BAN_MEMBERS")){
message.channel.send("non hai i permessi");
return;
}
if(!BanUser){
message.channel.send("menziona qualcuno!")
return;
}
if(!BanUser.bannable){
message.channel.send("mettimi il permesso prima");
return;
}
BanUser.ban()
.then(() =>message.channel.send("<@" + BanUser + "> Γ¨ stato bannato"))
}
what doesnt work?
i dont get why did you send it then here?
I recommend it !!!
