#development
1 messages · Page 379 of 1
:3
embed = discord.Embed(colour=0xC29FAF) # colour code is changeable
embed.set_thumbnail(url=ctx.bot.user.avatar_url)
embed.add_field(name="Dev", value="your_name", inline=True)
embed.add_field(name="Lib", value="discord.py", inline=True)
embed.add_field(name="Guilds", value=len(ctx.bot.guilds), inline=True)
embed.add_field(name="Support Guild", value="[Here](https://discord.gg/no)", inline=True)
await ctx.send(content="about the b0t", embed=embed)
I referenced this line on discord_bot.py:
https://github.com/AlexFlipnote/discord_bot.py/blob/master/cogs/info.py#L46
discord_bot.py - A simple discord bot that helps you get started within discord.py
How do I make it so if args(a number) has a m on the end it does something, but if the same args has a h on the end, it does something different, and if there is nothing on the end, it does something else (for example returns and says invalid usage) discord.js lib btw
can somebody help me?
@bot.command(pass_context=True)
async def promote(ctx, user):
""" Promotes a member to the next rank"""
if ctx.server.id == int("idhere"):
member = ctx.message.author
role = discord.utils.get(ctx.guild.roles, name=str)
if role in member.roles:
afterrole = ddrankroles[int(role[1:3]) + 1]
if name == "None":
await bot.say("There isn't anyone with this username")
else:
await member. add_roles(afterrole)
await member. remove_roles(role)
ddrankroles = {1 : "L01. Stranger" , 2 : "L02. Young" , 3 : "L03. Earner",4:"L04. Pickpocket",5:"L05. Thug"
,6:"L06. Racketeer",7:"L07. Sender",8:"L08. Wise guy",9:"L09. Representative",10:"L10. Guider"
,11:"L11. Advisor",12:"L12. Don",13:"L13. Father"} ```
..
error? library?
i have imported whatever needed
I said error and library
I want to make a promote function
it will check if the server id is the right one
then if the one who did the command is admin
and then will promote the user
i dont know what to do to make it work
how can I make this so I can mention someone to get their avatar url?
if (message.content.startsWith(prefix + 'avatar')) { message.reply(message.author.avatarURL);
well
You check if a user has been mentioned
And if so, send the user’s avatar(URL)
so any help?
maybe :3
ok
well I’m not gonna spoonfeed you, take what I told you and apply your knowledge of JavaScript to make it work
not you @earnest phoenix
.-. k
if you don’t know js pls learn
this chat assumes u have working knowledge of the lang
I just want to know how to direct commands at other people so I can get their avatar @frail kestrel
anyone know why this aint working?:
if(!msg.content.includes("m") && !msg.content.includes("h")) return msg.channel.send(incorrectUsageEmbed);```
it just returns but doesn't send the embed
what’s incorrectUsageEmbed defined as
returning stops the rest of the function from running
oof
oh nvm
yeah i know, but it should send the message too.
But that should send the embed 👀
oof
same
same
same for me
dbl m00t for auto embed!111!!11
because m is minute and h is hour so if the number doesn't get h or m after it it wont know what to do
https://google.is-a-shit.host/M1sLNvt1.png why does this happen when using dark mode?
@quiet bobcat what happens
let me ask you, does it look good to you?
Yes

I like it
fixed it

nothing
"SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at createScript (vm.js:138:10)
at Object.runInThisContext (vm.js:199:10)
at Module._compile (module.js:626:28)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)
at startup (bootstrap_node.js:193:16)"
what is it ? ;-;
my code is so big ^^'
since you have shown multiple times that you use VSCode, look at where an error is shown and see what it says
actually yeah read your error carefully
they are meant to be read to help you find the problem
ok
I suggest learning terms for js syntax, it might help you figure out your errors better
or just learning js straight out
ok thx
Whats the error ? bot.on('message', message => { if (message.content.startsWith(prefix + "cchannel")) { let myrole = message.guild.member(bot.user).hasPermission("ADMINISTRATOR") let yourole = message.guild.member(message.author).hasPermission("ADMINISTRATOR") if (!yourole) { // si il n'a pas la permission message.channel.send("Tu n'as pas la permission 😕") } else { let cname = message.content.substr(prefix.lenght + 9) // on récupère le nom du channel message.guilds.createChannel(cname) // on crée le channel message.channel.send("✅ salon créé !") } } })
if(msg.hasInvite()) msg.delete()
How can I get the message Id?
what lib
so quick question, can i readfile a file using fs that i got from sharex without saving it
how can I get this in Java?
Yes
yes but
what date do you wnat to set it to
the methdo to set it is just
in the EmbedBuilder
setTimestamp(...)
anyone here using mongo grid-fs
how to make a vote command d.js?
Can someone help me?
i want my bot to send me a Invite link to every discord server it joins
it sends me Server id's when it join
why would you want to do that
dont question me...
No offense but I find bots very creepy when their owner has an invite link active for them to just randomly join your server
well thats you
I have ID's, names and membercount but if they ask me to troubleshoot I'll still need to join
For proof that they are actually admin
pfft I don't do that. I just trust my users. If something is sketchy then I won't do anything. Anything I do would still require them to have permission to do said item
Kinda need too, can't trust anyone when your bot is used for security
Mines a moderation bot and I still don't?
trust issues fam
anyone use express and nginx
yus
I've used it
Although not an expert or know much with it
nginx is debatable. I don't use it much maybe like once
i keep getting a 404
with?
using them both
uhhh what now
im asking if anyone knows how to fix it
but im 100% sure i have the stuff in the directory
I mean with express.... I can't see any reason 404 would come unless you put your wildcard at the top
how can I include jda in gradle with kotlin? (need spoonfeed for this one :P)
I have a add and remove role cmd on my bot
However it only adds and removes one role
¯_(ツ)_/¯
Here is da code
if (message.content.startsWith(config.prefix + "addrole")) {
if(!message.member.roles.some(r=>["Admin", "Staff"].includes(r.name)) )
return message.reply(":x: Admin Restriciton :x:");
let role = message.guild.roles.find("name", "Staff");
let member = message.mentions.members.first();
member.addRole(role).catch(console.error);
} else
if (message.content.startsWith(config.prefix + "removerole")) {
if(!message.member.roles.some(r=>["Admin", "Staff"].includes(r.name)) )
return message.reply(":x: Admin Restriciton :x:");
let role = message.guild.roles.find("name", "Staff");
let member = message.mentions.members.first();
member.removeRole(role).catch(console.error);
} else
Do I use somthing like role.name instead of ``"Staff"`?
let role = message.guild.roles.find("name", "Staff"); this line
I know why it only does it for the staff role, I don't know what to replace it woth though
how can I make this so I can mention someone to get their avatar url?
if (message.content.startsWith(prefix + 'avatar')) { message.reply(message.author.avatarURL);
my previous question is fixed, I figured it out
now I'm just wondering which repo to use really
jcenter, or mavencentral
and nvm
oof
What is the d.js code for removing and adding people to and from roles
how can I make this so I can mention someone to get their avatar url?
message.reply(message.author.avatarURL);```
what lang?
Looks like discord.js
discord.js @errant bone
oh sorry can't help :/
probaly wont work
im shit at coding
USE THIS
let member = message.mentions.members.first();
actually mentions.users would be faster
🤔 dont you need the .first()
Does anyone use python on their bot?
@brittle oyster what cha need
https://help-there.is-fi.re/bf0068.png crossposting in case someone knows how to fix
what is wrong with syntax
if v.find("(GROUP)") != -1 or v.find("(GROUP NOTE)") != -1 or v.find("(GMOTD)") != -1 or v.find(" (ALLIANCE)") != -1 or \
(v.find("DoM") != -1 and (v.find(" has warned ") != -1 or v.find(" has promoted ") != -1 or v.find(" has demoted ") != -1 or \
v.find(" has kicked ") != -1 or v.find(" has joined ") != -1 or v.find(" has left ") != -1 or v.find(" invited ")) != -1 :
nvm
@remote estuary what
why?
yes there's the discord developers documentation
if your bot isn't in >2000 servers and isn't a music bot, you probably don't need to know about it
@low rivet is there something particularly special about music bots that requires you to shard earlier 
i just ask because im at about 1k guilds with music
unsure of when to shard
idk i just know that dabbot has a lot more shards then ill ever hit
from what i heard, less servers/shard = better quality and all
i finally got lavalink working on my bot so im hoping that mem usage will go down a bit
about 1k per shard
i might shard around 1250 then
zBlake#0007's
bots:
@crystal jolt 

ugh
need to fix my bots playing status
d.js added something recently where you can initialize your client with presence data included but im not sure how to use it
search it up
@austere meadow pretty sure I've seen from other people's code that you can pass it into your run()
yeah you can its pretty easy but i think its cool the client way
@proven wren
-bots @sacred crypt
@regal wasp
Hey, is this where I would ask for help making a bot...? I'd like to make one, but I haven't a clue how.
we have a blog with some tutorials that may help you
Okay, thank you!
How can I add a bot to auto role a specific role will be selected and given to new people when they arrive
ok sry
oof
hey
how can I do it
what lib are you using
hangi dili kullanıyorsun discord.js probably
okay
you'll want to add the guildMemberAdd event to your code https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-guildMemberAdd
and inside that code/event you will want to
- get the role you want to apply by using
guild.roles.get([role id]) - apply the role to the member joining by using
<guildMember>.addRole(<Role>)
<Role>will be the role you define with step 1, and <guildMember> is the guild member received from the event args
@steel heath
ne dedi
ve
ona bunun hazır halını atabılırmısın diye sorarmısın
Please stop tagging me karışık
@earnest phoenix can you make sure you keep other languages in #memes-and-media please
oh ok
👍
Hi. If there is any discord.py developers, Should I use discord.Client() or discord.ext.commands.Bot()?
@earnest phoenix sorry i can't just spoonfeed you the code
its pretty straightforward though, you just add that guildMemberAdd event to your code, then use <Member>.addRole(<Role>)
@wraith burrow i dont code in python so im sorry if im not much help, but most people i see use discord.Client
yeah but you need to replace <Member> with member in your code, and you can't addRole a member 
you need to put a Role object inside of addRole
you can get that by doing guild.roles.get([id])
replacing id with the role id
what
client.on('guildMemberAdd', member => { member.addRole(member.guild.roles.get(PUT ROLE ID HERE)) }
i made a script that keeps logs from a file
but if someone put a shit character
i am fucked
a simple way i guess would be to use encodeURIComponent()
what does this do
it encodes unicode characters
you can also use encodeURI() which allows you to use characters like / ? : @ & = + $ # whilst encoding others
where do i buy the role id
encoding="utf-8"
i use htis
how can i do it in autorole h!autorol @ROLE NAME
@earnest phoenix you can get a roles id by putting a backslash before a role ping like \@Bot Developer
How can I choose to label
h!autorole @ bot developer and choose the role member add the role
how can I do
that's pretty tricky
you'd need a database to store the value (JSON, something like that you can learn some of that here https://anidiotsguide_old.gitbooks.io/discord-js-bot-guide/content/coding-guides/storing-data-in-a-json-file.html )
then use that value in the event instead of getting a role manually
it's not easy but yeah
don't ever save data in json files
why
@wraith burrow Use discord.ext.commands.Bot()
however if you plan on expanding your bot you can use sqlite or some other database thing
you should avoid saving data in raw files
use a database
they're made to store data and be concurrently modified
without corrupting
@hushed oyster What advantages does it has over discord.Client() or reverse?
it's pretty overkill to use a database for an autorole thing but it depends on the use case
my friend makes a bot called @rotund orbit and although its only on ~120 servers they use JSON and it's not been corrupted
obviously he'll need to switch over soon (cough cough @white blaze) but the point is if you use it correctly and save the file within intervals you can get away with it ¯_(ツ)_/¯
Mornin' sir
when @molten wren used json to save data, it'd get corrupted at least twice a week
g'day
How's your Tuesday so far Blake
i also experienced lots of JSON data corruptions, about the same as you
I used to have issues
and the cost of running a database is fairly low
But what I do now is I write it out twice to different files
redis takes about 1-2MB of memory here
which is negligible compared to the bot's 400+
vic basically stores his settings within a variable then he saves the json file with intervals
It saves to a backup file first
if it's only stored one time at once
So if it crashes while it's writing the backup file you'll just lose the last 30 seconds of changes
isn't that what you do @white blaze
and if the bot crashes mid-write it's corrupted for good
you read once at start up
Yes
i had that issue a lot lmao
And I write to a second file first
Before writing to the main file
And then deleting the second file
If it crashes during the first stage then you'll just lose 30 seconds of data
but regardless of if its getting corrupted or not its not very reliable imo
write to second file -> rename main to eg main-old -> rename second file to the real name
thats why i think you should switch soon vic
that's the safest you can get with raw files
to something better
if you only write on an interval and only in one place
Should I make every function async?
it'll be safe
vic if i did it with postgres im sure you can do it
this was back when i literally didn't know what i was doing with linux
Discord bots don't really need performance
I'll have to rethink it a lot when I move to pg
when you have a bot using 5k threads and 10GB of RAM they do
Well my bot doesn't do that yet 😛
oof
whilst we are here i just wanted to ask; is there any difference in performance between postgres and redis or any other database provider
Whew man
just curious
At that point I wouldn't be using JS
@austere meadow I have definitely had performance hits when I experimented with SQLite
i dont think it should really matter at the end of the day, i was just wondering because i saw it on yorks guide
if you enable aof as well you shouldn't lose any data
also redis can be used as a cache
which it was designed for
and it's a k/v or k/k/v storage
ah okay
oh neat
which can atomically update any key
so you could eg have a counter incremented by 100 different processes at the same time and have always the correct number
thats pretty cool 
(not the best example, since there's already a command to do that, but you could do it with scripts)
right now i use postgres w/ sequelize and im really happy with the performance
i can write/read pretty fast
it uses scripts for CAS and get+delete
thats cool
Do I need to use aiohttp for HTTP requests or will requests be fine?
Python ^^^
?
Requests is blocking, and it will make your bot to pause for the duration of the HTTP request. basically use aiohttp @wraith burrow
hi @uncut slate
ill fix it for 25 smheckles
done
nu shitposting
k 1 sec
.columns .bot-img {box-shadow: none !important;}
ok
omFG
Help
am just a dummo
me
ask ur questions
you forgot a .catch
ur unauthorized
you can either do await promise or promise.then(/* stuff */).catch(/* handle error */)
that is js
i thought await was Java lol
Nope
And await is in many languages
^
how to detect a person up-voting a bot?
-bots Telk
@umbral hearth
@lament sinew
testing pls
unauthorised means u don’t have the perms for something and therefor is throwing that
OH
confused
yes
the lines mean every restart
ok
I am trying to get it to work
to actually respond to my command
wait can i invite it here
no
;-;
how long does that take lol
already submit like 30mins ago
yeah look a bit up in Logs
o
it said that @idle grail submitted @earnest phoenix Assistant
ok
@inner jewel Already added it like 30 mins ago lol
@idle grail then what's the problem
can’t find express
is it in ur package.json
Show package.json
thinking
please help
did you try uninstalling it and retrying?
npm uninstall <package name>
Or npm RM <package name>
npm i
^
try it again, just in case? lol
Hey guys, i have a q, if anyone could answer that would be awesome... I was wondering how to spread discord.js application through all of the threads on a cpu (because node is single) is there a way to spawn more processes
or even dedicate certain processes ? or split up your app using the same key?
shards 
you'll have to shard your bot
or do it the hard way and have a process connecting to the gateway and sending payloads for other processes to handle
what is bot sharding ?
anyone familiar with gridfs stream
nope
const config = require("../config.js");
exports.run = (client, message, args) => {
let guild = message.member.guild;
let Role = guild.roles.find('name', 'Member');
if(message.member.roles.has(config.memberRole)) {
message.delete();
message.author.send('\`You already have the \`member\` role!\`');
client.channels.get(config.channelbotlog).send(`Command: \`!member\` User allredy have the role: \`@member\` User: \`${message.author.username}\``);
}
else{
message.delete();
message.member.addRole(Role);
message.author.send(`You just got the role: \`member\`, you are now allowed to speak in the text channels`);
client.channels.get(config.channelbotlog).send(`Command: \`!member\` User just got a role: \`@member\` User: \`${message.author.username}\``);
}
}
any one knows why it just stopped working?
i wouldent do the else line only the first
but when i restarted it it worked
now !clear isnt working
could this be a storage problem?
Is there a way to check if I can dm user with Eris?
I know that, but without actually sending the message
For people who use Eris but not the built in command client how did you guys go about making your own
normally it'd be a map of command name -> command
Whats wrong with this 'purge10': (msg) => { if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES')); msg.delete(10) msg.channel.send(`Success! Deleted 10 messages!`); else msg.channel.send(`You require the permission **MANAGE MESSAGES** to use this command!`); },
if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES'));
there's a semicolon there
what you want: js if(x) { y() z() } else { w() }
what you have: js if(x) {} y() z() else w()
if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES'))
msg.delete(10)
msg.channel.send(`Success! Deleted 10 messages!`);
} else {
msg.channel.send(`You require the permission **MANAGE MESSAGES** to use this command!`);
},```?
if (msg.guild.member(msg.author).hasPermission('MANAGE_MESSAGES')) {
msg.delete(10)
msg.channel.send(`Success! Deleted 10 messages!`);
} else {
msg.channel.send(`You require the permission **MANAGE MESSAGES** to use this command!`);
},```
How tf do you get bot dev if u don't know how to use if else
lol
@lethal otter sends me sum nsfw photo, i think
Yeah
Lol
I get messages from @lethal otter...
@inner jewel
WTF
await text.GetMessagesAsync(count).Flatten();
CS1061 'IAsyncEnumerable<IMessage>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncEnumerable<IMessage>' could be found (are you missing a using directive or an assembly reference?)
shit
was it on the vps
regenerate token on dev page
IPad's VPS*
it spams "this bot has been hacked by apoda#5338"
lmao
spams a long list in every server
@daring dust reset your token then
also what the fuck is a ipad vps
ok
reset token
@topaz fjord no IPad is the heck that got banned
even the username got changed
i cant change it back because it shows the original name
please someone help
r e s e t t h e t o k e n
i did
ok so it should be fine now
it says the bot name on the top but the "username" above the token is the one that was changed by the hacker
uh wut
Oh jeez it's the iPhone character
oh boy
You'll need to send a PATCH request to /users/@me to change that name
well you can do that via a library
how do i do that
But that's how the libraries do it
you can use postman
;-; what is that
google it
send a patch request to the url to change the bot name
which url are you referring to
/users/@me
and how do i do a patch request
@pale light no u
please im bad at this
google how to use postman
I actually don't use postman so I can't help you much
¯_(ツ)_/¯
I use an electron app called Insomnia for all that
i do but its hard to explain without the person being next to me
Which personally I love Insomnia
you have to put in the discord api base url
https://discordapp.com/api/v7/users/@me
and set a header
or just /api/users/@me
with the bot token
That works too
im currently in the progress of making a wrapper for the D-Api 
do i put the bot token after the @me?
no
Do you guys know how to register a .bot domain name with a discord bot ?
What are the types in that dropdown
headers?
Well
yes
He's on Authorization tab
for key you put Authorization
Just curious if that dropdown has anything useful
and for Value you put Bot <token>
this one?
yus
oh hey that insomnia thing looks cool 
oh you're on the returned one
oh my gerd postman has a dark theme
there's no point anymore
@daring dust did you already delet
ok
uh
I overrided it
but it works
i dont see the "body" dropdown
oh wait, i was just blind but mine looks like this
{
"code": 50035,
"errors": {
"_errors": [
{
"code": "CONTENT_TYPE_INVALID",
"message": "Expected \"Content-Type\" header to be one of set(['application/json'])."
}
]
},
"message": "Invalid Form Body"
}

either the token is invalid or you didn't set auth header
where do i put the token and where and what is the auth header. sry im stupid
then go to the Headers tab
ok
add 2 headers https://help-there.is-fi.re/bb1f5e.png
how do i add them
(replace <your token> with your bot token>
it doesn't let me do that
how do i get to the request
it should be on the top??
usually it's split
one part is the request
one part is the response
i got it
What do you put in the Body since I'm following along 
{
"code": 50035,
"errors": {
"_errors": [
{
"code": "CONTENT_TYPE_INVALID",
"message": "Expected \"Content-Type\" header to be one of set(['application/json'])."
}
]
},
"message": "Invalid Form Body"
}
oh ic
set the content-type header to application/json
yeah I did
hm
i did it
oh wait I figured that out
select 'raw' option then select json from this https://help-there.is-fi.re/c24b3d.png
body tab
this part?
I'm stealing that token 
what do i put for the username and token
the body should be
{
"username": "what you want"
}
so .json boune
no
?
{
"username": ".json bourne"
}
if you want that to be the username
yep
send it now?
try it, ye
kek it worked
lul

dat spam
yep
you should be mostly good to go now
ipad vps 
so now, how do i fix the damage that Apoda#5338 did?
well I mean
you secure your token
and how do i do dat
oh god
don't push it to github
running on a trusted machine
and yes
yup basically that
run on a machine you actually trust
ok
and YeS
disabling root login
so ill just host it off of heroku?
natan basically covering everything
i have no idea how to do dat
@daring dust if that's where you want to go/can host
i've never hosted on heroku myself though
vps
oh which vps?
a paid one
friend's vps
What server do you run on the VPS?
its mostly linux-based
Lmao
proxmox with lxc of debian
testing new features on beta bot but using your prod one by accident
and not realizing for like 10m
same

test in production best
lel
and how would you do that by accident
prefixes
ignorance ;-;
muscle memory
I think it's physically impossible for me to do
kek
Then again
My bot is compiled
and the token is in the environment
I would know if it's a test bot or not and can't run on a production bot
My test bot runs on my own machine
41 commits in 6 hours 
@abstract mango got it back up again and reconfigured everything. it should be fine now as i secured pretty much all access to any source
cool
I'm having trouble with the webhooks, so I put my webhook link in the api options of the edit bot page.
And i had a friend upvote the bot for testing, and there wasn't a post from the webhook.
Am I missing anything?
discord webhooks won't work there
Oh they wont?
webhooks aren't specific to discord
they're just a way of having a website send you data in a url
I feel like it's time you specify that this isn't a Discord webhook on the page
^
Is it possible to add elements to a json object
Example:
let a = {}
Adding "derp" to a:
let a = {
"derp": 123
}
I can help you for Node.JS
I know
@brittle oyster so
all you have to do is
bot.add_reaction(messageobject, emojistring)
or client.add_reaction(messageobject, emojistring)
whichever you use
for example
yes
but in quotes
then
here's an example
yes
if you were doing this in a command
pass context
yes
but
make sure to pass context
do you use the commands extension?
well
- You should be using it - it's way easier
- Can you show me one of your commands?
ok
ok
can you show me the code
ok
so here's how you would add a reaction
client.add_reaction(message, "😂")
await client.send_message(channel, "Test")
print("t~test was used by " + str(author.name))```
that's not what I said
ok try that
i'm not good without the commands extension
but it should work
hold on a sec
here's an example bot with the extension
take a look at it
the entire thing
first off
btw
with the extension
a help command is built in
This is a JS question, not really JS even.
What website do you use for your snekfetch images.
So when you use snekfetch to get an image, what's the best website for custom messages?
@late ridge can you tell me @shell shoal Roverseems ofcline and content deleted
Rocer is. Content deleted
any1 here do anything with the tracker network APIs?
they give zero documentation
angery
@shy verge miss me wit that shit

i guarantee you someone made a framework/lib for it
Using Node.js version 8.4 or higher, lost track
I am trying to search through a database with the following code
let rows = await sql.all(`SELECT * FROM notes WHERE memberID = ${user} AND GuildID = ${message.guild.id}`)
let username = [];
for (let i=0; i < rows.length; i++) {
username.push(`${rows[i].Username}`)
}
const spaceuser = (username);
const longuser = spaceuser.reduce((long, str) => Math.max(long, str.length), 0)
for (let i = 0; i < username.length; i++) {
finmes += `${username[i]}${' '.repeat(longuser - username[i].length)}|` + '\n'
}
message.channel.send(finmes)```
And it is not doing wha it should do, which is place a space after a username and it does what it does in the image. Any ideas?
I found a way to add a cooldown to my bot, but im not sure i like it.
here is it:
const talkedRecently = new Set();
if (talkedRecently.has(msg.author.id)) {
msg.channel.send("Wait 1 minute before getting typing this again. - " + msg.author);
} else {
//command
talkedRecently.add(msg.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(msg.author.id);
}, 60000);
}
I believ you have to add it to every command.
can i just put it around muiltiple commands?
You want a cooldown for every command? Place the entire code after you run the command in the message handler
@olive ridge
Is it wierd to have it on every command?
I guess certain commands'
would have a higer tolerance for use
Like purge or ban
you could just put it in the message listener
you don't need to put it in every command
and as for custom "tolerance"
you would just need to export that as a command parameter and handle it in the message listener
if you have an actual command handler tho
hmm
I have the stupidest command
that can only add one single role
"staff"
if (message.content.startsWith(config.prefix + "addrole")) {
if(!message.member.roles.some(r=>["Admin", "Staff"].includes(r.name)) )
return message.reply(":x: Admin Restriciton :x:");
let role = message.guild.roles.find("name", "Staff");
let member = message.mentions.members.first();
member.addRole(role).catch(console.error);
} else
what can i relace with "staff"?
Is there a role.name?
Please dm if ya have an answer, i gonna leave soon, and this channel gets drowned in messages.
what are you asking
can i just use let role = message.guild.roles.find("name", role.name);
you'd need to define role previously somewhere
hmm
and it doesn't really make sense
;-;
HEEELLLLPPPP MEEEEE
The id's are perfect
WHATS WRONG
WHY DOESN'T client.fetchUser(id) NOT WORK
it does
is that d.js
they are perfect
you're treating member like it's a Member object
yes
when its actually a User object
isn't it client.users.get(ID)
Nope
<User>.user isn't a thing
or guild.members.get(ID)
Oh
remove the .user and it'll work
@austere meadow I will try that
also ken it depends on what version of d.js you're using
thats only on master
actually i think it recently got added to 11.3 but idk
@austere meadow Still didn't work... same error
what version u using
if you do npm ls discord.js what do you get
Ok i already updated it today but i will see what it does
updated today? you're probably on 11.3.1 then
Yup
fetchUser is still a thing in 11.3 
hmm
on line 207, replace member.user.id with member.id
client.fetchUser(id).then((user)=>{
})
member is a User object




