#development
1 messages · Page 1606 of 1
Yeah, if you made the application itll be the same bot
You just have to enter the token again.
indeed
Thats why my bot is still named the same
How do you get Bot Dev?
nvm
this is what happens when i clicked add bot. luca dmed me saying success! but when i go to the bot page it brings this
please check the pinned messages in #support
oh ok, what do i do? i have already added the bot twice
wait till the issue is fixed
I am really confused on what to do. I want to make a command where the bot gives a role to just 40 people at maximum, but even so some people said its a api spam even if I pace it 5-10 secs; while others said it's okay if I pace it.
so is it okay for me to pace it 5-10 secs and do it for only 40 members or should I just not do it at all?
@stark abyss it's a bad practice for a public bot to do stuff like that where mass roles are given out as it could quickly get out of hand and spam discords API, but if you're doing it just for your own server as an experiment, it wouldn't be API spam, and if it was, discord would just give you a "You are being rate limited" message
api abuse would be constantly hammering the api with no delay whatsoever
what you want to do is fine
how can i make a visitor counter?
if you know, ping me!!
in html
this isn't just for my server tho
impossible with html alone
well, the issue is if it's a public bot and it gets used by a fair amount of people, if 5 servers use that command at once the requests just pile up and up and up
html and js
oh that makes more sense
ratelimits are bucket based
oh what
this is still fine
so you can have this command on a public server, but keep the command private
javascript is backend? right?
global rate limit across the shard
like a whole ass backend?
you can use js as your backend through node.js
damn
but js alone is not backend
in a nutshell, it's just getting the ip from the request, making sure the ip wasn't already marked as a visitor then just +1
you'd use a database for this so the count is there even after your app dies
something like sqlite
having a hard time with removing a user ID from a json file.
{"userid": "code"}```
```py
@bot.command()
async def unlink(ctx, userid):
with open('config.json', 'r') as json_data:
jsondata = json.load(json_data)
for element in jsondata:
element.pop(userid, None)
with open('config.json', 'w') as data_file:
data = json.dump(jsondata, data_file)
any idea why this wouldn't work?
Getting discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'pop'
havent really messed with json stuff that much until recently
laughs in mern stack
oh wait you meant something else
if you were to use sqlite you'd just have a table and you'd structure it like this ```
+-------------+---------------------+
| ip | visit_date |
+-------------+---------------------+
| 192.168.1.1 | some unix timestamp |
| 1.1.1.1 | some unix timestamp |
| 8.8.8.8 | some unix timestamp |
| .... | some unix timestamp |
+-------------+---------------------+
then just COUNT the entries
the date is there so you can delete rows that are older than x hours/days/...
Is it a bad idea to use con.execute() for every mysql2 query
Because eventually it errors out due to too many prepared statements
You can only use pop on a list
>>>list = [1,2,3]
>>>list
[1,2,3]
>>>list.pop[0]
>>>list
[2,3]```
Also why are you iterating over the json and popping strings???
get the actual data with ```py
jsondata["something"]```
i have a code that changes the name of the channel and i added a cooldown to it beacuse it makes my bot super laggy after running it and i want to make it so people with perms can only run it but when i put this in my code js if (message.member && message.member.hasPermission("MANGE_CHANNELS")) { it gives me an error so i added another } at the end of my code but it doesnt respond.
i have no clue im too tired to be doin this rn been working non stop all day lmao, thank u
lmfaooo ight
Working with JSON for the first time can be challenging, take it slow if you can
yeah
it seems pretty simple if everything is predefined but like im trying to pass an argument in the command through to remove in the json list.
so like
;unlink <userid>
will remove the userid and their code from the json
linking was easy because its just dumping but im trying to delete a specific "key"
hey DBL. my D.py bot isnt responding to any commands other than mentioning it and it replying "hi" i have tried a lot of things like change prefix and so forth. can anyone help?
are you defining your prefix?
bot = commands.Bot(command_prefix="prefix")
)
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
try adding that and using .ping
### ----- Logging Initialization ----- ###
logger = logging.getLogger('discord')
logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
add that so it throws errors
import logging at the beginning aswell
ok
if it doesnt show anything with that, change logger.setLevel(logging.INFO) to (logging.DEBUG)
lol
debug should show a console output every time it sees a new messge
ill try to work. i have dinner. this has never happened
good luck!
ty
Can Anyone help me with this error:
https://sourceb.in/ROcEaO1m28
you're trying to use something that requires a number, but you're not giving it a valid number
const props = new (require(`${commandPath}${path.sep}${commandName}`))(this);```
what am i doing wrong?
TypeError: require(...) is not a constructor'
many stuff
how should it be then?
first of all why are you using new for require?
actually, I got a better question
what is that supposed to do?
load the commands
anyone know a good way to pull code from my json file by looking up ctx.author.id json {"userid": "code"}
tried this, but wont work:
with open('config.json', 'r') as cjson:
json_file = json.load(cjson)
traderchannelid = []
for item in json_file:
trader_info = {"{}".format(ctx.author.id):None}
trader_info['trader1'] = item['trader1']
traderchannelid.append(trader_info)
last thing i need to get working and of course i get stuck on it. starting to wonder if ini or yml wouldve been easier
wouldn't it be better to use a command handler?
define "pull code"
like, get a value from json?
Can you even do “new require” in JS lol 🧐
don't think so
yes
yeah pulling that "code" value from the json example i gave
you've seen it before
let Discord = require('discord.js');
let client = new Discord.Client();
//same as
let client = new (require('discord.js')).Client();
// the parenthesis is just there to make it easier for you to get it
Oh
Though, i think you might be able to completely fuckify this code into something not even experienced js users would do cuz its readability is super retarded
const { client: (new { Client })()} = require('discord.js')
i THINK this may be valid
Wtf 
yeah, you can declare destructured objects like that

let me run a test script rq
i think thats valid
though it might bitch about it being used before its declaration

no aparently not
you cant call it before it been delcared
const { client: { Client },} = require('discord.js');```
but this is valid
ACTUALLLY
nah you cant even call this inside there
@quartz kindle time for fucky code
can you try something like this?
wut
i dont think you can do any operation while destructuring
the same way you cant do something like this
tim has spoken
thats the challenge
i can do in one line or in two
the one line i showed before
const client = new require('discord.js').Client()
discord bot development 101
Wrong. 103
shit I frogot to take 101
oh dang
Is 150: use ts?
that one's probably 130 or something
In express, is there a way to have multiple GETs with one app.get()
For example like app.get(["/info", "/about", "/information") or something
uh
no
app.use?
sec
Not app.use LMAO
app.get('/*', (req, res, next) => {})
Ok
you can make a request handler and use it on all of your routes
function myHandler(req, res) {
// some shit
}
app.get('route1', myHandler);
app.get('route2', myHandler);
app.get('route3', myHandler);
ezpz
If Inc Is Equal To Increase Then Is Dec Equal To Decrease? When I Put Dec it Says Unknown So What Do I Put? Its For Mongoose
Hello?
OH Would It Work if Instead Of $dec I Put !$inc?
@mellow kelp
ANYONE!?!?!??!?!?!??!?!?!?
dude, don't ping random people
Pinging people in an aggressive manner gives you a 99% chance of not being helped
you should just use $inc with a negative number
idk what $dec does but it definitely doesn't decrease
But Its Not negative
just add a - before the number
so.. coins: -profileData.coins - args[0],
?
That Would give a negative output
so coins: -profileData.coins - -args[0],
Right?
or no
what are you trying to do
Im trying to decrease the two variables
minus it by eachother
and save the output into coins
ik
hmmm
Im so confused on where to put it
coins: profileData.coins - args[0],
},```
?
i meant set it to a negative value
huh
$inc: {
coins: -Number(profileData.coins - args[0])
}```
?
It Looks right
lemme try
bank: Number(args[0])
coins: -Number(args[0])
probably
thats what they are saying
oh
so bank increments by the value coin decrements (coin decrements cuz its negative number)
i've never used mongoose, i was just trying to help explain
ok
is there anyone using discord.py and has like a web_server (for dbl) set up to work asynchronously with their code
(I have already tried using aiohttp app runners, they work fine until after a few mins i get:
OSError: [WinError 64] The specified network name is no longer available)
How did you run the web server?
Welp, I don't have windows env, so this never happened. But if the webserver still runs, you can ignore the error ig 
there is some docs i can read for embed pagination?
would anyone know how to get the progress bar in the rank card to reset once the user levels up? because so far when they level up, the progress bar is in center or more in the card
depends how did u make the progress bar.. i make it with PIL, so to reset xp at every level up, i just get the progress bar color and replace with the progress bar bg color :/
i made it with discord-canvas
Can Someone Help Me Quick Heres Full Code -> https://srcb.in/01RuOKFNvS
How Tho, Wait Lemme Get The Code
cooldowns and/or time_stamps
const args = message.content.slice(prefix.length).split(/ +/);
to
const command = args.shift().toLowerCase();
to
const cmd = client.commands.get(command);
to
const time_stamps = cooldowns.get(cmd.name);
to
if(time_stamps.has(message.author.id)){
Everything looks fine
but still
OH I DIDNT DEFINE COOLDOWNS
nvm i did
const cooldowns = new Map();
So then What
I think its the .name
by any chance, are you blind?
it fucking says 'x' doesn't have a 'has' property
time_stamps is undefined
on the if statement
cooldowns.get
What if cooldowns defined as
if cooldowns.get is returning undefined, that means thats not a collection present, nor defined. try client.cooldowns.get
I keep getting this error, what does it mean? (node:22) UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.
Is there any way to directly push the data into the json.sqlite file?
(quick.db)
hi guys
how could i check if a guild has animated icon?
i tried to log guild.features
and i get
[
'COMMUNITY',
'WELCOME_SCREEN_ENABLED',
'NEWS',
'ANIMATED_ICON',
'INVITE_SPLASH'
]
for ex
how could i check if the guild has 'ANIMATED_ICON'?
you send a field with no data
well you can easy find it, usually you have 2 strings seperated by a ,
Is there any way to directly push the data into the json.sqlite file?
(quick.db)
¯_(ツ)_/¯
probably with sqlite
and no layer inbetween
or why did you want to do this in the first place?

array.includes()
One question..
I use usern = self.bot.get_user(userd).display_name to get the discord username in red bot
but then if I await bank.deposit_credits(usern, money)
I get 'str' object has no attribute 'id'. What am I doing wrong?
where is userd defined?
dont store ids as an int
I know the username is displayed properly
you are trying to use a username as an id, this is not a good idea. if a person changes their username they lose all their money
lol I load them from a file..
some languages do some funky stuff if you store the ids as a int causing them to alter
the user id is the discord.member.id
store the ID as a string not as int, if you store the id as a int is possible that it gets altered
you defined usern as display_name then gave it to deposit_credits
so you are doing deposit_credits(display_name, money)
yes
you dont want to store money based on username
like i said above, if you do it like this, they lose all their money if they change usernames
the user id is the discord.member.id
but you are giving a username to deposit_credits
from the error above, the deposit_credits functions is expecting the full user object
so just remove the .display_name from usern
hi
i have a problem with my script for a xp systeme
it can right the xp and the level but sometime it dont want to read it and it's totaly random when it dont want to work
sometime it work and sometime it's not
when it dont work it tell me 'Unexpected end of JSON input'
const jsonXp = fs.readFileSync(`./profils/${message.author.id}/xp.json`) const ListeXp = JSON.parse(jsonXp) const jsonStringLvl = fs.readFileSync(`./profils/${message.author.id}/level.json`) const customerlvl = JSON.parse(jsonStringLvl) const lvl = customerlvl.level_du_membre
here's my program
the problem is at the line 174
const ListeXp = JSON.parse(jsonXp)this one
on readfilesync define the encoding to utf-8
how do i do it ? 😅
const jsonXp = fs.readFileSync(`./profils/${message.author.id}/xp.json`, 'utf-8');
just like that
ok thanks you so much
the jsonstringlvl too
ok
sure
it still do it x')
the json look like this : {"xp_du_membre":52}
and this??
but the json work at 100% with another command
welp
how do i log with the console 😅
console.log(the thing)
Hey
so i got a dropdown menu
that shows the contents
and the button doesnt work
<html>
<head>
<title>LateSocialChat</title>
<meta charset="UTF-8">
<meta name="description" content="A Platform being developed">
<meta name="keywords" content="social, community">
<meta name="author" content="Matthan Sutton">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/welcome.css">
<script src="home.js"></script>
</head>
<body>
<div class="dropdown">
<div class="hidden">
<span tabindex="0">menu</span>
<div>
<a href="#">https://www.latesocialchat.com/registration.html</a>
<a href="#">https://www.latesocialchat.com/login.html</a>
<a href="#">https://www.latesocialchat.com/about-us.html</a>
</div>
</div>
</div>
<h2>Late social chat</h2>
<p></p>
<footer>
</html>```
I did steal the css and js for it but I am learning css and js
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}```
it log nothing @sacred aurora x')
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: hidden;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {background-color: #3e8e41;}```
so i have to recreate the file ?
does the file actually exist?
yep
how can I directly push the data into the json.sqlite file?
(quick.db)
im becoming crazy with it x') i've tried everything but still not working
Not my cup of tea, sorry
what mine the 'tho' (im french) x) @sacred aurora
though
thanks
no
oof
idk what to do now x)
so, using Docker Compose with mongodb, and apparently after making the db be offline for a little bit, the data was lost. ravy said it's probably because of a bad Docker Compose config, but I don't know how to work with Docker Compose so I had Link set up a config for me (since he offered it), but now I am not sure what parts of the config is bad.
This is the docker-compose.yml file https://pastebin.com/j5KNTEDa
I'll need some help figuring out what is wrong with the config seen as I am completely new to Docker Compose.
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.
wait i have a final idea x') @sacred aurora
what's that
A
as the xp is readed just before it what if i moove the code with that he read the xp which work to be read
sorry for my bas english x)
hmmm
try it first
i don't really get it
or try checking the xp json thats being read
maybe it really is empty
it's f*********** working @sacred aurora 
lol
you code it
hi how can i check a row exists with postgresql? im using select exists(select 1 from testtable where serverid=$1 but i dont get a true or false, i get SELECT 1
You make your bot's application via the developer portal, you have to code it yourself
Read this
Why do you need this over just selecting 1 and doing fetchone 5o get 1 or none

would be nice if you would have answered the question ive asked, bcs directly needs some more explanation
...
I don't think you understand how bots work... You don't write your code in the dev portal - the dev portal is used to get your bot token
This is a good tutorial for creating a bot application if you're using node.js with discord.js - https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot
don’t make a bot as a first project
learn JavaScript first
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:
- proper syntax
- debuging code
- basic features (vars, arrays, objects, functions)
- read and understand docs
- nodejs module system
As much as we'd like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.
Here are good resources to learn both Javascript and NodeJS:
Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie's Accelerated JS: https://js.evie.dev/
Please take a couple of weeks/months to get acquainted with the language before trying to make bots!
jsfirstbotlater learnjs
well you don't need javascript, I'm pretty sure you can make one in Lua if you know it
Minecraft's written in java
It's safe
,but make sure you understand what the code you're running is doing
After you install node.js you can run the js code on your pc
Uh... anywhere? You write your code down in a .js file, and use node.js to run it

Hey how old are you if you don't mind me asking
hey so i am trying to upload my id to discord
but it keeps saying this:
no matter how i take my picture, flash off/on.
you don't know how old you are?
what?
I was replying to Light's Good's "idk"
ah okay
so the dc verification brings you to stripe right?
before i hand my ID in to some randoms/thiefs.
Try taking a less blurry picture, make sure the ID is clearly visible against the background, try with a different background
yeah i could click continue anyways
however, is this dc verification linked to stripe?
Just scared to hand in my id. Call me stupid or something, but i have got low trust issues tbh.
okay thanks!
How can someone possibly fake that
discord requires your documents to verify your identity
idk, just wanted to confirm that.
yeah i know,
and yeah, DMs from the system bot cannot be faked
What does your application do? Please be as detailed as possible, and feel free to include links to image or video examples.can i just grab the info from top.gg and paste it in this field lmao?
Technically sure if it's relevant
is there any time limit of when user-ids should be wiped from a database>?
No right?
thanks btw!
Nope you can keep them as long as you need them
thank you!
look i am kinda new, so sorry for asking so much.
WHAT IS THE PROCESS FOR USERS TO REQUEST DELETION OF THEIR DATA?
tbh, they can't.
why not?
because this belongs to a warn command.
even after they left the guild?
owh yeah that can be done ofc.
Isn't it useful to keep warnings even after a person leaves though?
you could say that you keep them for like 1 month after they leave the guild or something like that
yeah it is, for like whenever he joins back the server or something.
they wont check if you're telling the truth
Liar liar pants on fire
I mean, if all you're storing is their ID and amount of warnings, then is it considered thair data? 
I guess
im pretty sure discord IDs are not considered personal information
WHAT SYSTEMS AND INFRASTRUCTURE DO YOU USE? okay dafuck?
Do they mean, like databases? Vps?
yes
Would decline your app if you wrote json database 
Yeah glad that i didn't use that.
but i don't think that they would actually decline it just because of a json database.
well
it's quite possible they would
because there's no data encryption whatsoever
yeah i use mongodb atlas
but made a back-up in json format. And saved that in my vps. The json doesn't contain any info of users, just the file format for the mongodb)
Is that an issue?
If yes, i will just delete that.
it's not meant to be used as a database, it's not fast and it's not reliable
they're slow and unreliable
wdym?
take a look at this
is this okay tho?
seems like a gray area to me
just to be safe i would encrypt the file contents
but keeping a backup is fine
okay thanks!
how would i even encrypt a json file. I will actually just watch a tutorial and try that out!
how big of a database are you guys talking about?
doesn't matter
I just use multiple files and read/write using filesystem
in the message you mentioned I read that you cannot write multiple things at the same time in a JSON file?
Thats not really true as you can read the file (an object) and modify multiple keys/values simultaneously
then just clear the file and write it again, we are talking about nanoseconds here
i've been using json files a lot, believe me it sucks.
and then saving the object
thats what Im saying
you cannot read and write simultaneously
and can you do that with a SQLDb?
one has to happen after the other
sure
any proper database is built to handle large queries, multithreading and concurrency
wait i am actually a bit confused now.
a proper database has more layers than just saving to a file
for a warn, kick, ban unban etc commands, would you need the server members intent?
that entirely depends on your code
Or wait yeah i do, for the total user count.
does anyone know a good image posting site?
thanks for the advice, I'll try setting up a proper database
do you know any good ones?
mongodb is really easy to use.
you can edit a json object in memory as much as you want, but when you write it to disk, you can only write it all at once, so if the file gets big, writes get slow.
a database can actually write to disk concurrently, by changing the bytes of only a part of the file, and not the full file, so they can concurrently write multiple operations on the same file
yeah true, the commands are all asynchronous and they might take a while
but thats what I was meaning to ask, how big is big?
this is probably one of the best explanations of why a database is better than a file I've ever seen and I'm keeping that somewhere safe
for json, anything bigger than 1mb is already slow
By reading https://javascript.info/
The JavaScript Guide shows you how to use JavaScript and gives an overview of the language. If you need exhaustive information about a language feature, have a look at the JavaScript reference.
whaa? what is this
considering a typical HDD writes at an average of 50MB/s, writing 1mb will take 20ms, while databases typically write in less than 1ms
server dbs also often keep a first and second level memory cache
to improve your access time
most stuff will get buffered somewhat
and databases are also protected against crashes by ensuring the change is either fully written or not written, avoiding data corruption
could anyone tell me what they mean by this?
you must write between 100 and 2000 characters in those fields
tbh I've only created small scale bots so that hasn't really been a big problem so far but Im switching to an actual database now anyways
i switched from json to sqlite3 and im very happy with it
using the better-sqlite3 library on npm
Does anyone know how to get the user's tag when the bot joins a server? or how to get the user's tag with a user ID?
the user who invited the bot?
perfect I use npm aswell, I'll try it out thanks bruddah
no. the owner of the guild that the bot was invited to
Im pretty sure everybody here uses npm lol
lol\
same
nop
Guild.owner will return the object of the owner, Guild.ownerId will return only the id
cuz i dont use nodejs 
Guild.owner could be undefined because the user may not be cached
Validation errors: infrastructure_third_party_accounts_description: Must be between 100 and 2000 in length. intents_use_case_supplemental_material_description: Must be between 100 and 2000 in length.
what.
yarn gang
multi langual app gang
tim already told you
owh
null :(
fetch it
Yeah, so you have to fetch the user yourself using Guild.ownerId
yeah i see that, but i don't even see a third_party_accounts_description
idk how to fetch sorry :P
await guild.members.fetch(guild.ownerID)
one of the fields probably has less than 100 characters, just find it and write more stuff
oh...
thats why await
wait
btw is anyone who's good at JS interesting in WebRTC 
im bad at everyhting :P
add async before the function
what the fuck should i add then?
oh sorry I replied to Youtube_101
lorem ipsum.
am i allowed to ask help in coding
you are not allowed to ask if you are allowed
or wait, it is connected to my vps as well as mongodb right?
but you are allowed to ask the question directly
lmao
third party auth services would be like routing logins through reddit and whatever other places
owwh
I made an async function
so i made a bot and i did all variables and all commands at last i wanted to add playing status and tried all the ways it is not working
so i need help
show c(@ode
you're awaiting the log
You need to await the fetch call,
not the fetch
the await is in the wrong place
OH
here
@eternal osprey how its very big
I don't think you understood what I said. You can do an oauth flow through reddit to get user reddit info.
i removed it tho
then add it back
i need help someone adding it properly
first try adding it yourself, then if it doesnt work, shows us what you did, and we will correct you
im kinda dumdum when it comes to fetch but is this right?
you can do let GOwner = await ...
dont need to put it separately
OH
you can also do console.log(await ....)
so anyone help
use a code sharding service, like pastebin or hastebin
tim btw, sorry for asking you again, but what is the exact issue of my background not loading in?
its easier to see your code that way
but the file is that bad
I changed everything, tried every non-encrypted image.
nobody bothers downloading files
However, it still doesn't show any image as background
c'mon its just 5kb lmao
plus they come as text files which people have to further edit to make it properly code highlighted
No is no.
thats why general convention is that code sharing is done through code sharing services
bruh why are yall doing this to me :(
because you're new here, so im introducing you to how stuff works :)
it worked tyy :))
ok then wait ill do it
pls help me
download that file :(
lmao
what file
thats your file
which part of it doesnt work?
it throws an error, too many brackets closed
what says wrong
thats the error it throws
I think you opened closed the Interval function too many times
check ||dms||
is that for me
yeah
yes
btw you should apply code conventions
either remove that one, or this one
ok ill do it
pretty print your code or something
hey tim, could you tell me why my background isn't working.
did you fix the things from before?
yeah i removed the background color part.
Is anyone else having problem with embedding Imgur image links ?
btw, it is Your(
not really
Not you're.
no, it worked fine for me.
imgur or discord have been having issues lately, just use another image hoster
setInterval(() => {
client.user.setActivity(`You're Status`, {type: "WATCHING"})
}, 40000)
let member;
client.guilds.cache.forEach(async guild =>{
await delay(15);
member = await client.guilds.cache.get(guild.id).members.cache.get(client.user.id)
//if not connected
if(!member.voice.channel)
return;
//if connected but not speaking
if(!member.speaking&&!client.queue)
{ return member.voice.channel.leave(); }
//if alone
if (member.voice.channel.members.size === 1)
{ return member.voice.channel.leave(); }
});
},
});
It dosent work for me
what is the mistake
show your code.
The activity
It is Your, Not you're.
lol
i dont understand

can you rewrite and send me
dafuck no,.
no spoonfeeding
could anyone tell me why my top,.gg isn't adding my background?
what is spoonfeeding
I'm pretty sure the problem is the fact that you're closing too many brackets
embed =>
(message, Title, Description, ImageArray) => {
try {
let a;
if (typeof(ImageArray) === "string") {
a = new Discord.MessageEmbed()
.setColor(ref.randArr(color))
.setTitle(Title)
.setImage(ImageArray)
.setFooter("Please Leave us a vote. [Use .vote]")
} else if (typeof(ImageArray) === "object") {
a = new Discord.MessageEmbed()
.setColor(ref.randArr(color))
.setTitle(Title)
.setImage(ref.randArr(ImageArray))
.setFooter("Please Leave us a vote. [Use .vote]")
} else {}
message.channel.send(a);
} catch (err) {
console.log(err);
}
}
Tried a different image hoster?
Forced reload the site to clear your cache (CTRL + F5)?
yup, did everything
are you trying to set an array as an image?
@untold ingot what was your problem again ?
No a random image from an array of links
show the ImageArray.
k
then you should do array[Math.random()*array.length]
or array[Math.floor(Math.random()*array.length)] I forgot
I did that as a different function names randArr
he already has a rand function.
oh my bad
aren't links seen as links? So shouldn't you wrap it in ""
but you're not using that here
randArr = (givenArray) => {
return (givenArray[Math.floor(Math.random() * givenArray.length)]);
}
if the input is string
oh you're either passing a single link or an array of links and incase its a single link it runs this
Don't take it too much
someone said not to use imgur for a while
yea
sorry what was your error again?
was it just an image loading?
also it wasnt posting the image
the image wasnt there either
try to console.log the ImageArray.
as it contains links.
it works when the link is from dropbox but dosent work for imgur
if that is the case, the imgur integration with Discord isn't working well atm.
Try any other image sites.
how can i contact a mod about my top.gg page? My selected images work when i watch them in preview, but after i save them it just disappears.
It happened out of nowhere, after months of good use.
I only have 5 Gib on my VPS so I.m trying to find a host on google
ping one
Not only that. Imgur has start to block a lot off clients from fetching images in the last months for some reason.
Sometimes private domains are getting blocked, sometimes just the http agent, etc. Imgur is going crazy.
yeah i actually had a good one, but forgot the name of it. I will send you the info once I remember it.
I use vultr rn btw
did u actually use the direct link not the imgur link?
instead of a ping, i will just dm a mod.
When I use imgur it dosent work but when I use dropbox it works
Recently Imgur started to block http agends including TeamSpeak in the name, causing all TeamSpeak servers worldwide not being able to fetch their icons or banners anymore
2 vvvvv diffrent things
imgur
So thats why it isnt working lol
with .png at last
tf is the diffrence anyway
one is direct the other is a link to the site 
Here's the demo file```json
[
"https://imgur.com/2Tbul1L.gif",
"https://imgur.com/lgcYfTt.gif",
"https://imgur.com/jj7DYke.gif",
"https://imgur.com/cODrsUg.gif",
"https://imgur.com/Eh4oKXL.gif",
"https://imgur.com/im4kYi3.gif",
"https://imgur.com/yTDYXaB.gif",
"https://imgur.com/lNiwGfw.gif",
"https://imgur.com/cppUzJZ.gif",
"https://imgur.com/PvPeCV2.gif",
"https://imgur.com/rcg1MHW.gif",
"https://imgur.com/dq5BQdK.gif",
"https://imgur.com/qQxxsIi.gif",
"https://imgur.com/3Um5fnP.gif",
"https://imgur.com/RFslRUj.gif",
"https://imgur.com/iFeuAJQ.gif",
"https://imgur.com/XujdW2O.gif",
"https://imgur.com/iTwYyxz.gif",
"https://imgur.com/yeAd07M.gif",
"https://imgur.com/1unIZqF.gif",
"https://imgur.com/8fhZcbM.gif"
]
yikes

That’s not a direct link. It’s getting redirected to i.imgur.com
Open the URL in your browser and copy the URL you see and try it in Discord.
with i. ??
Try it.
are you loading it properly into the embed?
let the image url print out into console before sending the embed
you're loading the whole array
the code or the console ?
or am i wrong
no it takes a random thing from the array
i mean this
"ITS FIXED GUYS IM USING DROPBOX NOW"
if (typeof(ImageArray) === "string") {
like i said earlier
if (typeof(ImageArray) === "string") {
Amazing way to make something un-readable ftw
IK thats why im still 14 y/o
🤨 Your age shouldnt be an excuse for lack of writing readable code
all its gonna do is make it 1) harder for other to help you and 2) harder for you to read and understand yourself 
I'll keep it in mind
Practice makes perfection 🪄
Everybody knows that the more complicated your code looks the better it is
If noone understands it it must be 5head code
No raw loops, declarative > imperative 🪄

You're like 11 give yourself some slack
has anyone successfully ran an aiohttp web application with discord.py for dbl webhooks? my thing works fine until after a few mins i'm assuming the websocket closes connection and i get:
OSError: [WinError 64] The specified network name is no longer available
the only workaround i could think of was to restart the app once it shuts down consistently, but the shutdown event happens much later
Does anyone here use influxDB?
I've got a bunch of logs, for example, every time a command is used I save a point in my influxDB with the command_name, the user_id of who used it and the timestamp obv. Now, how do I turn all these logs in a nice graph in the influx dashboard, I would like for example to have a graph that showed the total number of commands used that grows through time.
Grafana™️
Websocket? What does it have to do with the webhook?
im using a TCPsite which uses a TCPsocket
anyway, i decided to host the web server separately and have multiple connections to the DB instead
Hi so I have this array: let levels = [50, 100, 250, 750, 2500] and a number of xp for example: 150 now I need to use that XP to get the level + progress to the next level this function should return 2.33 (since 150 is bigger then 100 (2nd index) and smaller then 250, but is 1/3rd of the way to 250 (level 3)) how would I start on this function? I already have the part to find the level but not the progress: levels.findIndex((num) => num >= Math.floor(xp))
what
so 150 : 100 = 50 : x
250 is the xp of the next level while 100 is the xp of the previous one, the other 100 instead, the one after :, stands for 100%.
The 150 after the = is the current xp and x is the percentage to calculate
@tulip ledge
this would be: 100 * 50 / 150
so
which gives 33.333333333333 and so on %
right
function calcLevelAndProgress(levels, currentXP) {
// Your code to see the level
const currentLevel = levels.findIndex((num) => num >= Math.floor(xp))
const progress = 100 * (currentXP - levels[currentLevel - 1]) / (levels[currentLevel] - levels[currentLevel - 1])
}
alright ty very much
But you have to keep in mind about the first level, which doen't have a previous one
So
oh yeah I'll put a 0 as index 0 and to const progress = 100 * (currentXP - levels[currentLevel]) / (levels[currentLevel + 1] - levels[currentLevel])
function calcLevelAndProgress(levels, currentXP) {
// Your code to see the level
const currentLevel = levels.findIndex((num) => num >= Math.floor(currentXP))
const xpPreviousLevel = currentLevel - 1 > -1 ? levels[currentLevel - 1] : 0
const progress = 100 * (currentXP - xpPreviousLevel) / (levels[currentLevel] - xpPreviousLevel)
return {
level: currentLevel,
progress: progress
}
}
Or that
Which I think is more straight forward
if (args[0].toLowerCase() === "store") {
Error: ```
TypeError: Cannot read property 'toLowerCase' of undefined
EXTRA INFO:
TypeError: Cannot read property 'toLowerCase' of undefined
at Object.run (C:\Users\David\Desktop\Bot\addons\ADavid_test.js:24:21)
at module.exports (C:\Users\David\Desktop\Bot\events\message.js:519:31)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
How to fix on this?
you haven't defined args
if its a function make sure you passed through the args var
or make sure args are defined globaly
so i am trying to implement voice chat levels on my discord bot, how do i log a users voicechat activity? I am still unsure
or there is just no element in position 0 of your arguments-array
Im not sure tho
track their voice state updates
once you detect that a member is in a channel, store when it happened
once they leave the channel, get the date you previously stored and calculate your xp based on that
the same principle would be applied if a user wanted to check their xp
if the member is in a voice channel, get when it happened and calculate the xp at the time of the command execution
you would obviously mix in a database there
oh also
account for your bot downtimes
whenever you receive the ready event go through every guild's voice channel to see if any members are in there that your bot wasn't tracking yet
and start tracking those
Hi, i would like to use Mongodb Triggers in my node.js app. Basically receiving events when a document has been: Updated, Deleted or Created. Is there any easy way/npm package to do it? Also I'm using mongoose as my driver.
Or Connection.watch if you want to watch all models
since when did discord change purge messages max time from 30 days, to 14?
Idk.. I feel like it used to be 30 days..
But now I need to make that thing that will reply if error happened..
always was 14d
fine..
how do i fix that?
catch is a keyword, name your variable something else
I did catche... but now it says its undefined..
define it
TypeError: message.channel.fetchMessages is not a function
What version of discord.js are you using?
If you're using >= 12 all methods for messages got moved toChannel.messages
yup
thx
np
Does mee6 have a lot of expenses since it’s in 10m+ servers?
Yes
yup
Ugh why doesn't eslint auto-fix the linebreaks-style rule
I want my purge to ignore pins, anyone knows how could I do it?
If you're using the bulkDelete method then I don't think you can filter out pinned messages
lol
any method?
Actually you can specify the messages to delete
so I guess it's doable
You have to fetch the last N messages and filter out all pinned messages (by checking the message's pinned property)
do message have like a pinned property?
yes
But then you wouldn't be deleting N amount of messages, but N - pinned, if you're ok with that then this is a good solution, if not then you'd have to do some more fetching
nope
you need to filter fetched (assuming it's the messages you fetched), not the return value of the bulkDelete
I would just fetch all the messages from a channel
(await message.channel.messages.fetch();)
then while the specified amount of messages is greater than the deleted messages: if message.pinned, delete the message and increment deleted, else just move on to the next message I guess
does that make sense ?
I could write it in javascript if you want me to
using bulkDelete is better and less spammy
if the user wants to delete 100 messages you'd have to first fetch those 100 messages and then make a HTTP request for one of them - that's 101 requests
Using .fetch and .bulkDelete is just 2
let messages = await message.channel.messages.fetch();
let toDelete = parseInt(args[0]);
let deleted = 0;
for(let i = 0; toDelete > deleted; i++)
if(messages[i].pinned){
message.delete()
deleted++;
}
not quite sure if that would work tbh
you would have to do .purge <amount of messages to delete>
thats why I wrote parseInt(args[0])
It's spamming the API
weit wut
it is but how else would you do it
.fetch() fetches only 50 messages by default
i knwo but
Fetch the messages, filter out the pinned ones, use bulkDelete
wth
2 HTTP requests
then we could cap the .purge message to max 50 I guess
Yes keeping in mind that they spend like thousands of dollars every week here on #bids
yes but you're not doing what @earnest phoenix requested
It's exactly that - ignore pinned messages
how are you ignoring them if you're bulkdeleting lol Im so dumb
I dont get it
You're first fetching the N messages, then you're filtering out the pinned ones, and then you're using .bulkDelete
oh I thought you just fetched then bulkDeleted
yeah okay I miss read that Im dumb sorry
I saw 2 HTTP requests and thought you meant 2 commands
What shards do exactly?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
And is it benefic to my bot?
It is if you need it
discord sharding stays true to the meaning of shard, you split a big thing into a bunch of smaller things, ergo shard
Fetching N messages (N < 100) and then calling .bulkDelete is only making 2 HTTP requests to discord, the only limit being that the messages cannot be older than 14 days,
while fetching and calling .delete on each one of them is going to make N + 1 HTTP requests.
yeah I get it now I just thought you said fetch messages then just bulkdelete them
(without filtering)
The css file wont load for the html file
const command = args.shift().toLowerCase();
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
const avatar = message.author.avatarURL({ dynamic:true });
const Embed221r = new Discord.MessageEmbed()
.setColor('RANDOM')
.setDescription(`**Sorry <@${message.author.id}>, You Need To Wait \`${timeLeft.toFixed(1)}\` More Seconds Before Using \`-${command.name}\` Again**`)
.setFooter(`Yep, Need To Wait`, `${avatar}`);
return message.reply(Embed221r);
}
}
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);```
I Keep getting this error
can you paste the code in line 80
const timeLeft = (expirationTime - now) / 1000;
have you defined timeLeft somewhere else in your code?
if you have, then remove the const
then I have no idea
Want Me To Paste My Whole Main.js?
yeah go ahead
anyone know sailsjs?
huh
The code was probably pasted differently because I dont see a line 89
oh
well it says timeleft is not defined
so wouldnt you expect it to be in const timeleft?
I mean it doesn't make sense as you're defining timeLeft by using const but it says it is not defined
ikr
show your full code snippet
are you sure the line you pasted is line 89? Im asking because it says the error is at position 76
but the line you've sent doesn't even have 76 characters
lol
lol shit happens
lol
you were running an old instance
ok thanks!
I mean I was pretty much useless but no problem xD
Oml now there is another problem, when I do any command it has a cooldown
of 5 sec
I think it has to do with the 3
what in the literal fuck is your command handler lol
Lol
why are you doing this
its specific
cuz specific
I would use switch case
you're aware you can just
const commandObject = get(command);
if(commandObject)
commandObject.execute();
That's rather unnecessary
no lol
instead of stacking arguments
create a context object
const commandObject = get(command);
if(commandObject)
commandObject.execute({
client: your client,
message: message,
...and so on
});
then in your command you can just
execute: (context) => {
//you now have access to all of those variables
context.client...
};
clean up that clusterfuck
you should refactor your entire command handler before you implement cooldowns
you should have some amount of cooldown on every command



