#development
1 messages · Page 1295 of 1
get the user through his id
guild.members.cache.get("id");
that'll return a GuildMember object or null if none was found
yes
Alright.
you can't get statuses of GuildMember objects tho you need to get the User object of it through member.user then you can get his/her statuses
I am using the ID to get the status of the member.
document.addEventListener("click",() => {
window.location.href = "https://donatebot.io/checkout/721707451375943740";
});
look at my brain
you're first getting the user through his ID
then you can check his status
lemme get the docs
this returns this: https://discord.js.org/#/docs/main/stable/class/Presence
you should know about presences if you used the Playing smth stuff for discord bot statuses
what
It worked.
@feral aspen you're getting the PROPERTY HamoodiHajjiri of OBJECT message even though you're defining a VARIABLE HamoodiHajjiri which is not a PROPERTY of OBJECT message
(too lazy to emphasize bold text so i just went for CAPS)
last Question
Is there a way I can check if this message is not in a specific server ID, then return;
How can I do that?
just use an if statement
message.guild exists?
if(message.guild === "serverID") return; ??
no
if(message.guild.id !==)
is this allowed
document.addEventListener("click",() => {
window.location.href = "https://donatebot.io/checkout/721707451375943740";
});
lolum
where though
@pale vessel on a useless website on https://theuselessweb.com
why name name still not green?
@carmine summit name's name is not green because name's name is name

why me not in koolserver?
why me not in koolserver?
@carmine summit you notum in koolum serverum because you notum clickum joinum buttonum
||we're trolling||
How do I make a discord bot
@silver lintel bruh that's the list of every single member of the server
no, thats me
you need to track them, discord doesn't offer username history
i think that's what you meant..?
yes ok
that's kinda like a privacy breach if you let anyone other than the user himself see the usernames
hm
can DSL detect if the bot is online or not even if the bot is not in this server?
yes
the DSL bot regularly syncs data with top.gg
if top.gg doesn't get another load of data sent by DSL every interval then it'll assume it's offline
Then, Why not, remove the bot that is offline for more than 3 days in the queue?
@carmine summit why you say DSL when you're talking about DBL
hm?
DSL == Discord Server List
DBL == Discord Bot List
What does this mean: 8. Must have a clear and obvious point of entry (e.g. a working help command)
you must document your help command
50% wrong
at least say use .help for help or mention for help in your description/bot status
what is my bot's activity is something like: Playing ?help | website.xyz
It just means your bot should have a clear description of how to use
A help command is recommended but botums have become weirder nowadays so smth else is also allowed
does that count?
How to add welcome message during javascript code (I dont want readymade code) just tell me the starting I dont know the starting. And in which file should it be server.js or any file else.
@earnest phoenix it's still spoonfeeding
Yeah
But just the starting plz
Rest I will do
Because I am a noob
Discord.js?
This is my first ever bot
@earnest phoenix yes using glitch.com on android
client.on(‘guildMemberAdd’, member => {})
Lol on me 😔😖
@earnest phoenix yes Thanks for motivating me it helped a lot lub you 😘
how to make botlist like DBL
@gilded lily there is no guide online but I'm sure it's super duper easy
@earnest phoenix what is the function of DBL?
@earnest phoenix yes Thanks for motivating me it helped a lot lub you 😘
@earnest phoenix uhhh are you gay or smth....
@earnest phoenix I am a boy
@earnest phoenix what is the function of DBL?
@earnest phoenix just a place where people can add their shit bots for the world to see
@earnest phoenix oh nice
@earnest phoenix are you girl or boy?
I'm gapple
also #general
this isnt development
@earnest phoenix what ?
how can I use substring() but it starts from the left
@gilded lily there is no guide online but I'm sure it's super duper easy
@earnest phoenix I was jk I know how to make one
how can I use substring() but it starts from the left
@carmine summit add 0 as the second parameter
ok
that tells javascript to start from that character
0 is the leftmost character
(you should know that js stuff starts always from 0)
Is it possible to use a different lavalink_host instead of the hostings lavalink_host?
It doesn't work on my code
see I have a code that returns miliseconds
and i want to convert them into seconds
without decimals
moment
@carmine summit Math.round?
or that
also can you send the code
yeah im just gon use Math.floor
Yeah Yeah
or just go straight for Math.round() if you're not using strings
Can I add purge,warn,welcome,ban,kick,mute,instant reply, economy,music in one bot?
Ofc it's your bot
Ofc
remember that you can't use it on strings
@earnest phoenix you can
And how to get a bot verified? And get verified bot developer tag
everything is possible in programming (other than NOT having AI take over the world)
And how to get a bot verified? And get verified bot developer tag
?
?
you can't get badge anymore
but you can still be verified
@earnest phoenix why?
ask discord why
Lol
And how to get a verified bot?
So basically, Don't trust JavaScript with GEMDAS
@earnest phoenix your country tell me your country so we can talk in a primary language
to be verified you need to have your bot in atleast 75 servers then follow the instructions they DM you
@earnest phoenix we can't chat in any language other than english in this channel
we're not supposed to ask programming stuff in #general-int (the only channel that allows other languages)
@oak cliff can we chat in other languages here
@pseudo temple stop
adverts
general 2 only so if someone needs dev help in another language you can talk there
ok
Is timers updating every 2 seconds considered as "1. Abide by top.gg’s Terms of Service, Discord’s Terms of Service, API rate limits and Developer terms."
@carmine summit yes it is API abuse
uh
make it 10 minutes
ok
that's the rate limit
10 minutes!?
go lower and you'll be beaned
alright
@earnest phoenix oh and is there any way to get inside on android not using pc or laptop
@earnest phoenix of course
but it's VERY VERY VERY VERY VERY RISKY
so i won't help with that
so uh
@earnest phoenix what will happen what are the risk?
I cant make live timers?
@earnest phoenix I want to get inside a bot using android nothing else
idk
ask auger
@earnest phoenix I was asking this
he hosts his bot on his phone
@earnest phoenix auger
Who is he?
do you have to ping every message
@carmine summit no
they're against API rate limits if they update too fast
@faint prism Can you help me in getting inside my bot from android nothing else?
But you won't be sued for them
is 2 seconds "too fast"?
@carmine summit yes
Server stats bot says discord forced them to make the timers uodate every ten minutes
What are you updating @carmine summit
message
oh
Is it a constant interval?
messages have API limits of 5 seconds for everything
It will load the servers to load every 2 sec making the servers slow that's what I red
yeah, I think
I want giveaway bot
Make it 5-10 minutes
Just because it abides with ratelimits doesn't mean it's not abuse
^
Whats 5 minutes in miliseconds?
but if you're going for channels like server stats bot the the limit is 10 minutes
Whats 5 minutes in miliseconds?
@carmine summit 5 * 60 * 1000
5X60=300
300X1000= 300000
5 * 60 = 300 * 1000 = 300000
xD
@earnest phoenix isn't it 100?
@earnest phoenix milli means thousandth
@slender thistle nice calc.
@earnest phoenix then what the 100
thanks
1000 is nano
So uh, What if the message will expire in 10 minutes?
100 is milli 1000 nano
clearInterval()
@carmine summit make the limit 7 min.
7 minutes, then the message can be updated every 2 seconds?
???
@carmine summit no make the update 7 min. And the message to delete after 10 min. It will give you 3 min. Lifeline
not "7 minutes first and then 2 seconds after"
What if its not constant
@carmine summit make it atleast 7 min.
like, It will not edit after 5 minutes
whats the recommended interval
shivaco's phone prob died 
@carmine summit see if the limit is 10 min. Make the min. Limit 5 min. So if bot gets late it will update at 7 or 8 min. Giving you 2min. Life.
shivaco's phone prob died :KEKlaugh:
@carmine summit I was thinking the same
Im so confused
Ok
@carmine summit make the limit 5 that's all and update after 5 sec.
@slender thistle is this ok?
yep, his phone prob died
@carmine summit yeah try I think it ok
@carmine summit I am in india and he is in Russia probably he is eating or sleeping
He is just 30 min ahead of me
wait @slender thistle's a male?
bruh you ping every message
k.
Had an habit due to replying in a fast messaging channel
You from which country?
I think Russia!
wait @slender thistle's a male?
@carmine summit yes
make the limit 5 that's all and update after 5 sec.
eh I'd say go for it
Wait shivaco a russian a Soviet union?
With first 5 letters of your name I thought you are ind.
development 
Slowly getting off-topic, let's move to #general-int
How to become mod?
-faq 12 -c
@slender thistle in this server
My bot won't get declined if i do this?
I highly doubt we would decline it unless it was actually getting ratelimited
What is the prefix of dbl?
@slender thistle yup
-ping
I'm alive!!!
-ping
I'm alive!!!
I want bot developer role
Hello.
Generate a random index and then get an element under that index
In. English?
what?
I've got an error else if wont work in my bot commands
(js)
show the rest of the code
Define "not working"
Yes
what do you mean 'wont work'
In. English?
@carmine summit What programming language do you use?
@sand sparrow Ok
because there is a semi colon on the first line
yes
on the
if(command === "ping");{
line
It works
lmao, it's ok @sand sparrow, common error
also when somehthing doesnt work, check logs
I SOLVE IT
I'm bad at this
itll tell you excatly whats wrong
Define "not working"
@slender thistle i love shivy
@sand sparrow I can help you with discord.js
Yea
I need more help lol
just ask
anyway guys, does Luca have chat bot / clever bot feature?
because, I am lonely rn
Nope
let p = `${...[ /* an array*/]}`;
SyntaxError: Unexpected token ...
wut
whats ... stupposed to be
spread operator
ahh yes
what
why inside a template literal and ...array should be inside an array
cuz
me dumbo
.join(", ");
... will return multiple values, but string literal thing only supports 1
ok
no template literal .toString()s it
no template literal
.toString()s it
@pale vessel u cant.toString()multiple values
we're talking about the fact that he's putting an array inside a template literal
its not [1,2,3] its 1,2,3
well u can put an array
but not with ...
ok
so spread operator no work outside objects?
no
(or func params)
functions are objects
function params work
||
||
@earnest phoenix you from india I came to know via emoji
Bhenchod How to add purge command?
how to make bot list @urban ridge
Responsive website with backend that utilizes a database
good luck making money off of it though
Thing is, are you sure you want to mention it here
yes
not you
ojk
new and original project :)
in a bot/server list's support server?
How can I make the Among Us effect, You know, the animation in was An Impostor.
it like, type animation
I have made my bot open a server, but I cannot authorize myself, how do I authorize myself?
Oh, understand
Edit the message or generate an gif
so the text will show up one by one, right?
yeah yeah
ok idk
ima think its somekind of str.substring(i, 0)
jk, I will try it for u
Editing messages quickly enough will just be a pain in the ass
a letter per second
what language are you using?
But, if you really wanna make it a thing... create an empty string, use a foreach on a string (if that's possible), append a letter to the empty string and edit the message
msg.channel.send('w').then(message => {
message.edit('wa').then(msg => {
msg.edit('was')
})
})
@carmine summit probably like that?
woah
"pain in the ass"
That wouldn't be that efficient
PLEASE NO
wouldn't that be abuse? you should create an interval
but
callback hell
But, if you really wanna make it a thing... create an empty string, use a foreach on a string (if that's possible), append a letter to the empty string and edit the message
why not do this
yes
Use canvas to generate a GIF
lol, use flash
i dunno how to use canvas lol
i dunno how to use canvas lol
@carmine summit ask flazepineapple he's a godum
@pale vessel
I have a question in terms of the Lavalink_host, is it possible to use a different one instead of using the hostings Lavalink?
oof
message.channel.send("w").then(msg => {
setTimeout(function() {
msg.edit("wa");
}, 1000)
setTimeout(function() {
msg.edit("was");
}, 2000);
})
Something like that?
Iam creating a bot in github and hosted by heroku i use json db and all json db reset in 24H for now i wanna use a nother DB
I don't now about a nother db?
something like this```js
let string = "hello";
let counter = 0;
let interval;
channel.send("word: ").then(sent => interval = setInterval(() => {
if (!string[counter]) return clearInterval(interval);
sent.edit(sent.content + string[counter]);
counter += 1;
}, 10000));```
*takes deep breath*
@solemn jolt JSONDBs ARE THE MOST RISKY THING IN THE ENTIRE UNIVERSE STOP USING THEM SWITCH TO SMTH LIKE SQL OR MONGO
AND DON'T WHINE ABOUT NOT BEING ABLE TO UNDERSTAND THEM
NOBODY IS BORN WITH PROGRAMMER SUPERPOWERS (except me)
The best way to use a database in heruko is to use a cloud database, otherwise you'll have to setup a ton of stuff, I don't know how it's done
heroku has a postgresql database for free
Use mongodb atlas free tier or that
Mangodb?
Mongo
How i can use mango db
depends, do you want to self host it?
Mongodb atlas is best for small things
Yeh
@compact oriole 😂 thx
also please learn actual freaking programming
you can use mongodb atlas like affax said and get the driver that supports the programming language that you use
mongo in javanese means please


god staying in dbl has made me tenfold salty from these weirdass whitenames
How i can lern mongo db ?
@compact oriole wait you have Kurzgesagt emotes
you can read their documentation
Bro I'm on their server
animationg worked out well, but........
let shown
let str = args.slice(0).join(' ')
msg = await message.channel.send(args[0].substring(0, 1))
str.split('').forEach(letter => {
shown = shown + letter
msg.edit(shown)
})
i gave you an idea of what i had: ```js
let string = "hello";
let i = 0;
let interval;
channel.send(string[i]).then(sent => interval = setInterval(() => {
i++;
if (!string[i]) return clearInterval(interval);
sent.edit(sent.content + string[i]);
}, 5000));```
the bot sends a message. after that, it creates an interval (by assigning it to a variable so that it can be cleared when done). it'll add a counter and edit the sent message until it reaches the end of the string (where it would clearInterval itself).
@carmine summit why are you making among us bot in discord
How to get invite link of a bot
get the bot id
@earnest phoenix
discord.com/oauth2/authorize?client_id=<bot id>&scope=bot
yes
Ok
Or you can generate an link in OAuth2 on the developer site
Where you created the bot
No it's not coming
by renaming their VC
to their code
so people wont just hop into a VC and ask "code?"
How to get invite link of a bot
@earnest phoenix Have you benn to discord developer wesite?
@earnest phoenix
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
There you can create the applicaton
Go to that link and go to oauth2
let shown = ''
let str = args.slice(0).join(' ')
msg = await message.channel.send(args[0].substring(0, 1))
str.split('').forEach(letter => {
setTimeout(foo => {
shown = shown + letter
msg.edit(shown)
}, 500)
})
```the setTimeout wont work properly
@sudden cape I have created application but how to get link?
You also have to go to bot and create an bot
@sudden cape I have
I have
Then go to OAuth2
And click bot in the field of options
The click on the perms that you want the bot to have
Then copy the link
https://discordapp.com/channels/264445053596991498/272764566411149314/762613754176340048
@pale vessel Im not the guy who usually does copy pastes
can you explain how the interval works
also, the interval dont work
interval repeats the function given after specified period of time (in milliseconds)
also, i tested it on my bot and it worked

it wont work on mine
show me what you did
were there any errors?
setTimeout won't work in your case, it only runs once
hey whenever i do node . i always get module not found
even if it is a blank workspace with no module requirements
let shown = ''
let str = args.slice(0).join(' ')
msg = await message.channel.send(args[0].substring(0, 1))
str.split('').forEach(letter => interval = setInterval (() => {
shown = shown + letter
msg.edit(shown)
}, 5000));
you need to define interval
it could be before shown
i don't know what you're doing with that code but it would be easier for me to explain what i did
whenever i do node .
let i = 0
let shown = ''
let str = args.slice(0).join(' ')
msg = await message.channel.send(args[0].substring(0, 1))
str.split('').forEach(letter => {
console.log(i)
setTimeout(() => {
shown = shown + letter
msg.edit(shown)
i++
}, 2000 * i)
})
```logs `0` for every word... WEIRD
its normal
why tho
2000*0
kirito how is asuna lol
i see u guys are busy ill come ask later idk js
why my i++ no work 
bruh
k fine ima do for loop
can anoybody help me
what https://discordapp.com/channels/264445053596991498/272764566411149314/762613754176340048 does:
- define string to use (
string) - define a counter (
i) for the string (first index first, so 0) - define an unassigned variable (
interval) (for clearInterval) - send the first letter (strings can be iterated so we can use indexes! that would be
string[i]) - after the message is sent, create an interval by assigning
intervalasetIntervalwith a function. the function adds 1 to the counter (i++) and appends the next letter to its content (sent.content + string[i]). this could go on until the accumulated index does not exist on the string (if (!string[i])), it will stop the interval by clearing it (clearInterval(interval))
re
my. i++. does. not. work
Why is this happening
my. i++. does. not. work
show your code
wait one sec
so apparently
i moved the i++ to the top
and it worked
let i = 0
let shown = ''
let str = args.slice(0).join(' ')
msg = await message.channel.send(args[0].substring(0, 1))
str.split('').forEach(letter => {
i++
console.log(i)
setTimeout(() => {
shown = shown + letter
msg.edit(shown)
}, 1000 * i)
})
why tf did i not block it
what is wrong with me
how did you start your script?
isn't there a missing })
show your package.json
Unfinished brackets
that can be looked on later
and your index file is called?
index.js
Unfinished brackets
fixed all of that but it didnt make a difference
can you send the full error?
ok
throw err;
^
Error: Cannot find module 'C:\Users\farah'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1065:15)
at Function.Module._load (internal/modules/cjs/loader.js:911:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}```
are you sure you don't have any other files
I'm probably wrong, but isnt it new Disocrd.client?
the error indicates they're trying to require a local path
ok i fixed that still problem persists
did you mess with node_modules
no
then you're trying to require your path somewhere
do you have any other files in your main directory like cry said
your index.js is 46kb?
this doesn't look that big at all https://discordapp.com/channels/264445053596991498/272764566411149314/762622738481152001
so that wasn't the code...
lol
uh
jeez
basically
bin your index.js contents at https://paste.mod.gg
its the code without all the commands
Hi I am a new dev
i just took out the commands chill
but why am i getting the same errror everywhere
in different projects
whenever i type node .
imagine going to the doctors because you keep coughing but you don't mention that you smoke a pack of cigs a day
great analogy
also
its not a problem of the code
cus the same code works on heroku
and the bot is running on the same code on cloud
so its a local thing
it could be that you don't have some of the modules
heroku installs modules inside the package.json so it's guaranteed to work
try running npm i
did it
try starting your bot
doesnt work

yes
delete your node_modules folder and re-run npm i
where did you run it
^
is it the same directory as your index.js?
yes
either npm didn't install packages successfully or you didn't run it in the right dir
double check it
cd <dir> or just boot up cmd in the dir from the context menu
i have winterminal so it's a bit different but you should have something like this for cmd
wait
don't tell me you've been running node in the wrong dir the entire time

^
let Days = moment.duration(message.createdTimestamp - message.guild.createdTimestamp).asDays()
this is correct?
wait
well, only you know the values
if i do node . from visual studio code
was it correct?
the days are like this
it gives me the same errro
just round them
do i need to do it cmd every tiem
cdeez nuts
Set-Location -Path <p>
i think you can omit the path arg
it's there by default
no
need to do it every tiem?
well, if it isn't going to stay there permanently, obviously yes
or you can open your project folder with vsc
vsc is going to recognize it as a project and the terminal path is going to default to the current path
i love using windows terminal instead
tabs yum
and WSL2 support
No one asked.
but they did hun lol
how do i make anti spam discord.py
Windows terminal is so amazing
Finally tabs
I only found out 3 days ago and left bed at 4 am to download it
lol
Hoe to add space after every character in js? .split('').join(' ')
@silver lintel are you not doing that
did you just answer yourself
also if you want to get every character in an array, you should use the spread operator instead of splitting by ""
Oh it's right then
also if you want to get every character in an array, you should use the spread operator instead of splitting by
""
@sudden geyser ?
[..."string"] // ["s", "t", "r", "i", "n", "g"]```
:O
@silver lintel see this stackoverflow answer: https://stackoverflow.com/a/34717402
how do i make anti spam discord.py
can anyone help?
how to i make customable prefix to my bot
do u use python js or ...
Save the prefix in a file as array for example together with the guild id, load and cache the file on startup and there you go
Hi guys,
Do you know how to make a command with multiple arguments?
like a message or something?
What lib?
djs
Args?
yess....
how do i make anti spam (discord.py)
Command: !command hi hello :)
args = ['hi', 'hello', ':)'];
console.log(args[0]) //hi
Is this what you want @balmy anchor
something like this:
(Example) !role create My Name Is SuperMan
Ahh ok
I know how to do it,
But I dont want to make an if all the time for any arg
What are you trying to do?
And you want the role to be called 'ny name is blah blah blah'?
yes
how do i make anti spam (discord.py)
I've already made it but I just want to have the command with multiple args and not only 1 or 2
then args.slice(1).join(" ") is that i think
Doesn't work, anything wrong with this code?
welcomeChannel[bot.guilds.cache.get(message.guild.id).id] = {
name: message.guild.name,
channel: channel
}
fs.writeFile("../../welcomeChannel.json", JSON.stringify(welcomeChannel), (err) => {
if(err) console.log(err);
});
}```
Np
@violet mesa if nobody is helping why keep spamming the same question
wait for somone
it's your code, debug it
still cant seem to know the problem
also you can goto discord.py server and they'll probably help
Logs?
it doesnt writefile thats it
also you can goto discord.py server and they'll probably help
@earnest phoenix im not in any
@feral aspen welcomeChannel is an array?
also you can goto discord.py server and they'll probably help
best they'll tell you is to either rtfd or google it
Can't really vouch for that server anymore
Anyway, @violet mesa still need help?
const welcomeChannel = require("../../welcomeChannel.json")
yep
python after all
i do
json go brrr
@feral aspen JSON DATABASE WHY WHY WHY WHY WHY WHY
Bro, I didnt ask for the opinion, I just asked what's the problem.
back to square one saying JSON databases are fine if used properly
bruh
@earnest phoenix, Bruh moment öyle bir andır ki
Bruh
ill make an empty list of through python to json
and add message
(each user has its own using id)
and remove everything after 5 seconds
JSON needs to be completely parsed before it can be used in the code
If you need just a single object from it you'll need to parse the whole fucken thing
Real fucken databases like SQL and MongoDB only read files when they're needed not all the time
Not that easy
Alright.
welcomeChannel[bot.guilds.cache.get(message.guild.id).id] = {
name: message.guild.name,
channel: channel
}
fs.writeFile("../../welcomeChannel.json", JSON.stringify(welcomeChannel), (err) => {
if(err) console.log(err);
});
}``` It doesn't writefile, I tried putting the Stringify something else, still doesnt work
ill make an empty list of through python to json
@violet mesa The only thing I can come up with a dictionary, user ID as key with a nested dictionary as value, containing message content and count
how can i do that
so i make a list with user id
then add all the messages to that list
and remove after 5 seconds
if there is 5 messages that are the same
i delete
It is not that easy
them
It is not that easy
i know
im just lying idea's of what i can do
send the list to json
1
2
3
Spam
Spam
clear
Spam
Spam
Spam
4
5
Bruh
mhm
so i make a list with user id
put in json
then add all the messages to that list
and remove after 5 seconds
if there is 5 messages that are the same
i delete and mute for 5 mins
this is what i came up with
does that sound good?
If you are clearing the whole list, the messages the user sends before are not included in the next lidt
mhm true
Which means they don't get counted
1
2
3
Spam
Spam
clear
Spam
Spam
Spam
4
5
@silver lintel
yep
mmhhhmm
maybe i create a list every 5 mins and just put aside the other list for now but if the next messages contain what the last list has they get muted
store time when last repeated message was sent inb4
?
basically when last repeated message was sent
check if it happened within, say, 5 seconds
if yes, increment your count
if not, reset the antispam data
ima create the json file
I'd suggest against JSON database for this
specifically, storing on each message
what should i save in?
a real db
just a normal python list?
Cache
whats cache
?
yea
wait
why do i need to save it like that
i can save it in a normal list cant i?
why list
The only thing I can come up with a dictionary, user ID as key with a nested dictionary as value, containing message content and count
wouldnt a hash map be better suited, or am i missing the point of what hes doing?
guess ill use a key
what should i name it so it doesnt look bad
lol
messages
ill call it messages
bot.antispam = {
123: {
"message": "spam",
"count": 2,
"last_sent": some_datetime_object_that_was_stored_when_the_message_was_sent
}
}
ok
so
on message
and then i get a var to save when it was sent
then "last_sent" would be the var
so
what
"last_sent"=varname?
no mad pls

Are you familiar with Python dictionaries?
I really suggest you take a step back and learn basic Python itself
because you wouldn't have a problem understanding my snippet if you were more familiar with Python dictionaries
in any case
You need 🐍 to work with 🐍
How are you going to build a house without knowing how to use the tools
bot.channels.cache.get(channel).send("Welcome to the server!")
Cannot read property send.. 😐 am I dumb?
the message key is the message content itself, count key is the number that's incremented if now - last_sent (both datetime objects) in seconds is <= 5
or just missing something
what is channel defined as
@thin turret i thought i knew most but i guess no cause i saw some tuts
module.exports = async (bot, message) => {
const channel = welcomeChannel[message.guild.id].channel
if(channel === null) return;
bot.channels.cache.get(channel).send("Welcome to the server!")
}```
That is how I did that.
the
messagekey is the message content itself,countkey is the number that's incremented ifnow - last_sent(both datetime objects) in seconds is <= 5
@slender thistle mhm
use if (!channel)
json dee bee
what does welcomeChannel[id] return
don't use json database
^
smh
Once again, being unhelpful in fixing the issue instead of bashing people for using a JSON database
@slender thistle can we go to dms so u can shout at me ?
its a pretty simple fix, just use channel.id assuming you used the entire channel object when storing
so what is the problem
cuz i just opened discord
bot.channels.cache.get(channel).send("Welcome to the server!")
@feral aspen i think u save the channel object in that json
so maybe u just have to do channel.id
thats what i said
lol
👀
Overall idea is following:
import datetime
bot.antispam = {}
@bot.event
async def on_message(message):
data = bot.antispam.get(message.author.id)
if data:
if (datetime.datetime.utcnow() - data["last_sent"]).seconds <= 5 and data["message"] == message.content:
if data["count"] < 5:
# increment the "count" key
else:
# punish and reset the data
nice
@slender thistle thx i shall now learn python
👍
Pog
# increment the "count" key before i go do that do i just do data["count"] += 1?
or again im dumb
so maybe u just have to do
channel.id
@dark kestrel Yes, I saved the entire channel information into that json file, thank you though.
@slender thistle ?
yay!!!
is there i++ in python?
Nope
ic
It's either n = n + 1 or n += 1
n+= 1 is best in my opinion cause if u have long var names it will be easier to see
but who am i to judge
it's the same thing ¯_(ツ)_/¯
yep
With strings though it can get trickier
like
if i != len(s) - 1:
if i < 3:
string = s[: i + 1] + string
else:
string = s[i - 2: i + 1] + "," + string
plz teach how to use canvas
Look at the docs






