#development
1 messages · Page 1585 of 1
text colour bot description
important didnt work either
hence the __description part
yeah
.entity-content__description > .content { color: #0c3ccc !important } should work though
how do i check what screen session this is
I haven't used screen, but can't you do screen -ls and see the PID?
Or you can probably try this
for i in `pidof python3`; do pstree -sp $i ;done | grep -v '^ '
how can i make this bar @ the bottom like move automatically?
like without hovering, or clicking anything
how can i make it like move
move where?
i got it dw
(node:2432) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
help lol
const manager = new ShardingManager('./bot.js', {
// https://discord.js.org/#/docs/main/v12/class/ShardingManager
totalShards: 'auto',
token: 'token'
});
manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));
manager.spawn();```
sharding managers im using
bot wont start without sharding so any help would be nice 👍
Google Cloud issues are preventing Discord from rolling out a fix right now. Just gotta be patient. My bot's been offline for an hour.
shit, well thank you lol
i think i figured it out
how do i make a bot create a channel with a name?
Ah looks like the sharding issue has just been resolved.
RTFD
?
RTFD = Read The Fuckin Docs
Basically "docs have only one job, don't take it from them"
oh
someone helped
nvm
This usually means something else crashed and wasn’t able to start which means your shard couldn’t start either and exited
change the padding of the elements
Any way I can just put it in such a manner that I don't have to scroll below
Padding is 0 everywhere
This is my code
is the See Above an image
nah
hewo, anyone know what this around mean?
I cant save my webhook settings ;-;
Might just be the fact that they're different divs or the script that's loaded is hella jank
your bot must be verified first on top.gg
yo i'm tryna make a review command that would take the message input and put it into an embed. This is my code but it seems to not function can someone help me?
await message.delete();
const bruh = message.content.slice(4).split(" ");
const saymessage = args.join(" ");
const embed = {
"title": `Review by ${message.author}`,
"description": saymessage,
"color": 4718336,
};
MessageChannel.send(embed);
return;```
Around is getting messages created around a message ID (slightly before or after)
https://discord.com/developers/docs/resources/channel#get-channel-messages
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
oh thanks, i didn't found about that code on any website
If you're using discord.js, you should look at the MessageEmbed class instead of trying to construct the embed payload. I don't even know if discord.js' message create accepts a raw embed payload
ight thanks for the tip
There are a few
different divs implicitly have padding you cannot remove and make them vertically align
How do I like..
filter to find a person by id?
I got that..
but fetch isnt working..
help.
client.users.fetch("id");
thanks. 🙂
:(
what's wrong in here
Literally nothing. Just that djs v11 still works but lol
Nice discord.js
"discord.js"
Yes
cough
did papi even have that
Wait. Fuck. I should have named it RichEmbed
what did you name it
What
is it the same as discord.js or just rewritten to mimic it?
Ripped from and just modified to TS and also to follow my eslint rules
hrm
I actually don't know, I never used the builder
I doubt it makes much difference
Any abstraction layer has overhead to process
The time lost is pretty negligible as well
Right
Haven't seen that nick in a while
@opal plank 1.3GB for 40k pog
Problem: The Data Does Not Save properly. By This The Command Does Not Work.
Error: I Do Not Know
const log = require('../../database/schemas/logSchema');
const name = 'logchannel';
module.exports = {
name: name,
category: 'admin',
run: async (client, message) => {
try {
message.delete();
if (message.member.hasPermission('ADMINISTRATOR')) { } else return message.reply('**You Do Not Have Permission To Set Log Channel**').then(message => message.delete({ timeout: 4000 }));
const channel = message.mentions.channels.first()
if (!channel) return message.reply('**I cannot Find This Channel**').then(m => m.delete({ timeout: 3000 }));
log.findOne({ guildID: message.guild.id }), async (err, data) => {
if (err) console.log(err);
if (!data) {
let newLog = new log({
guildID: message.guild.id,
logChannel: channel.id
});
newLog.save();
message.channel.send(`**The Mod Log Has Now Been Set To ${channel}**`);
} else {
data.updateOne({
logChannel: channel.id
})
data.save()
return message.channel.send(`**The Mod Log Has Now Been Set To** ${channel}**`);
}
}
} catch (error) {
require('../../structures/on_error')(client, error, name);
}
}
}
Error: I do Not Know
No way...
data.updateOne({
logChannel: channel.id
})```what are you updating?
The Channel ID
isn't that just the filter?
ah
try adding await await data.updateOne()
and I don't think you need data.save()
updateOne() does that for you already
just change
data.updateOne({
logChannel: channel.id
})
to
data.logChannel = channel.id
then save it
is this sequelize or mongoose?
i think its mongoose
that doesn't look like sequelize
it does
hey umm
how would i get a users' guild that he's an admin or owner of
using oauth
it returns all the guilds the user is in
use your bot
can i pass something like ?owner=true
nope
i need it from oauth
updateOne is not as cool as findOneAndUpdate
how can I get output of console.log in eval() ?
should I just not console.log and just do it the old eval way ?
what's your end goal?
redirecting stdout?
to get the console.log value from an eval
and why are you using eval in the first place?
You probably shouldn't use console.log in eval, but a custom function, which instead of printing to console, it puts the value in an array or something
don't question my methods... I know what I am doing
Right
yes
hi
(node:7960) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit``` im getting this error for years. i how to fix this
message
Ya
hmm
Just make a command handler or try making all commands inside 1 listener for event message
client.on("message", async msg => {```like this?
If you want to solve it
Ya
yes i want
And inside that put as commands as you can
when i have two good embeds and i try edit, it edits e1 to have both instead of replaceing e1 with e2
let e = blahblah
let edit = another embed
let msg = await message.channel.send(e);
msg.edit(edit);
oh well how do i make it not do that
if i do <Guild>.members.fetch(an id) but the member is not in the guild, does it error or does it just return undefined?
can i send tryitands.ee
check error code 
guess ill have to do that 😩
kekw
ever heard about our lord and saviour
the ? keyword
you need to show the code
otherwise we can't help
well
you are not passing the middleware
and you shouldn't create the webhook each time a post request is being made
also its better if you require modules at the top of your code
hey so this is my code
## Links
<a href="https://dsc.gg/">Invite Link With Perms</a>
<a href="https://dsc.gg/">SmartWikiSupport</a>
<a href="https://.gg/"><img src="https://invidget.switchblade.xyz/jp8et9xU56"></a>
<style>
@keyframes float { 0% { box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6); transform: translatey(0px); } 50% { box-shadow: 0 25px 15px 0px rgba(0,0,0,0.2); transform: translatey(-30px); } 100% { box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6); transform: translatey(0px); } } .entity-header__image { box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6); transform: translatey(0px); animation: float 4s ease-in-out infinite; }
.entity-content__divider{
display: none;
border: none
}
.entity-content__description {
background: none;
border: none;
}
body {
background: linear-gradient(135deg, #8a2387, #e94057, #f27121);
}
</style>
the thing is my color and stuff is visible in the preview page but after i save it it doesnt
Like in preview page: it shows color
In bot page: it only shows black and not my colors
ya mind helping me? pls 
can't rn sorry
okay ill wait
def check(reaction, user):
return user.id == ctx.message.author.id and (str(reaction.emoji) == '' or '')
reaction, user = await self.client.wait_for('reaction_add', timeout=600.0, check=check)
It doesn't seem like the check method is even running when I react to the message
tried printing something in it, but nothing happens
someone @me when help pls https://discordapp.com/channels/264445053596991498/272764566411149314/810086172733865995
if x == y or z is incorrect if you want to compare x to either
try to use .entity-wrapper instead of body
x == y or x == z??
You can either do any([x == y, x == z]) or x == y or x == z
Yea, I tried that as well. The check method isn't even running so for now it doesn't matter
That's interesting
def check(reaction, user):
print("Here")
return reaction.message.id == message.id and user == ctx.message.author and (str(reaction.emoji) == '' or str(reaction.emoji) == '')
This doesn't print anything
Are you sure the code block with the wait_for itself actually runs?
qt above
Cute person named Not Erwin
print("Here")
reaction, user = await self.client.wait_for('reaction_add', timeout=600.0, check=check)
This does print something, yea
It's just in a try block so it should run no matter what
x in (y, z) 
oh geez I forgot you can do that too
Do you have reaction intent enabled doe
DM_REACTION and GUILD_REACTION iir
DIRECT_MESSAGE_REACTIONS && GUILD_MESSAGE_REACTIONS
Oh, anyway. reaction_add only gets dispatched if the messages are cached
wait... theres a reaction intent ?
consider using raw_reaction_add instead
Oh yea, that was it. Jesus christ I'm sad
there is
Been sitting here for an hour
1024 and 8192 bitfields
What would be the difference?
it'll get dispatched despite the message caching
i assume there are no partials like d.js or something
on djs you could just fetch the partials and move on
There are partial objects
in fact, the emoji that raw_reaction_add returns is partial.
yall fighting on py, here i am fighting on ts
or, well, js
its not much ts related
trying to map something
by shards, in one line
I had my bot in py, rewrote it to Java and then back to py
i just rewrote to use a different and better lib, dont think i'll port something this big to another lang
Yea it's not fun, but it's something to do while you're procrastinating school work 
fair
I think Julia looks kinda fun, but there's so little documentation
even rewriting something on another lib is pain, let alone rewriting it in different lang
const client = new Discord.Client() - When I do this it does not fetch the users correctly
const client = new Discord.Client({ fetchAllMembers: true }) - When I do this my events don't work!
const myIntents = new Intents();
myIntents.add('GUILD_MEMBERS');
const client = new Client({ ws: { intents: myIntents } });``` When I do this non of the commands work!
I have Server Members Intent!
So can someone help me what I should do?
the last code block is the correct one
however
you only added the GUILD_MEMBERS intent
so you'll only get member related events
nothing else
let me pull up the docs
just use https://ziad87.net/intents/
uh ok?
i literally said let me pull up the docs chile
and use the bitfield instead, way easier and less pain
i am not sure what i should do lmao
select your intents/events and provide the generate number to the intents property
i selected everthing except GUILD_PRESENCES since i dont have that
will this work?
you tell me
like if the code is correct
it is working but it is still not fetching users properly
Guys, I know I sound like a nub asking... but, I forgot if it’s client.login(" ") or client.login(' ')
Alr thanks lol, sorry I forgot I’m just testing something
hey
const obj = require("./trainers.json")
idIndex = obj[firstmember].mons.indexOf(given1)
obj[firstmember].mons[idIndex] = given
idIndex = obj[targetMember.id].mons.indexOf(given)
obj[targetMember.id].mons[idIndex] = given1
so i have this code.
it should replace the given(1) with given as you see```js
{"345138133429649408":{"name":"Awsome","mons":[3298763,3949091,2493972,5281975],"currentBalls":3,"spawnIds":[7357173,7691225,6019191,6966024],"catching":false},"367251020914491392":{"name":"xGAMERSx","mons":[5234883,9689076],"currentBalls":3,"spawnIds":[1444051,2479025],"catching":false},"808344263598669874":{"name":"pea hancock","mons":[5370724],"currentBalls":3,"spawnIds":[7011973],"catching":false}}```
this is how the json looks like.
however, it doesn't error and doesn't change anything at all
For those whose CSS broke after the last update
- Try to use
.entity-wrapperinstead ofbody - Set
backgroundproperty totransparent !importantfor the class named "bTmyJW". Example:
.bTmyJW { background: transparent !important; }
this should stay here just in case 
it changes obj
but not the file itself
to change the file itself, you need to write obj to the file with fs
ooowh
will give it a go
i did this but the events are not working
like status not showing
i only added the fetchallmembers :true
everyone time i add it events dont work
log the debug event
?
client.on("debug", console.log)
the animation css attribute is not working for me??
Aren't they deprecating the fetchAllMembers option since it just causes problems?
was it working before? I mean before the css update?
I just edited my css with it and it didnt work I did not have it before. I tired on 2 elements and still no
they removed it completely in master already
that's good
you should only request for members when you need it
their implementation of fetchAllMembers was all borked
i had to fix it myself in djsl
sry for ping
it is sending sooooo many things and cmds are not working now
what are the many things?
can you dm me with your animation code?
do you have the GUILD_MEMBERS intent?
that infamous error
yes 😄
144
idk
discord only allows requesting members for 120 guilds per minute
so 144 guilds takes a minimum of 2 minutes
you need to change your client options to allow waiting for 2 minutes
so why is my status not working
done
@quartz kindle guilddelete is working but guildcreate not working
and status not working
i am trying to fix since yesterday
]]vps
you also have an error in the ms library
how to fix it?
hey umm ik i keep asking stupid questions but how do i get guild avatars from that hashtxt
like for users there's a avatars route
is there something similar for guilds?
so @quartz kindle it would be like this? ```js
const obj = require("./trainers.json")
idIndex = obj[firstmember].mons.indexOf(given1)
obj[firstmember].mons[idIndex] = given
idIndex = obj[targetMember.id].mons.indexOf(given)
obj[targetMember.id].mons[idIndex] = given1
fs.writeFileSync("./trainers.json", obj);```
as the obj now gets saved into the file
anyone??
v14.15.0
what the flying fuck is this
damn
i am trying to replace 1 id of the firstmember
with a saved variable
i know
{"345138133429649408":{"name":"Awsome","mons":[3298763,3949091,2493972,5281975],"currentBalls":3,"spawnIds":[7357173,7691225,6019191,6966024],"catching":false},"367251020914491392":{"name":"xGAMERSx","mons":[5234883,9689076],"currentBalls":3,"spawnIds":[1444051,2479025],"catching":false},"808344263598669874":{"name":"pea hancock","mons":[5370724],"currentBalls":3,"spawnIds":[7011973],"catching":false}}```
jesus christ
an array in an array with inside objects.
i mean... i tried my best 🙂
anyways, tim told me that the obj indeed changes. i just need to fs.writefile
the obj to this json file
learn to use a proper database, it's so much easier, faster and safer. You're paobably tired of hearing this lmao
tim should've told you to use a database
i am definitely tired of hearing this ;). I understand the point... but i just want to stick on with json.
My code already depends too much on json. It will take days to change it all.
i'll use real databases in the future, for other projects.
and thats why back dating 2 months ago, i warned you to use a database
this bot i am workin on is actually from 4 months ago.
And yeah, i understand.
I am also using real databases for my other projects.
I just can't get back to it with this code.
I think it's worth switching to a proper database
yeah i understand. Will have a look this week.
i literally told you to start using a database dating back 3 months
you started as 2 coordinates, and now you see how it spiraled out of control
yeah i do see that.
But once again, i can't get back now. I would have to change literally everything. 4 months of work gone,.
you can
also, this is only a bot for me.
a week at most to port your code
Not for public use.
how old are you?
yours you wont even need that much change, you'll simply use a database to store
23, why?
yeah, sorry i was asking it as i need to choose a study to follow.
yeah i wanted to follow computer science/software engineer. I wanted to know whether that was his study so i could ask him how hard it is, if it's fun etc.
you could wrap it in a code block and make the code block some language that changes the color of "" strings
like javascript code blocks for example
lol
so yeah i changed my code a bit but it still doesn't want to work
I'm doing computer engineering rn if you got any questions about that :)
could i actually interview you lmao? Just chat questions.
I'm only half way through my first year, but sure go ahead
how do you create a discord bot please in Italian?
Learn a programming language, and then use a discord bot development library for that language.
JavaScript or Python is a recommendation if you're new
Thanks
Thanks
how do you create a discord bot please in Italian?
#general-int if you want to speak in your own language
@marble juniper @near stratus , but what if I want an embed color string?
Hmmm is there any workaround for embed fields to be inline for mobile users too? It just looks so much better on desktop version
how can i solve this with js
u solve it already?
pretty simple
you can pretty much Google everything step by step and then add all the solutions together, if you don't want the challenge
nope its timedout
the docs for raw embeds are on the discord dev portal i think
but yeah above should work
@split hazel, @sacred aurora , thanks! <3.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
@split hazel thanks this can help me a lot
or just use the embed builder if that's easier for you
@split hazel huh, it didn’t work
the colour didn't work?
Mhm
show code
You need to put the color property identifier in the embed object. Lol
Ohh, lol
Hello, is using autoplay Youtube feature on bot prohibited? Like i want to play Japanese song, i added one and when the song ended, it'll search and play other Japanese song like autoplay do. I want to search this information in google but it's hard to find. Just to make sure i didn't break any ToS, because i can't find it on https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
Streaming YouTube audio from sources other than YouTube is already against the terms of service
yeah, but i stream audio from youtube
or scraping youtube in the first place
but due to discord not doing anything about it we don't really care
Tools like YTDL got DMCA'd for a reason. Thanks, GitHub
like normal autoplay do...
hey guys
Just know that whatever you do music wise is already against YT's terms of service
you mean playing a song then playing another one automatically?
var m = trainers[firstmember].spawnIds;
m.concat(founds.spawnId);
var d = trainers[firstmember].mons;
d.concat(founds);
var p = trainers[targetMember.id].spawnIds;
p.concat(found.spawnId);
var n = trainers[targetMember.id].mons;
n.concat(found);```why doesn't this change in the json file?
Is that because i need to write it first?
speaking professionally you'd probably want to ask discord but I've seen tons of bots (huge ones) having the same so discord probably won't do anything about it
r u using ytdl?
yep
You do need to write the changes from memory to json. Although, I would highly suggest using an actual database. JSON is only good for reading data from. Not writing data to
i mean u can use the recomendation object to do the autoplay thing
my bot has that feature too
oh i see, thanks for the information. i think it's not breaking google ToS..
it's recommending, but not auto playing?
by streaming music from their platform you're effectively ripping content from them with no ad revenue so it is against tos
but that's about the main idea of music bots
oh, ah yes no ads
I’m sorry, I’m a bit confused could you show an example?
You shouldn't worry about if it's against TOS or not. It always will be. So, just do it, I suppose
Yeah you just change cookies here and there
i just afraid if it's breaking any top.gg rules and get deleted
but thanks again for the information
this is really basic, you should practise more js before making bots but
{ color: "something", description: "something" }
🥺
#rules-and-info is all this guild cares about
which port does bots use to send request to discord api gateway?
trying to find a way to use librenms to monitor how many request my bots send
someone replied: 80, 443
but im unsure since music bot, dont it send music data through UDP aswell?
Alr thanks, and it will send it embed automatically?
@serene cliff none
yes as long as its in the reply/send method
You connect to the websocket
which it is
No port
Thank you, sor/ma’am lol
Voice connections are always UDP
voice is udp, gateway is tcp, rest is https
tcp is far too slow for good voice connections
since it validates if all packets were sent
so which port is it for udp, tcp then ?
wanna hear a tcp joke?
No
i was hoping someone would get the reference
okay i see.
There is no port you need to specify. If you're trying to create your own WS implementations, read the docs
https://discord.com/developers/docs/topics/voice-connections
https://discord.com/developers/docs/topics/gateway
alright thanks
isnt 443 for rest?
forgot to add that https uses 443
since its https
gateway should be 80, since its http plus upgrade
alright thanks, will configure librenms to listen to those ports thanks
Hl
hello is that just a friendly greeting before you're going to post a question or chatter
Uh
.setThumbnail(member.user.avatarURL({ size: 4096 }))
(node:11604) UnhandledPromiseRejectionWarning: RangeError [IMAGE_SIZE]: Invalid image size: 4096
I got this error.
Did I do it correctly with my Math?
max image size is 2048 iirc
What. How can I see other bots using my avatarURL having more better quality.
someone to follow me on my thoughts?
Ko-Fi's API doesn't exactly send how many months people have purchased for VIP
but it sends how much they've paid for
If I divide that for the price of one month, I get the exact amount of months to assign
e.g.: 15€ / 5€ (3 Months)
but the problem is people can pay for those months in other currencies, like USD or Yens
and the API sends me that info, in which currency was paid
I need to convert, but the only 2 modules I found, are outdated somehow
just set it to 2048
that quality is more than enough for a good quality
but if I make a function to convert, values can be outdated since 1 EUR is 1,21 USD, but can be 1,19 later
yeah it gets a bit messy
you need a currency converter api
Fixer provides a free, simple, and lightweight API for current and historical foreign exchange rates and currency conversion. The API tracks rates published daily by the European Central Bank.
will probably be quite inaccurate but it'd get the job done
seems the way to go
and while you're doing that maybe suggest to them to show how many months people are subscribed
hey guys
wait, what?
var m = trainers[firstmember].spawnIds;
m.concat(founds.spawnId);
var d = trainers[firstmember].mons;
d.concat(given);
var p = trainers[targetMember.id].spawnIds;
p.concat(found.spawnId);
var n = trainers[targetMember.id].mons;
let h = n.concat(given1);```how do i actually update the trainers[targetMember.id].mons; to the variable named h (without the rest of the file to be changed)
I have it through commissions
Donations are something else
and Shop... idk if it's a good option
like, Mudae does it through Commissions too
unless there's a simpler way
maybe the API could send me the bought item name
cant you just do trainers[targetMember.id].mons = h (assuming trainers is an object)
i tried
it doesn't work
{"345138133429649408":{"name":"Awsome","mons":[2571375],"currentBalls":3,"spawnIds":[3003152],"catching":false},"367251020914491392":{"name":"xGAMERSx","mons":[9811888],"currentBalls":3,"spawnIds":[4500501],"catching":true}}```this is how it looks like
@split hazel
i tried console.logging it and it looked like it contained all the expected info
it just doesn't write to the file.
i told you
i know,
if you want to update the file, you need to use fs
I tried doing it but it literally overwrites the whole file
yes
and only leaves me [id1, id2]
thats why json is not recommended
ah i thought so
because the only way to update a json file is to overwrite the entire file
i thought you were having trouble changing a value
and that's why DBs exist
yeah ^ something like sqlite would be much better since you can target that specific value
or anything really
mongo, mysql, postgres the list goes on
with json you have to
- load the entire file
- change the value you want to change
- write the entire file back
but assuming you dont want a whole database server you should use something like sqlite3
not saying JSON should be swapped with a DB, cuz JSONs work as DBs if you don't need to change any data
but since it's not the case
so there is no way how i can update the mons[] without losing all the other info?
there isn't if you just wanna use JSON.
there is if you create a DB
I use Firebase cuz it's simple as hell, but so different from MySQL - something I learned at school 😓
i told you how
load the entire file
and save the entire file
okay
no other way
or that
wait i am confused
forget what I said, do what Tim says
so i need to load the entire file. Using require
yes
require saves in cache
be careful with require since it caches the object (if i remember correctly)
but that's fine if you only have one application running and modifying that file
100%
if you have things like clusters/worker threads you need to use fs#readFile
to read every time you want to write to it
owh i already am using that to read it
but i am prob doing it wrong
as i am kinda confused
require()reads and caches to a variable- the info will be in the variable, ready to edit
- after every change u can overwrite the file with the edited info (which is inside the variable)
trainers[targetMember.id].mons = given1
trainers[firstmember].mons = given
const test = require("./trainers.json");
let data = fs.readFileSync(test)
fs.writeFileSync("./trainers.json",JSON.stringify(data));```so like this?
If i have understood it right
nvm you cant read from a variable
yeah i saw that already!
but ehmm
it kinda writes the buffer into the file
instead of the right info
so what's your current code
trainers[targetMember.id].mons = given1
trainers[firstmember].mons = given
let data = fs.readFileSync("./trainers.json")
fs.writeFileSync("./trainers.json", JSON.stringify(data));
});```
you need to set the encoding to utf8
owh shit ofc
also, why are you reading and then immediately writing to the file again?
and what you are doing now will result in absolutely no changes
There's no point in that
ooh
you also dont need to specify the encoding in writeFileSync since node will automatically detect the type, but since you aren't using readFileSync that's fine
then everything should work after you replace data with the stringified trainers object
it will only change the mons value to the value of given
by adding the []
great support @split hazel ! Really helped me out a lot!
Thanks
fast question
"message_id":"3a1fac0c-f960-4506-a60e-824979a74e74",
"kofi_transaction_id":"0a1fac0c-f960-4506-a60e-824979a74e71",
"timestamp":"2020-08-21T13:04:30.7296166Z",
"type":"Donation",
"from_name":"Ko-fi Team",
"message":"Good luck with the integration!",
"amount":"3.00",
"currency":"USD",
"url":"https://ko-fi.com"
"is_subscription_payment":false
"is_first_subscription_payment":false}```
Ko-Fi's API sends me something like this
when someone buys anything, "type" tells me if it's a Donation, Commission or Shop
but there isn't anything to tell me what they bought, until I reach their website
any ideas beside what I thought?
i mean if they don't tell you in the data payload there isn't much you can do besides find some api route that would let you track what they bought or scraping since you mentioned you can see it on their website
yeah, hope there is
is there an api route that would let you find the transaction details?
if there is, it's not official
this is all there is about their API
I should either find an unofficial API or install a Node module for that xD
.addField("Bancolombia", dinero.get(`usuario${autor.tag}.dinero_banco`))
it returns undefined
😐
o wait nvm
// These are the models that we are going to be requiring to connect to the database.
const Server = require("../../models/guilds/server.js");
module.exports = async (bot, message) => {
if(message.author.bot || message.channel.type === "dm") return;
const server = await Server.findOne({
serverID: message.guild.id
});
if(!server) {
var prefix = process.env.PREFIX;
} else if(server) {
var prefix = server.prefix;
};
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
if(!message.content.startsWith(process.env.PREFIX)) return;
let commandfile = bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd));
if(commandfile) commandfile.run(bot, message, args);
};
I've been stuck on this message.js as it isn't able to perform commands! I've made it so it can detect different prefixes but it won't work.
you check if the message starts with the default prefix, not the custom one
if(!message.content.startsWith(process.env.PREFIX)) return;
Also, you should probably cache prefixes so you don't get them from every time from the database
Where can I drag that, after if(message.author.bot)?
It has to be after you get the prefix from the database, duh
Yet didn't work, and I dragged it to
const server = await Server.findOne({
serverID: message.guild.id
});
if(!message.content.startsWith(process.env.PREFIX)) return;
the problem is that you are checking if the message starts with the default prefix
Even if the server has a custom prefix
also, that return ```js
if(!message.content.startsWith(process.env.PREFIX)) return;
uh it kinda is
why?
if(!server) {
var prefix = process.env.PREFIX;
} else if(server) {
var prefix = server.prefix;
};
if(!message.content.startsWith(prefix)) return;
I guess it's fixed now?
Because you would always check if a command exists, and try to parse the message, even if the message isn't meant to be read by the bot
yes
But yet no commands are working.
you should cache your prefixes
console.log prefix to see what it is
Well, I tried performing the command to have it console log but didn't work.
if(!server) {
var prefix = process.env.PREFIX;
} else if(server) {
var prefix = server.prefix;
};
if(!message.content.startsWith(prefix)) return;
console.log(prefix)
log it before
put it before you check if the message starts with the prefix
Ok
It's probably not what you think it is if it's not getting logged
tf
Ok.
Not be to mean!
I guess I was kind of stupid.
I had the prefix changed.
I was using the wrong prefix for the server.
well I guess it's working now
I'm making sure for multiple servers.
module.exports = async (bot, message) => {
if(message.author.bot || message.channel.type === "dm") return;
const server = await Server.findOne({
serverID: message.guild.id
});
if(!server) {
var prefix = process.env.PREFIX;
} else if(server) {
var prefix = server.prefix;
};
if(!message.content.startsWith(prefix)) return;
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let cmd = args.shift().toLowerCase();
let commandfile = bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd));
if(commandfile) commandfile.run(bot, message, args);
};
So this is the final result to the code, it's correct right?
All is left is to cache?
sure
You can remove that if statement and use OR const prefix = (server && server.prefix) || process.env.PREFIX
Sorry for late reply
You can use code blocks in embed too (inside .setDescription())
@split hazel there isn't anything 😢
wha
hey umm
does client.users.cache.get(id) find the user even with sharding?
idk why it sometimes returns undefined
no since they are stored on the different instances
anyone here use https://npmjs.com/dotenv
client.shard.broadcastEval(`this.users.cache.get(${userid})`)
``` @crystal wigeon you have to reduce the result
was this a question?
Yes
don't spoon-feed bad code
Where are the quotes
me ?
Just fetch the user, way easier
Yes
yes
Yes I use that module
thats not bad code, Do you have any knowledge about SHarding?
Of course he does kekw
I mean this user lol
well idk that much xD
some users were not getting detected by the client so asked
im using dotenv and it doesn't seem to read my variables. I got undefined while logging to console (and invalid token error from discord)
i thought sharding only did the server spliting thing
Have you tried specifying the env path?
paths are ```
src/.env
src/Bot.ts (where i use dotenv)
by fetch you mean client.users.fetch() ? someone here earlier said its bad tho so used get
yes
It's not bad
You can fetch the user on any shard instead of relying on cache
How did you specify it?
@pale vessel I talked about @lament rock , He meant that the code was bad, Probably they do not have the know how about sharding. @crystal wigeon wanted it from the cache. I gave them the way, how to fetch them ^^
I said he knows.
i tried ../ when im using dotenv in src/components/Client.ts
Have you tried using a full path?
lemme try
the code is doing what it should do. fetch the user from the cache 🤷♂️ , .users.fetch() is not good , since you could hit the ratelimit on multiply fetch
The user isn't guaranteed to be cached in one of the shards
Plus why not just fetch?
yes, I gave what they wanted 😦
The code wouldn't have evaluated correctly. The id would become an integer and Collection<string, User> is not keyed by an integer
I don't think so
yes lol forgot the """
That was what I was pointing out
show code
show bob
show vegana
🤔
nah, you do it in every command lol
how does your command file look like? how do you access Discord?
error says "Discord" is undefined
hey is gibo down?
I dont need anything from discord in my commands
show votifier.js
I will
@quartz kindle What do u think? is it good, and makes it slow?
then where is this line? const voteWebhook = new Discord.WebhookClient(dont look at this, dont look at this either bruh ;-;)
I did^^
Aki for fuck's sake, stop
its unnecessary
and it will make it slower
it will not make it slower
It's just pointless
You sure you're passing through big objects
They're just references
they are passed by reference
still pointless
Pointless, but it doesn't make it any slower
👍
"name":"AbortError","code":500,"method":"post","path":"/channels/755375798348677150/messages","level":"error"}
anyone know what this error means?
wtf is this line module.exports = (app, Discord, voteWebhook);
that makes no sense
That only returns voteWebhook, no?
lol
you dont declare what app is
then you are just requiring something
not doing anything with it
@solemn leaf So how can I access DIscord when I do not pass it? with require?
what are you trying to export
module.exports = (app, Discord, voteWebhook); first off when is app declared second off why
yes
honestly the entire file makes no sense. i dont know what you're trying to do there, but i see many wrong things
is that the full file?
and why do you even need to login
are you sure the role exists and id is correct?
the above code should work, even though you should be using .get() not .find()
message.guild.roles.cache.get(id)
Maybe the role isn't cached, if the id is correct
It's stupid that you can't fetch one role from the API
you have to request for all of them
Try doing <@&roleid> and see if it's a valid role
Maybe it's a deleted role?
Discord.js has a method for fetching a single role https://discord.js.org/#/docs/main/stable/class/RoleManager?scrollTo=fetch
because discordjs is a bad library
lying to your users, good one d.js
that code makes no sense
Python is the easiest language
just do ```js
let id = val.split(" | ")[1]
@earnest phoenix yeah but python developers don't know how to spell as you have just shown to us.
Oh wow im crying 😭
lmao
we're joking, python is fine
i personally dont like it, but it has its merits
Ok
defining types?
whats a type
describing objects, defining custom types, etc
ah okay thnaks
Document the type of an object.
what is typescript equivalent of require
for example require("xxx")()
what do you want to require?
dotenv-json
Oh that's a thing
still prefer dotenv though
didn't work 😔
let cantidadN = Number(cantidad);
if (cantidadN == 0) {
message.channel.send("No puedes depositar **0** barcoins!")
return;
} else {
if (dinero.get(`usuario_${autor.tag}.dinero_banco`) == "0") {
if (cantidadN > dinero.get(`usuario_${autor.tag}.dinero_mano`)) {
message.channel.send("No tienes esa cantidad de dinero!");
return;
} else {
dinero.set(`usuario_${autor.tag}.dinero_banco`, cantidadN)
dinero.substract(`usuario_${autor.tag}.dinero_mano`, cantidadN)
message.channel.send(`Se han depositado **${cantidadN}** Barcoins!`)
}
} else {
dinero.add(`usuario_${autor.tag}.dinero_banco`, cantidadN)
dinero.substract(`usuario_${autor.tag}.dinero_mano`, cantidadN)
message.channel.send(`Se han depositado **${cantidadN}** Barcoins!`)
}
}
this part of the code doesn't get executed 😐
another option is
{
"compilerOptions": {
...
"allowJs": true,
"checkJs": false,
...
}
}
then import * as env from "dotenv-json"
Full path didn't work?
Are you sure your file is actually called .env
which part
then the problem is not there
yes
Try turning on debug mode
Tim how long does it take to make a discordjs MessageEmbed?
I thought you guys did a shit load of tests?
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.
tim
well yes, but for like 100k iterations
that's for like 100k iterations
not just one
that's the entire code
if i recall correctly, 100k embeds took like 200ms
so realistically there is no need to not use embed builders
realistically no, only if you're a performance freak
as its such a minimal difference on the small level
just send embed object
atErwin
Not Erwin :^)
dont do this if (!dinero.get(`usuario_${autor.tag}`)) {
why?
autor
if the person changes their username, they lose all their money
i define autor as message.author
always use ID
is there anyone who can make a bot to combine servers in a master/slave kinda setup? Or does it already exist?
besides that, it seems you put the entire code inside if (cantidad == "all" || cantidad == "All") {
so it will only work for all, and not work for any other kind of value
if (cantidad.toLowerCase() == "all") {
if (!cantidad.toLowerCase() == "all") return;
const reacted = await promptMessage(m, message.author, 60, reactions);
````(node:9108) UnhandledPromiseRejectionWarning: TypeError: promptMessage is not a function`
I figured out the problem to the error above as it isn't adding reactions unortunately, but when I added the `if(!message.guild.me.hasPermission(["ADD_REACTIONS"])) return;` code, it yet errored. Even though it works in other servers fine and normal.
why it doesn't return?!
let cantidadN = Number(cantidad);
if (cantidadN.length < 2) {
message.channel.send("No puedes depositar menos de **10** barcoins!")
return;
}
@feral aspen Uh read the error, promptMessage isnt a function
return message.channel.send("No puedes depositar menos de **10** barcoins!");
xd
Yo, it works perfectly fine in other servers without erroring.
It has to do with permissions I think.
In the server I am testing, It isn't adding the reactions and it errors, but in my main server, it does
Ill check
Ha, it yet didn't return
bcs channels can have their own permissions
It still doesn't return.
It isn't adding reactions and since it isn't adding reactions, it errors TypeError: promptMessage is not a function.
Hm, one sec, I may have figured it out.
Hm, it wasn't from the permissions, but somehow in my main bot, the function works fine but in my testing bot, it doesn't, unsure why!
gotta love google
i was gonn search "is open source software good"
and the first suggestion i got was "is open source communism"
lmao
Array.from(new Set(commands.map(cmd => cmd.category)))``` is there a better way to do this?
I've spent the past 15 minutes trying to figure out why, not sure, any help?
promtmessage ? code pls
promptMessage: async function(message, author, time, validReactions) {
time *= 1000;
for (const reaction of validReactions) await message.react(reaction);
const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
return message
.awaitReactions(filter, { max: 1, time: time})
.then(collected => collected.first() && collected.first().emoji.name)
}
It works perfectly fine in my main bot, though.
Not sure why it is erroring in the testing bot.
Example on rock paper scissors command.
const m = await message.channel.send(rpsembed);
const reacted = await promptMessage(m, message.author, 30, chooseArr);
const botChoice = chooseArr[Math.floor(Math.random() * chooseArr.length)];
const result = await getResult(reacted, botChoice);
await m.delete(rpsembed);
``` It works PERFECTLY fine on the main bot, but why does it error here?
[...new Set] also works but other than that
hey stupid question, where do i grab my dbl token
Welp.
Anyone knows why the webhook is not working? neither the test or the vote. Its the first time im messing with webhooks so bear with me plz
try async function promptMessage()
python hmmm, where did you defined dbl?
Try await this.promptMessage(...
async function promptMessage(message, author, time, validReactions) {
time *= 1000;
for (const reaction of validReactions) await message.react(reaction);
const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
return message
.awaitReactions(filter, { max: 1, time: time})
.then(collected => collected.first() && collected.first().emoji.name)
}
i imported it, first i installed it with pip install dblpy, and then import dbl
where?
I defined it in a functions.js file.
so did you exported it correctly?
lol
const { promptMessage } = require("../../functions/functions.js");
okay , how does the function.js file look like?
The function works perfectly fine in my main bot, but doesn't work on my canary bot for some reason.
how do you export it
module.exports.run = {
promptMessage: async function(message, author, time, validReactions) {
time *= 1000;
for (const reaction of validReactions) await message.react(reaction);
const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
return message
.awaitReactions(filter, { max: 1, time: time})
.then(collected => collected.first() && collected.first().emoji.name)
}
};
does .run exist ? never used it lol
Bruh.
... you export it in a run object
so you need to do
import {run} from "...";
run.promptMessage(...
Why though? the function works perfectly fine on my main bot?
try it
its better, when you would create a class, then you can save all functions on a client.function and access on them
From where do I define run?
umm... you import the run object from the file where you export it?
