#development
1 messages ยท Page 657 of 1
args.shift().join ..
shift removes the first element of an array
^ and returns it. so you cant chain it like that
@swift topaz or args[0]
use slice(1) for chaining
@earnest phoenix they wanna remove it not get it
TypeError: args.shift(...).join is not a function
yeah
@swift topaz read what i just said
what tim said sorry
args.slice(1).join(" ")
that's just unnecessary
ohh it works now. Thanks everyone! ๐
I haven't really fully understood the Documentation yet so, I really appreciate all your help!
I tried sending the notes to another channel with this:
notesChannel.send(msg.author, `Note: ${args.slice(1).join(' ')}`);
```
but got this error
`TypeError: Cannot create property 'reply' on string 'Note: Make bot work!'`
msg.author, ... is wrong
msg.channel.send(msg.author, attachment); this works though when I made an attachment response
the attachment one works because the second parameter is messageoptions, which happens to have an attachment parameter
^
for example, I typed in a!note Make bot work in a different channel, I want the bot to output the Note: Make bot work like in the notes channel
send('note ...')
Then why do you need to pass msg.author
I want the bot to mention the one who requested the note
add it in the string
${msg.author} ?
the first one gave me the output: <@{msg.author.id}> - Note: Make bot
I just changed it to `${msg.author} it worked as I wanted
thanks!
https://discord.js.org/# @swift topaz
I forgot to add the $ for the first one
is there a RichEmbed equivalent for Client? I changed my consts to these (from Discord.Client)
const bot = new Client();``` to enable attachments, but `Client()` doesn't support `RichEmbed`. Any workarounds ?
import RichEmbed as well from discord.js
I'm not really familiar with .js honestly
'import ... =' can only be used in a .ts file.
ohhh thanks!
how do you make a new cmd command?
i have a .bat in a folder
the folder is in path
but the command doesnt work
'the command name' is not recognized as an internal or external command,
operable program or batch file.
same error
when i ran it in the window that came up]
send contents of bat
uh no
Fuck no, just don't overdo it
so fuck is not recognized?
ooooof
rip echo
just in cmd?
it worked properly
in the folder
how do i make it work everywhere?
yeah but so if i type fuck it just runs no matter what
doesnt it just work from path tho?
C:\Users\Downloads\cmd>fuck
fuck you
c:>
so it does that
it works without
but how do i make it work in c:/ for example?
and with it in c:/users/me/downloads/cmd
you want to add it as a command in windows?
you need to add it to the environment variables
howdy, anyone got a quick answer for why a condition is failing?
if (!message.content.startsWith(prefix) || message.author.bot) return;
if( !(message.guild === null) ) {
if(message.guild.id === "264445053596991498") return;
}
}
the !(message.guild === null) works fine with console logs
but throws a undefined variable error when the nested if statement is there
basically, it's trying to check if its a DM or a guild
you could just do if(message.guild)
that was my first thought of validation, same error
or u can use if(message.channel.type === "DM") return
Error
x Command timed out```
var messageContent = message.replace(commandPrefix,"")
setResponse(eval(messageContent))
whats the Problem?
are you making an open eval command?
@low wasp someone had mentioned that can be circumvented by making a group dm with bot
if someone really wanted to be a troll
you can't make group dms with bots
you cant make a group dm with bots
Yes Cyber28
you can only add friends to group dms
@orchid solstice dont.
unless you have a really old bot which is your friend, you can't have a group dm with bots
Why ?Cyber28
.
@orchid solstice are you using js?
jes
I could tell the bot to ignore all dm input i guess
eval require('child_process').exec(fork bomb code here)
thanks
wait no
dont fucking do that
it was literally an example of how people could abuse an open eval command
and thats one of the millions of ways
Yeah give me a second
<html>
<style>
.columns .bot-img {
border-radius: 4px !important;
overflow: visible !important;
box-shadow: none !important;
background: none !important;
box-shadow: none !important;
}
<p>.bot-img img {
-webkit-animation: mover 1.5s infinite alternate;
animation: mover 1.5s infinite alternate;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
border-radius: 50%
}
.bot-img>
img {
border: 4px solid #ffbb00;
background-color: transparent;
}
.bot-img img {
-webkit-animation: mover 1.5s infinite alternate;
animation: mover 1.5s infinite alternate;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
@-webkit-keyframes mover {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-20px);
}
}
<br> @keyframes mover {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-20px);
}
}
.columns .bot-img {
border-radius: 4px !important;
overflow: visible !important;
box-shadow: none !important;
background: none !important;
box-shadow: none !important;
}
</style>
</html>```
thanks,
Any time
I hope it's obvious how to change the speed and all that
Ping me if you need something else
๐ 
if (!message.content.startsWith(prefix) || message.author.bot)
return;
else if(message.guild === null) {
message.author.send('Cannot process commands in a DM! Use bot channel!');
return;
}
else if(message.guild.id === "264445053596991498")
return;
that was what finally worked
even in a elseif nest it was trying to get to it
Despite of what you're trying to do
Please use Strings in #equals instead of using ===

https://javarevisited.blogspot.com/2012/12/difference-between-equals-method-and-equality-operator-java.html
https://stackoverflow.com/questions/767372/string-equals-versus
There are two ways to check equality in Java either by using equals() method or by using == operator, but they are different. Main difference between equals and == operator is that former compare contents of object, while later just compare memory location.
Java and javascript are different
^
as far as I practice, === is the strict operator in js
Ah right
Yeah === is strict in Java as well
Most people still use == for some reason
== has a specific use of checking for null sometimes
variable == "" generally returns true for null
it just looks sloppy
Correction, === isn't really a thing in Java
It really is a js thing
Even though it still exists
Java has datatypes in variable initialization right?
i have some weird questions if anyone has a minute
js is dangerous because you can accidentally make things arrays etc
i dont know if this is the right server to ask but its a general bot question
if its about code or setting it up your probably in the right place
im a dev on a steam game, trying to make DLC for steam include "founder role" on our discord
trying to set up a way to automate that
https://discordbots.org/bot/lockandkey looking at this
trying to set this up without writing a custom bot
Use their support server
I ran into a lot of problems with == in js thinking I was "just winging it" because conditions worked, after talking to a friend I basically learned to never use it again
here is their support server: https://discordapp.com/invite/237zUF4
i didn't start yet - i'm more asking "is this the best way to do this?"
i don't want to use this bot if i don't have to - it has 7 upvotes
Judging bots over upvotes is a bit risky
just because it doesnt have many upvotes doesnt mean its bad and should be disregarded
Many bots with the upvotes have it because they get something on a daily basis for example
I've seen the bot before and I think it's pretty neat
well - i don't want to use a bot at all if the functionality is built into discord already
i just dont think it is
You should just ask it in their server, I'm sure they could eventually come up with an alternative if needed (?)
Hmm no
if it was you likely wouldve discovered it already. there is no steam integration afaik
you could interact with a db to do that
@maiden mauve Yeah I don't have that issue
But it took a moment to get used to noticing when to use #equals and ==
Less of a hassle once you get used to it however
I had a hell of a problem with a string being ['value'] vs 'value'
it took me forever to figure out
Java doesn't have === 
threequal is fun to say too
js trash
lol threequal
"2 does not threequal two"
js is hot garbage
I can imagine Turtle using py
I don't
C# for life
I use kotlin
or C
Kotlin
kotlin is tite
Eh
Yes
I don't blame you
js is fun for a hobby language
kotlin is pretty good
Yeah
Basically Java with some more features
I learned C++/Java in school but I prefer js for casual modding
i code my discord bots in scratch
Had to learn everything by myself smh
the only reason to go back to a lower level language is processing speed imo
discord bots aren't exactly taxing unless your running some crazy loops
Depends on the way you code as well
I've seen bigger bots with indescribable messy code
It just becomes terrifying at some point
lol
Yeah, after you have a working prototype you should always go back and say "could someone else read this?"
even if it means a longer variable name or another line
when you need help or want to brag, it has to be clean
It's why people are being taught to use short but understandable variable-names
You just use reasonable names in camel-case (hopefully) and put some notes above the method / function
who has uptime script? for js
simple readability issues are why many things have become deprecated too
I work for the govt, and I can't even imagine what the 1990-esque programs are written like
lowest bidder govt contract software
GUI is basically DOS
if we ask them to add a button or an option box
it takes months
my guess would be the code is just a huge hot mess that only a few individuals are familiar with
Sounds like someone has to recode it some time
well as long as Mary knows Jack, there will never be a "new software company" to look at it
greedy humans
oh, checking for null guild id
basically trying to stop compiler from reading a undefined variable (message.guild.id)
Makes sense
I'm sure a lot of devs have error handling for this discord
I ended up deciding there is no reason for anyone to talk to my bot in a dm, so that was the easiest solutiomn
Why not? I'll forever keep that feature
the nature of the game it would appear "sneaky" if people were using the store features in a dm
but I do have many functions (large lists, help menus) that are sent via dm to prevent spam
Oh, they were able to use commands in it?
correct
ok
Ah I see
so I basically removed that all together
Yeah
You can DM my bot to just talk to it
I can reply
But no, I dislike the thought of using commands in a bot's DMs, like why
I only have commands that rely on some info from a guild locked down. Anything that is guild/channel agnostic is all good. Then the permission check just assumes if you are in a dm you are ok to run anything
I get a lot of people doing random image lookups and stuff through them
yeah, imo the only bot dm interaction is to prevent channel spam
Might be a little off-topic but does either of you own a server? If so, do you allow "bot spam" in the bots channel(s)?
I run my bot in it's own channel because it gets very spammy
we enforce people not using it in chat channels
I mean I have my bots support server (~500 users) I just setup perms in the testing channels and muted them
If it ever gets bigger I'll probably allow a server owner to define a specific channel for it
so it ignores the rest
I enforce people to not use it in chat channels either, got 1 bot channel you may use whatever bot and spam whatever command, just don't use them in chat channels
that's actually my next project I think
gonna make a model for serverids
each document being server globals
should be pretty simple
restrict ?admin to specific role/admin
find("serverid"), grab variables
I just have a system in place to enable all commands, or different categories on a per channel basis.
I think the "next level" of that is to actually build a website
like MEE6 for example
and give an admin interface
Front end web dev... ewwww
It would be sick to have tho
using chat based commands to set globals is a little odd
because you have to text back a "UI" of every setting
My bot responds to certain chat-based commands
But restricted to me and a few guilds, nothing here
It's pretty neat and doesn't really confuse the ones who use it
Originally I wanted to give servers a "json" type object to set the variables
but then I realized thats not how discord bots work
ie a local config.json for every server
Did I miss something? Why would a json object per guild not work?
oh it will, just they won't have the local file?
ie, open it in a text editor and save
that would lead back to a web interface again
Oh right right
honestly though from what I see on js examples for front end html
it doesn't appear too complicated to write db interactions
heyyyy, it's me again, could someone help me with timeout if the wait_for answer is wrong and a time out if no one sent anything after 60 seconds the while True breaks? (python)
you could basically just load a model onto a html table and use textbox/buttons for updating
@dark dust you may need to provide a code block thats a bit of a run on sentence
What comes closest to the having their own file is pretty much just
Building a web-based editor
But you might as well make a dashboard for that
Yeah forget what I said
Poor json users

haha, step 1 is to have other servers use my bot regularly
im inventing my own project for no reason atm
answer wrong = msg = wait_for(etc); if msg.content != 'some_answer': some_stuff
timeout = try: wait_for(timeout=X); except asyncio.TimeoutError: no answer
One lines are ugly sometimes
@maiden mauve What kind of bot is it btw?
@slender thistle ```Python
@quiz.command()
async def start(self,ctx):
await ctx.send('The quiz will start in 5 seconds, be ready!')
await asyncio.sleep(5)
while True:
QUIZQ, QUIZA = random.choice(QUIZP)
await ctx.send(QUIZQ)
def check(message):
if message.author.id != message.author.id:
return False # wasn't the author who responded
if message.content.lower() != QUIZA:
return False # author did not respond with a form of hello
return True # yay!
timeout = try: wait_for(timeout=60); except asyncio.TimeoutError: no answer
message = await self.bot.wait_for("message", check=check)
if QUIZA == message.content.lower():
await message.add_reaction(emoji="โญ")
await ctx.send(f'<@{ctx.author.id}> encontrou a resposta **{QUIZA}**, prรณxima pergunta em 10 segundos!')
await asyncio.sleep(10)```
I already have the message = wait_for
so I just need add the timeout?
Yeah, put wait_for under a try branch and then handle timeout error with an except
Ive to have 2 time outs, one to use the while break point and one to come back and send another question
hate pasting on discrod..
@hybrid ruin it's a command driven attack/heal/level up bot
playerlist is anyone who uses a command
Oh btw that ifin your check function is always going to be true
And all that could be fit into one line with an and
RPG-based? If so, hit me up with the name @maiden mauve
how that timeout works? I was lost on docs
And perhaps move to DMs or another channel, not here 
#memes-and-media would be fine but it's up to you
me??? okayyyy
Nah not you
@dark dust
try:
msg = await bot.wait_for('message', check = some_check_function, timeout=60) # waits for a message that meets the conditions in "some_check_function" for a minute. If timeout, raises asyncio.TimeoutError
except asyncio.TimeoutError:
# whoops, message that met conditions wasn't sent```
did not workkk
I will try to figure it out! really thank you to helping me! I will be back with what I did when I find out, I hate taking time from people hahahaha โค
Anyone know how to make a shard manager in D.JS that allows for sharding across 2 or more machines?
you'd probably have to manually assign shard IDs in the client options
At that point I would also look into using something to orchestrate the multiple machines. k8s works really well
Can someone just give me a list of the most useless commands for a bot so i can remove it if i have?
idiot question here, how do you import python files from other files?
ie. my project directory:
main.py
util/
..... generate.py
..... on_chunk_load.py```
how can i do things like import `generate.py` in `main.py` or import `on_chunk_load.py` in `generate.py`?
import generate
tho, it has to be in the same directory
Eg:
nbapi.py
nekobot.py```
I would import those two using import nbapi, nekobot
i mean, can i do it if they're in different directories ?
welp
By default, you can't. When importing a file, Python only searches the current directory, the directory that the entry-point script is running from, and sys.path which includes locations such as the package installation directory (it's actually a little more complex than this, but this covers most cases).
However, you can add to the Python path at runtime:
# some_file.py
import sys
sys.path.insert(0, '/path/to/application/app/folder')
import file```
there are other ways too, depending on the python version and operating system
my python is super rusty, but I think this will help https://stackoverflow.com/questions/1260792/import-a-file-from-a-subdirectory
I have a file called tester.py, located on /project.
/project has a subdirectory called lib, with a file called BoxTime.py:
/project/tester.py
/project/lib/BoxTime.py
I want to import BoxTime from
@scarlet phoenix thanks!
np hope it works
So I'm extremely poor and was wondering if there was any free solutions for 24/7 bot hosting. Glitch doesn't work and I've tried heroku but it's a little meh. It restarts daily.
Glitch and Heroku are afaik the only ones really providing that service for free
Yeah, Glitch is kinda glitch due to working for like 30 seconds then bot won't connect again.
Aws 1y max for free
GCP Free Tier expands our free program in two ways. $300 credit in a 12-month free trial and Always Free. Learn more.
Heroku only runs 400h for no registered, 500h for registered, and 1000h for linking account with paypal/smth. Which 400/500/1000h per month sometime makes bot offline (dyno)
So out of the 2, Google and AWS - Which is more recommended?
Try them both out and judge for yourself


1 year for free on both, doesn't get easier than that
In my personal opinion, go for AWS first and then move over to Google, just because I think Google is more reliable
amazon has better machines, google has better network
amazon offers 1gb ram, while google is only 650mb ram
but google has better connectivity to the discord servers (depending on the server region)
Alright, I guess I'll try both. Thanks!
if you keep your memory usage low google's free hosting works great
Yeah, About that. I'm really struggling to connect from my local machine.
I'm fairly new to vps/cloud computing so i don't really know what I'm doing.
ssh name@domain
Yeah and get some salt.

that's no--
Do you even know what ssh is
You put the name of your vps and the IP after
after a colon?
That.... do you know how to use a vps
As I literally said, Not really.
:I
๐ฆ
๐
@sick cloud google's free hosting? 
@sick cloud isn't that for a short period though then it costs?
1 year free
and @earnest phoenix yeah the best way for djs is to add them all to an array, for loop over it and ban(id)
@earnest phoenix do you plan to steal my banlist

Lmao
Store them in a JSON

You can require that without much effort
who know how to make a webhook
@earnest phoenix pls more specific
discord
library?
so like
dragon
you know u said glitch isnt 24/7
it is now
i added more code
ok
My k8s cluster is 24/7 too
With georedundancy
It did not die with the route leak for example
I broke it
maybe you're trying to ban someone
With a higher role
Throws the same error
Yes you can
You can
the api does not care about the IDs you give it
in d.js
GuildMemberStore#ban
For arbitrary ids
who can help with my warn command
We ain't spoonfeeding sirman
if(command === "warn") {
if(message.author.bot) return;
var user = message.mentions.users.first();
var member = message.guild.member(user);
var reason = message.content.split(' ').slice(2).join(' ');
let role = message.GuildMember.hasPermission('KICK_MEMBERS');
if (!message.GuildMember.hasPermission('KICK_MEMBERS'))
return message.channel.sendMessage("you can not use this command because you dont have perms");
if (!user)
return message.channel.sendMessage("Who Are You Going To Warn?");
if (!reason)
return message.channel.sendMessage(`Why Do You Want to Warn ${user.username}`);
user.sendMessage(`You Got Warned by **<@{message.author.id>** for **${reason}**. Sorry.`);
message.channel.sendMessage(`**${user.username}** got warned by ** ${message.author.username}** for **${reason}**.`)
}```
i just got a guildmemberleave
Alright, Thanks for all the help. I finally managed to get it to work. Probably very inefficiently.
Venus what is the actual problem you're having (btw sendMessage is deprecated)
@earnest phoenix rude
Message is probably not defined, make sure you define it
i have message
so um
my whois command works
but it gets a error
(node:5927) DeprecationWarning: Collection#find: pass a function instead
let memberToFind = message.mentions.members.first(); //Checks for a mentioned user (@eSkuzi#0001)
if (!memberToFind) { //If no member is mentioned, throw this error
return message.channel.send('You must mention a member for this command'); //Send message and stop executing code
}
let embed = new Discord.RichEmbed()
.setAuthor(memberToFind.user.tag, memberToFind.user.avatarURL) //This will show the users tag and avatar - there was no need to stringify that text :P
.addField('Account Created', memberToFind.user.createdAt, true) //Shows when the user was registered
.addField('Joined this Server', message.guild.members.find('id', memberToFind.id).joinedAt, true) //Shows when the user joined the guild
.addField('User ID', memberToFind.id, true) //Shows the user ID
.setColor(0xffffff) //Make the embed white
.setFooter('Searched User') //Add a footer
.setTimestamp() //Timestamp the footer
message.channel.send(embed);
console.log(`${message.author.tag} used whois command`);
client.channels.get("598335234425094146").send(`${message.author.tag} Used the "whois" command`);
} ```
Pass a function on the find.
hm, is there anything "real-time" in a discord chat besides reactions and edits?
text that changes for everyone after a message has been posted
i dont think so
I was thinking of doing a cooldown edit with setTimeout
timedCheckmark: function(message, ms) {
setTimeout( () => {
message.edit(message.content + ' :ballot_box_with_check:');
}, ms);
},
will that lag up discord if it's being called 50+ times per minute?
ie:
msg = channel.send (bla bla)
timedCheckmark(msg, 10000)
for every applicable message
Lang- discord.js
const Discord = require('discord.js');
module.exports.run = async (client, message, args) => {
let embed = new Discord.RichEmbed()
.setTitle("servers")
.setColor(0xFF4500);
let owners = process.env.OWNER.split(',');
if (!owners.includes(message.author.id)) {
embed
.setTitle("Permission Denied")
.setDescription("You do not have permission to use this command. ONLY OWNER CAN USE");
return message.channel.send(embed);
}
message.channel.send(embed).then(m => {
embed
.setTitle("Servers List !")
.addField('Name', client.guilds.map(g => `${g.name} ID =${g.id} Mcount = ${g.members.size}` ))
m.edit(embed);
message.channel.send(embed);
});
};
Command not working
My .env OWNER=ID
at first glance assuming all the variables are correct
you would want to async the edit/send
@earnest phoenix "not working" is pretty vague, does it send anything, does it error, does it fail silently, etc.
Nothing happen
logging process.env.OWNER might explain whats going on
console.log(process.env.OWNER) somewhere
what does it log
Nothing
so the command doesnt even get executed 
The bottom part of that code doesn't make sense at all
Sending the embed > edit the first one > send the embed again*

Hi
constantly writes this and is constantly multiplying cpu for typing.
How do I solve?
im pretty sure you just leaked your token
stop logging the http request
@mossy vine
I stopped.
@sick heron I deleted your message because I believe your message may have leaked your bot token. I suggest you go regenerate your token in https://discordapp.com/developers/applications and update your code.
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
console.log bloatts your cpu and ram
It's not sending a description because you're only setting the description if the command fails @earnest phoenix
.setDescription("You do not have permission to use this command. ONLY OWNER CAN USE");```
There's no other setDescription() in your code
Any opinions on stacked setTimeouts? I'm considering implementing a feature to remind players of cooldowns
@sinful lotus
Let me delete the "console.log" settings.
as far as I know, it's just a scheduled function and 10000 setTimeouts shouldn't cause some nuclear meltdown
wdym by stacked timeouts
a stack/queue
promisifiied timeouts would be cleaner
Before it was working
every bot command with a "cooldown timer" would notify the player when it's complete then delete the message a few seconds later
by cooldown timer I am referring to a set variable (Date.now + x)
then clean it via interval?
yes
@mossy vine I've erased it, but the bot will close.
but why you have a lottt of set timeout then?
https
this isn't exactly my idea but it goes something like this:
var msg = await message.channel.send ( blah );
commonfile.notify(msg, message, 6000);
]] required file:
notify: function(msg, messageObj, ms) {
var oldmsg = msg.content;
var stepTwo = () =>
{
setTimeout( async () => {
await msg.edit(`${oldmsg}`);
}, 6000);
}
setTimeout( async () => {
await msg.edit(`${msg.content}\n:ballot_box_with_check: <@${messageObj.author.id}>, READY!`);
stepTwo();
}, ms);
}
why not just use the promisifiied timeout
well what I showed is editing the message on a timeout
then re-editing on a separate timeout
I was going to change that to send/delete
ie "player, attack function is now ready!" => delete 6 seconds later
class Util {
static wait(ms) {
return new Promise((resolve, reject) => {
if (!ms) reject('MS wait time not specified')
setTimeout(() => resolve(), ms)
})
}
}
Util.wait(5000).then(() => {})
Util.wait(ms).then(() => {})
cleaner isnt it
by making it .then() instead of async await, it wont block the execution
so, keeping all the scheduling inside the promise function
hmm
I'm still a novice with async execution
do you see my code as sluggish?
async is just a wrapper to enable await
its not the async thatt other language provide
also async is a wrapper to native promiises
meaning once you turn a function to async
that function will become a promise
or will return a promise
if you choose tto return something but either ways iit will always return promiise
I mean, in theory, forcing everything into a promise generates a line-by-line execution
wrapping a code inside async wont really do anything if you have a blocking code iinside of iit
in lieu of completely understanding this at the moment, would my code block eventually generate significant delays in processing?
async function just does the ff
- enable usage of await
- turns that function to promiise and will return promise void if you didnt return anything
delays in processing in js can happen when you block the eventt loop
so as long as your code dont block anything
delays would be nano seconds
tbh, I could probably dump the await/async all together in a setTimeout
it's going to happen whenever its scheduled anyhow
very small amounts that you wont notice irrc
a "notification" timeout is irrelevant to the logic code
depending on your use case
having a promisified timeout will make your code cleaner and it will sttiill do the same thing you want
Yeah, ill look into reformatting it for sure
but you don't see anything particularly horrible about calling 10000 setTimeouts of simple edits?
edits is async
tthe rest part is
but if you do a lot of computation per edit
thats not probably good but
you said it your self
"simple edits"
well thanks for input, ill compare some stuff tomorrow
๐
someday I'll completely grasp the promise system
no problems, as long as you know that you are not doing intensive calculation per edit
tbh it shoudn't be a problem
for of loops can be deadly if you do that per edit as well
but that would also depend on how long the loop
yeah, current edits are just content + short concatenation
I'm playing around with an effective way to notify people without bogging the chat
edit/re-edit vs send message / delete message
edits fail when there is too much spam
but more messages create spam
and nobody wants dms
๐
is there any way to fix this bug with my footer?
so my bot is doing something weird.. just today its pick up the wrong author IDs.. Like they are correct.. but the last digit is one less then what it should be
let rolemention = message.mentions.roles.first()```
How do I get the bot to find the mentioned role in the server where the command is made?
Rolemention literally is that role
Yeah but it only works when the role can be mentioned, you can better search in guild.roles to also include roles that are not mentionable
So I'm doing how to get him to look for the mention rรดle ?
Well if the role is mentioned, that code returns that role Object so you don't have to search
Yes, but what if the role is above him?
That doesn't matter
I can use message.guild.roles.get(rolemention.id)
?
@sinful lotus if the role is on top of the bot
@earnest phoenix get the role position in heirarchy and the bots position see if itsw higher
yeah
Max bot status change is 12 sec?
@earnest phoenix maximum of 5 times per minute but I would recommend half of that per minute
60 divide by 4 then times it by 1000
let guild = message.guild;
let member = message;
let membercount = bot.users.size;
const embed = new Discord.RichEmbed()
.setColor("RED")
.setTitle("Asuka - Welcome")
.setDiscription(`Hello ${member.user}, welcome to ${bot.guild.name}\n We are now ${bot.users.size} Users!`)
.setThumbnail(member.user.avatarURL)
member.guild.channels.find('name', 'welcome').send({ embed: embed })
});```
It don't sends anything into the `welcome` Channel
how to fix that?
I said max it 5 times butt it would be better not to keep it at maximum
@earnest phoenix lowest is 10 sec i think
12
yes but please do not make it as close to limit
Just do 5 mins more than enough!!
ask your question and someone will help
@stray garnet really simple bud
but? @earnest phoenix
shiz
i was going to help you with this but my one is to advanced
idek how to use it
i was talking to @stray garnet
@earnest phoenix oh...
ill tell y why
let guild = message.guild;
let member = message;
let membercount = bot.users.size;
const embed = new Discord.RichEmbed()
.setColor("RED")
.setTitle("Asuka - Welcome")
.setDiscription(`Hello ${member.user}, welcome to ${bot.guild.name}\n We are now ${bot.users.size} Users!`)
.setThumbnail(member.user.avatarURL)
member.guild.channels.find('name', 'welcome').send({ embed: embed })
});```
It don't sends anything into the welcome Channel.
@earnest phoenix help me
@stray garnet @stray garnet let { member } = message;
yw
though your first line could be truncated into that too
const { guild, member } = message
any why is membersize the amount of all users in the bot
shouldn't it be guild.memberCount
or guild.members.size (the same)
still dont works.... :\
no
just no response
sad
no errors
weird shit
Well anyone knwos how to to an fakejoin command?
Whatttt can you explain what that exactly does
that should Welcome a User that joins the guild
@stray garnet output of require('discord.js').version ?
Yea discord counts it up
Well yes because .memberCount isnโt in the updated guild object lib does it itself
Well that wonโt be a command, itโll be with the guildMemberAdd event @stray garnet
But it takes a decent
Oh fck lol
Lol
Weird that guildMemberAdd gives a message
its hard to type on a mobile
What guildMemberAdd gives a member
Yeah thatโs what I thought
So then do .emit(..., message.member)?
it's giving me a headache
bot.on("guildMemberAdd", member => {
const embed = new Discord.RichEmbed()
.setColor("RED")
.setTitle("Asuka - Welcome")
.setDescription(`Hello ${member.user}, welcome to ${member.guild.name}\n We are now ${member.guild.memberCount} Users!`)
.setThumbnail(member.user.displayAvatarURL);
member.guild.channels.find(c => c.name === "welcome").send({ embed });
});
Eh Iโd let the user pick the channel name and store the ID in a database
shush
Not the topic
but I would use User#displayAvatarURL() over User#avatarURL()
because avatarURL fails if they have a default avatar
Same
I changed it lmao
Oh ok
All the icon and avatars are methods now
@tight heath still don't Works
Yeah now hehe
Is there a channel named welcome
iconURL was removed in discord.js@12.0.0
no?
bot.on('guildMemberAdd', member => {
let server = member.guild.id;
if(!db.get("blacklist_mode").find({ serveur: server }).value()) {
return
} else {
let iduser = member.id
if(!db.get("blacklist_users").find({ user_id: iduser }).value()) {
return
} else {
const get_motif = db.get("blacklist_users").find({ user_id: iduser }).value()
let motif_msg = ''
if (!get_motif) motif_msg = "โ Aucune raison dรฉfinie."
else {
let motif_message = Object.values(get_motif)
motif_msg = motif_message[1]
}
if(!member.guild.me.hasPermission("BAN_MEMBERS")) return member.guild.owner.send(`**โ L'utilisateur <@${iduser}> vient de rejoindre votre serveur ${member.guild.name} mais il se trouve actuellement dans ma liste noire pour la raison suivante : ${motif_msg}**`).catch(err => {
if(err) {
return
}
})
member.ban()
member.send(`**โ Vous avez รฉtรฉ banni du serveur ${member.guild.name} car vous รชtes dans ma liste noire pour la raison suivante : ${motif_msg}**`).catch(err => {
if(err){
return
}
})
member.owner.send(`**โ Un utilisateur malveillant vient de se faire ban du serveur ${member.guild.name} car il se trouve dans ma liste noire pour la raison suivante : ${motif_msg}\nIdentifiant de l'utilisateur : ${iduser}**`).catch(err => {
if(err) {
return
}
})
}
}
});```
Once I put the catch (err etc the bot react not when a malicious user joins
it has not
and I see no reason why it should
Ok.
Is connecting to MongoDB outside or inside of a message function better on discord.js.
outside
you should do it where it's only executed once
and access that connection in the message function
so like put the events inside
Embed.setThumbnail(message.guild.iconURL({ format: 'png', size: 1024 }));
yw
npm i && npm run start
oh wait ur not cool
yes
for basic features it just needs a DISCORD_TOKEN
yes
I think I'll add an example.env
Client is a MongoClient and client2 is a Discord client.
client.connect(err => {
client2.on(โmessageโ, message => {
});
client.close();
});
``` Will this work?
once I'm done actually writing the bot, I'll make it selfhostable
yes but it hurts
why don't you just name the mongoclient mongo or db
client2 is a very unreadable variable name
is anyone here proficient with MongoDB
What is your question?
mongo has its own clients for every language
json db
sounds like a bad idea
One message removed from a suspended account.
idk man
One message removed from a suspended account.
@old geyser being read as a string or integer?
I need some help with my music bot I am working on.
It can come online and work but when I type the command to play music..well I just get this (Picture) after it joins my Vc does what it does in my console log. Then it leaves the Vc with me after saying "Undefined"
Note: I am still kinda new to coding.
how can i use AHK to make my screen loop?
the x is correct
according to that
so to start off
lets say any y less than -393 should move it back to there
#Persistent
SetTimer, WatchCursor, 100
return
WatchCursor:
MouseGetPos, x, y, id, control
return
escape::ExitApp
IfLess, y, -393:
{
MouseMove, x, -393
}```
that doesnt work
@jaunty stump Did you manage to get it fixed?
No
Ok. 1 moment
window.onscroll works on discordbots page?
@earnest phoenix you need configure DBL in your code
Go to the link he sent, it's pretty self explanatory
yes, but apparently window.onscroll only work on preview mode
Oh, I'm not sure then, sorry
np ty
javascript in long description is only for certified bots
oh, ty guys
{
"guild": {
"prefix": ".",
"cases": {
1: {
"user": "123456789",
"mod": "987654321",
"reason": "Test",
"date": "Not givin"
}
}
},
"user": {
"987654321": {
"permLvl": 100,
"msgType": "embed",
"cases": {
}
},
"1234567890": {
"permLvl": 100,
"msgType": "text",
"cases": {
1: {
"mod": "370381633305575426",
"reason": "Test",
"date": "Not given"
}
}
}
}
}
Error:
- SyntaxError: Unexpected number in JSON at position 55
Where's the error??
Ping with response, please.
Sorry man
Odd...
When I put "1" for both times it appeared, it's valid for me @floral bloom
"1" is valid for me too
@floral bloom for cases, you can use array, i think is better for use numbers
Am I able to get help for the discord-rpc thing here?
or is it just bots I can get help with
Hi
@snow urchin how do you even have access to rpc ๐ค
i meant rich presence ok
which kind of logs
which library
thanks ๐
client.on("messageUpdate", async (oldMessage, newMessage) => {
let log = await logs.obtener(oldMessage.guild.id).catch((err) => (err.message));
const embed = new Discord.RichEmbed()
.setFooter(`Pedido por ${oldMessage.author.username}`, oldMessage.author.avatarURL)
.setColor("GREEN")
.setTitle("Mensaje editado", client.user.avatarURL)
.setDescription(`**Autor:** ${oldMessage.author}\n**Canal:**<#${oldMessage.channel.id}>`)
.addField("Texto incial:", oldMessage.content)
.addField("Texto actual:", newMessage.content)
client.channels.get(logs).send(embed)
Why this didn't work
I do it
how do you define logs
looks like let log
the .obtener callback is not how you do arrow functions lol
does it give a line
client.user.avatarURL, oldMessage.content, newMessage.content can all be empty
inspect which
Odd question but does anyone use linux/ubuntu
Yes
You can just run sudo passwd root
Or just sudo passwd
Or if you are on root sudo passwd
im already logged on root
What if theres a user I added on root
But now I want to completely remove him
google exists
But.......
Me 5hrs ago: Almost destroyed it
What version of Ubuntu are you using
18.04
Do you want to remove the files from the users repository as well?
yes
Thanks, I appreciate it
But if I changed the root password, but he's still there will be be able to even login
Literally 1 minute of googling >.>
Sorry for all the questions I actually never used linux
If you change the root password, only the way you login as root changes, so if he is still there and he still has access to his password he can still access his account and repository on your VPS
Guessing how to do log mode to ur bot?
What do you mean with log mode
๐
I think he means to console
I mean about
The bot logging a deleted/edited message
Depends on language
What language are you using?
What is the username of the user you are trying to remove
But, are the files they created gone
where are all the users usually located though
I might manually delete them
Ig you're right
There sould be a /home directory
Did they remove <Message>.channel.fetchMessages() in discord.js@12.0.0-dev?
Or did they change it, Because I get fetchMessages isn't a function
its .channel.messages.fetch() @warm marsh
hey ya
I think he's just singing the song
@weary zodiac I will paste, wait a sec
@tidal relic no hahahahahaahahha
@quiz.command()
async def start(self,ctx):
await ctx.send('The quiz will start in 5 seconds, be ready!')
await asyncio.sleep(5)
while True:
QUIZQ, QUIZA = random.choice(QUIZP)
await ctx.send(QUIZQ)
def check(message):
if message.author.id != message.author.id:
return False # wasn't the author who responded
if message.content.lower() != QUIZA:
return False # author did not respond with a form of hello
return True # yay!
try:
message = await self.bot.wait_for("message", check=check, timeout=60)
except asyncio.TimeoutError:
await ctx.send('Ninguem acertou, nova pergunta em 10 segundos')
await asyncio.sleep(10)
continue
if QUIZA == message.content.lower():
await message.add_reaction(emoji="โญ")
await ctx.send(f'<@{message.author.id}> encontrou a resposta **{QUIZA}**, prรณxima pergunta em 10 segundos!')
await asyncio.sleep(10)```I'm struggling with that, I'm beginner at python and coding at all, I'm on it for like 15 days. I've been learning and doing stuff since.
I'm on that quiz command and using while loop and wait_for. I need a timeout for guessing (that I already have) and a timeout for **idling**, if no answers at all in 60 seconds reaches the break point.
I read the docs and I did not get it working on my own, I would like if someone could show me how and I will learn from it! I already have a lot of wrong attempts to that.
So, basically what I need on that thing is a second time out, a guy told me to add another coroutine with a new timeout for idling.
@dark dust, I might be able to help you.
@steady canopy It would be lovely
so what is exactly the error your getting
Ahhh, alrighty.
I'm not getting any error
I sill need that
So if no one responds in 60 seconds, what would you like to do?
so it stop looping
do u have it in a class
(and another thing that I will try to do next is: if the command still running, you cannot run that in the same channel) so the person gets a message like (there's a game happening right now)
I have the quiz command inside a command group
ok
in a cog
ok
I mean you could do something along the lines of responseReceived = False and a counter = 1 before your While loop. I see you have an asyncio.sleep(10) so every time that fires, you could check to see if a response was given. If no response was given, increment counter by one. If counter gets to 6, break. If a response is received, set responseReceived = True
Not currently at a point to think it out properly
@steady canopy the asyncio.sleep(10) is only a pause time for the game, to not give another question right away when someone get the correct answer
- p JASON RANTI FULL ALBUM
Ok
@steady canopy sorry for poking ya, do you still here?
Yeah Iโm here. Just getting to a point at work where I can step away and code it out.
If you add me I can work with you on it in a couple hours via PM
are you starphobic?

#oooooooff-topic ๐
Someone know how to put welcome/goodbye code so my bot can send a welcome/goodbye message when someone join/leave?
How can i get members from role.members
what's your language?
node.js
dunno
i tried with filter but it result "undefined"
I want to get the users id's
dunno```
if you cant contribute, dont
role.members already returns the members
some might be uncached, hence why they're undefined
Yeah, but how i can get the id's
that's all i want
The ID's of all the members with that role?
you can use keyArray() on the collection
since it's a collection of snowflakes as a key and guild members as value
If u ask im using glitch.com discord.js ytdl core etc
Thank u
@earnest phoenix I asked which language he was using! how would I know If I can contribuite if he did not say anything!
saying "dunno" or something other than a helpful advice is not useful and clutters the chat, so does this, have an argument in #memes-and-media
Anyone know of any guides setting up discord oauth with cookies for web development? ๐
or cookies with oauth in general
nodejs
idk anything about discord oauth but you could store the access token in localStorage
yeah but I'm pretty sure saving the access token on localStorage is unsafe
i mean
maybe I'm wrong, not fully sure
the person who authenticated it
it has their data
they wouldnt share their access token unless they know how to access localStorage or want people using their data
yes but couldn't they themselves manipulate it?
not sure, but its safe to say yes until you find the answer
dw
anybody got suggestions on doing a sticky footer?
hello I have a little problem with my bot, if for example a written bot help my bot will respond to the bot by the help command. Can you help me
( I do not know if it's clear )
check if the message author is a bot
Oh yes I did not think thank you !




I'd say it's the 1: but I don't know where position 55 actually is