#development
1 messages · Page 327 of 1
lol
Who really gives a fuck on the internet @earnest phoenix
i do.
I dont
cool
ok
They dont know the true you
how would you read the latest article from this https://newsapi.org/v1/articles?source=engadget&sortBy=latest&apiKey=apikey-here and post it to Discord?
and by the way, the JSON looks like this: https://haste.passthemayo.space/izotosoxop.pl
in JS
what is it
news cmd
aaaa js
lol
do you wanna read it into a list or array
or wot
or dict
just google™
I'm doing all this using google
@low niche
so then ask it
Okay
Well
Im trying to get a server ID
I tried message.group.id
But im sure thats not correct
Wew
At all lol
Have you tried consulting the documentation
"group"
Yes
lol
That might help
Discord servers are called guilds
To create the other commands
Are you lying?
Guilds
Yes!
Where did you think it was called group
It auto completed
No no no no
In my vcs
Check the documentation
Check before you ask
I did lol
No
Im using node.js
And visual code studio
Along with discord.js and commando
Lel
You said no but you are using it
nice
I found out the last strings are similer between users and channels and servers
like .id
Found out?
wew
Now i need to find a way to incorperate mentions
.>
So you can do like a mention ID
Welp, time to expeariment!
Thx guys!
What’s the point of showing someone a channel / guild / user Id 
hey how can i make in a dm message separate lines from a bot
@timid bolt
-bots @timid bolt
Bots don't have bots, silly.
does anyone know who does the backend on https://discordbots.org/? i wanted to ask a quick question about how it works
that would be me
if you are alright with me asking, how do you handle user logins and oauth2 token storage? i am trying to make a website in node.js but im a bit stuck 🤔
refer to oauth2 docs and store to a database
@bitter sundial what lang/lib
@noble hazel for?
oauth?
the site itself
nodejs
express
👌
Thx Luca
!!test
code=
await client.change_presence(game=discord.Game(name=f'$help | Servers: {len(client.servers)} | Users: {len(client.users)}'))```
error =
```Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Roei\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 223, in _run_event
yield from coro(*args, **kwargs)
File "C:/Users/Roei/Desktop/Skeletron Bot/main.py", line 16, in on_ready
await client.change_presence(game=discord.Game(name=f'$help | Servers: {len(client.servers)} | Users: {len(client.users)}'))
AttributeError: 'Client' object has no attribute 'servers'```
if anyone is able to help than thanks
what does the error say?
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Roei\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 223, in _run_event
yield from coro(*args, **kwargs)
File "C:/Users/Roei/Desktop/Skeletron Bot/main.py", line 16, in on_ready
await client.change_presence(game=discord.Game(name=f'$help | Servers: {len(client.servers)} | Users: {len(client.users)}'))
AttributeError: 'Client' object has no attribute 'servers'
the error says 'Client' object has no attribute 'servers'
what do you think that could mean
mhm
the lines are under each other
and the requested
requested is a footer
how do i do it in embed
stating your lib would be a good start#
js
d.js
then what
computerfreaker - Today at 14:34
msg.channel.user
in d.js
set the embed footer to that
the heck is msg.channel.user
ya
yeah
but eww embed builder
no after .addField don't put a ;
ok
these damn ads istg
it says
yes
Yes.
no
how can i make seperate lines in embed rich embed
.addField(some text, true)
.addField(more text, true)
.addField(somewhat more text, true)
for every line that has " "
add semi-colin
np
url(image => {
var emb = new Discord.MessageEmbed()
.setDescription(`[image link](${image})`)
.setImage(image)
.setColor([
Math.floor(Math.random() * 256),
Math.floor(Math.random() * 256),
Math.floor(Math.random() * 256)
]);
msg.channel.send({
embed: emb
});
});```
this is how i have done it btw
how do u make a kick command
that works
i have this but it doesnt work
the rest
i have to go
and look at examples online
client.on("message", (message) => {
if (message.content.startsWith("/kick")) {
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
// Kick
member.kick().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully kicked :point_right: ");
}).catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
});```
@shrewd field simple example
just do ** text **
np
how reasons
did you global define prefix
there might not be any mentions
that code expects a mention
there might not be one
const member = msg.mentions.users.first();
member // will return undefined if there are no mentions
member.kick() // will throw 'cannot read property kick of undefined'
ok i will retry
what did you change
well duh
the code works but
it only gives the part which says "access denied"
not the kicked
how can i make it say kicked user
message the channel
huh
look
meber instead of member
ohh
member
actually i fixed it
but this is old
it is fixed from meber to member
okay
scrnshot
above with the bot
i want it to kick not say access denied
computer freaker
hello

computer freaker
typing their name wont help much
ok
anyone can help me
can i mention
@supple ocean with what?
tonkuu
You know python rewrite?
dont mention multiple times
ok
like just
don't be annoying with the mentions
@lavish mango
@stone kiln @uncut slate
remember that we're talking over text
Dude.
???
can u help
not irl face to face
sorry only do discord.js and discord.net haven't learned discord.py yet @supple ocean
i'm partially busy with other stuff
ok
you literally just got told to stop mentioning people randomly.. @shrewd field I've told you so many times. If someone can help, they will.
ok
rip
Just ask your question and wait.
ok
just post your question
Im trying to make a $Report command, It should be like: $Report @Roi#4575 spamming and then it sends DM to the owner of the server
Coding language - discord.py rewrite
I know discord.py rewrite a bit
Though I'm not officially a dev so my answers come with a grain of salt :P
You can get the server owner with Guild.owner, and the Member object is a child of messageable
So you can just do Guild.owner.send() to send a PM to them
oh
i found out to send DM to the owner
ik
member.guild.owner.send()
But now I need the message inside the $Report will be sent
Not "test"
If you want to just pull all that the person typed, you take in def report(ctx, *message)
In a function definition, *args means 'take in any number of arguments'
And it gives them to you as a tuple
@commands.command()
async def report(ctx, *message):
message = ' '.join(message)
ctx.guild.owner.send(message)
ahh like varargs?
Yeah
weird cuz in the langs I code in that's either a pointer or a spread operator
Yeah. Python doesn't have explicit pointers, though all lists, dictionaries, and class instances are actually pointer variables
Yeah
Learning some of this stuff was a pain, when you're not explicitly taught it. Especially as it relates to imports.
I'm struggling so much with pointers
Java and Kotlin did it for me
now Go's like
here have these pointers and stuff, enjoy!
import lib
from lib import func_a
assert lib.func_a != func_a
👀
import lib creates an import object for lib. From lib import function copies that function into your __main__ area.
So thus, they're two different copies of the same function
Other fun special python intake form is
def function(**kwargs):
for key in kwargs:
print(key, kwargs[key])
function(a="123", hello="world")
Prints
a 123
hello world
*args is an unnamed tuple. **kwargs is a dictionary of named input values.
Python is fun. Anyways back to making sure the bot does what it should on server join.
👍
the code works but
it only gives the part which says "access denied"
not the kicked
how can i make it say kicked user
params IMessage messages best way @scenic crest 😏
public async Task Report(IUser user, [Remainder] string reason) {}
fun method(required: String, vararg optional: String) {}```
That's one fun method
yeah kotlin is so weird
but it's weird to the point where it's just cool
func method(required string, optional ...string) {}```
nop
no
I give up. I just can’t get the server count to update with Python. Even when I try @royal pelican’s example from #312614469819826177, all GET https://discordbots.org/api/bots/363007359204982786/stats gives me back is {"shards":[]}. Also, my bot’s page on discordbots.org says that my bot is offline, even though it’s not. Am I missing something? I can’t find any more documentation than that given on https://discordbots.org/api/docs.
@jolly zodiac The bot offline thing is a website bug
But it seems to work for other bots.
Did you use the bot specific tokens?
Yes I did.
@shrewd field could just use if(!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send("you don't have the correct perms to use this commans"); instead of using catch
@jolly zodiac it's supposed to be a post request
.settitle("text")
Oh yea
Can only do titles once
You can do .addfield("Usage !8ball", "Ask a question") @shrewd field
You can do multiple .addfields
and i need the description part
Only things like title, description, footer are limited to 1
@bitter sundial It is, I just used the GET request to check if it has worked.
huh
check the error from the post
how does he do it
The documentation for embeds are on the discord API docs
It doesn’t seem to give me any errors, @bitter sundial. Or I’m overlooking something.
check status code and response body
if you dont get those you aren't sending anything
I get HTTP code 200 – OK
And I’m POSTing {"server_count": 3}
@bitter sundial
But even then the response body just says {"shards":[]}
Server count is supposed to be used non sharding I think
And it doesn’t matter if I use the example or my own solution: ```python
count
b'{"server_count": 3}'
testreq = urllib.request.Request("http://discordbots.org/api/bots/363007359204982786/stats")
testreq.add_header("Content-Type", "applications/json")
testreq.add_header("Authorization", "my token")
resp = urllib.request.urlopen(testreq, count)
resp.read()
b'{"shards":[]}'
resp.getcode()
200
you can use it while sharding too
And it’s just the response, anyway.
you make a regular command and make it return the number of guilds
if you're using d.js
bot.guilds.size
or client.guilds.size
depends on what you called the instance
I am posting. If you give urllib.request.urlopen() a second argument, that’s what it will post. If you just pass it one argument, namely the Request object created before, it’s just a GET request.
And the method returns an object containing the server’s response.
You could also include the POST data in the Request object itself, but the results should be the same.
My solution is more or less like they do it in the Python documentation.
Only that it’s JSON.
ah
could be that you don't need to put +
that should be inside the quotation marks
"blah ${x.y} blah blah"
idk
@jolly zodiac well it's not working. Despite having the second argument it is still doing a get
ok
it works
@shrewd field you tried to insert ${client.guilds.size} into something that isn't a template literal
So no, that wont work
anyone know sqlite3
no
Anyone interested in helping with my bot? You need to be good with working on stuff using many API's OR you can help with the back end database systems... I'm making a bot that acts as a bridge between Discord, normal phone calls, SMS and many other messaging platforms such as Telegram, Email, WhatsApp, Facebook Messager, a Socket.IO chatroom, IRC, and more. We're using twilio for SMS and voice calls right now, but we're open to change. We haven't decided on a database yet, so if you'd like to use a certain database, be prepared to explain the pros and cons of it as well as why it will fit our needs better than another option. Knowledge of server-side JavaScript is required. DM me on Discord (moose#3054) or email me: cooper@moosehub.xyz
DM me if you are
@unique jasper BRO
XD
If I knew more JS, I'd be more than glad to help @earnest phoenix
How much do you know? @cerulean zinc
Not exactly sure
Also someone who can work with the server side stuff
Its kinda like C# in a way, im sure id be able to catch on quick
Me?
If you're interested
how could i filter out text channels from this
client.guilds.forEach(g => g.channels.first().send(content))
?
find()
annoucement command
const Discord = require('discord.js')
exports.run = (client, message, args) => {
let content = message.content.split(' ').slice(1).join(' ');
client.guilds.forEach(g => g.channels.first().send(content))
}
just a basic one
i need to filter it
very basic
why do you need Discord
im going to be adding embeds later
i dont have that in my bot
please don't use richembed
xD
use a simple embed
k
thats not helping my
anyway
what was your problem?
i need to filter out text channels
from this
const Discord = require('discord.js')
exports.run = (client, message, args) => {
let content = message.content.split(' ').slice(1).join(' ');
client.guilds.forEach(g => g.channels.first().send(content))
}
client.guilds.forEach(g => g.channels.first().send(content))
.filter()
do nothing
ik
use client.channels
client
.channels
.filter((channel) => channel.type === 'text' && channel.name.includes('announce'))
.send('ping');
client.channels.filter((channel) => channel.type === 'text' && channel.name.includes('announcements'))
?
xD
it filters out text channels
k
ik
i need
a forEach
or map
someone said
:3 but i dont know where to add them
For each to send message
What library are you using?
Commando and discord.js
Like
I want to have it so you can mention a user
And i.e. it gets their ID
Alright. Just quick note that if it's similar to discord.py there should be methods for getting mentions from a user object
Erm k
I'm looking up documentation quick
Use <@id here>
message.mentions?
.toString()
When concatenated with a string, this automatically concatenates the user's mention instead of the Member object.
And it gets their ID
Ohhh
wow
Just inside a function?
Message mentions and then get the tag of the user
Pretty sure message.mentions returns a user
So you can just do message.mentions[0].tag
//message.reply(message.mentions + "'s ID is: " + message.mention.id)?
Well why are you using an array in the string
MessageMentions
Oh
Wait
Whoops
My bad
The array is supposed to be out of the string
Dere
whoops
Okay there
////message.reply(message.mentions.username + "'s ID is: " + message.mention.id)
So this?
WAIT
Okay
Array
Is this the proper code?
How do you access elements of an array
?
Do you know JavaScript?
Yes lmfao
🤦
Wtf
Ugh dont judge :/
Properties
You need to research terms
User_pattern
Is message.mentions a collection or an array
because a collection is a d.js extension of a map
You need to use .first() instead there
you'll need message.mentions.users or .members
I didn't have the docs on hand
read the docs then 🤦
I did XD
I can
If you don't understand the terminology
Alright so, now i can create a ban system along with a ping ID system
Bro
Of course i dont understand
The terms
Lol
All i know is that there are .<values>
Lol dont judge pls
Alrighty created a testing thing
Uh
It came up "Undefined's id is: undefined"
because it's an array
Okay
collection
map
//message.reply(message.channel.name + "'s ID is: " + message.channel.id);
This works fine
.>
wtf
Check if it exists first
In case there is no mention
It's a map
Read the docs for a collection
Which is an extension of a mao
Mao
Map
Should i use an array?
To store the data?
"Array.map"
sure
you could use sql or enmap but it's really your choice.
;-;
Array.map is different
That goes through an array and does something with every element
Alright, so how would this be useful in mentions >.>
Therefore you need to use .first() on the collection
Ah
Okay
So
wait
Hm
Attached to what?
Any function?
Nonono
.>
Okay wait
So whats happening is
The message.mentions is turning it into an ID
I need to store that ID
Then call it?
message
.mentions
.first()
Okay
What do i put inside first?
Like what kind of code
Oh
Hm
So in this case it would be .first(1)?
Since i need 1 value?
okay what do you want to do
I want to get a user's ID from their mention
okay so if a user mentions your bot you want to get the id of them?
Read the docs
You need to learn how to read the docs correctly because trying random values won't help
It says to put a count in .first([count])
Throw a URL at me
message
Its not in message though
Its in collections
The count is optional.
Oh
Okay
I assigned the code to a variable
So according to what you guys said
It should get the first mention
And store it
Wait
?
.members are members that are mebtiobed
var mentions = new message.mentions.first()
Mebtiobed?
message.mentions.members.first().id
click through blue links to see what things an object has
Wow this is very specific lol
Okie
Thanks so much
😃
Uh
Nvm
-bots @earnest phoenix
@serene moon
@mossy magnet
Is it the same thing with the username?
what?
message.mentions.members.first().username?
@earnest phoenix yes
It comes up undefined
.>
The ID thing works
But the name doesnt
because it's a member not user
Yes...
?
OH
Okay
So instead of members
It would need to be
oh yeah yeah you could do message.mentions.members.first().user.username
user?
OH
Okay so you need a
Ohhhhhhh
Okay
I need to make @mossy magnet work
Hm
Whats wrong with it?
doesn't work
I haven't worked on it in months
any errors?
Oh
Okay ye
Any errors?
And i dont like to assume bot's genders because some dude yelled at me for that so i say it lmao
lol
Erm
Okay
Trying to make my bot send friend requests
Code i have:
message.author.user.addFriend(message.author)
Is this correct?
It comes up with an error
Ah wait
did you read what the error said 🤦
Catch those warnings
How lol >.>
or do you call them something else in your terminology 
Apparently it wont let me if i dont lol
But then you'll just delete the code after seeing the error anyway
It'll be fun finding out how to catch promises
(promise).catch((error)=>{
console.log(error)
})
or again, you could read the docs 
Lol
I did lol
;-;
My bot has a user account
I'm sorry I'm going to contact b1nzy
🤦
and then interpret it correctly
Nah im not gonna have my bot friend people
Its just too complex
Now, imma do a ban system!
Lel
Gonna go research that
Try not asking us for everything
message.mentions.GuildMember.first().user.ban("Banned for unknown reasons")
Got it!
It says ban can go onto users
I might need to just get rid of user
But ill test and expeariment
😃

guys
.setAuthor('Google Search Results')
how do i put an image link for the author
it's almost like docs don't exist
https://discord.js.org/#/docs/main/stable/class/RichEmbed?scrollTo=setAuthor
Ohmegerd
Docs? Are that the tutorial sites you copy-paste your code from?
wat
@jolly zodiac docs = documentation
I know. That was a bad joke.
kek
thonk
no
YES
how can u get a mentioned user's id
substringing
huh
if you're unaware of what substringing is then google it
and then you shouldn't be making bots imho
don't make the mistakes everyone else does
ok the command is !id @user
what lang?
ok
that's a collections of everyone who was mentioned
like
can u gimme an example
ok then
how
docs are your friend
they provide you w/ everything you need to know
I'm terrible at JS and I've never used discor.js
yet I was able to help you by reading the docs
let member = message.mentions.members.first();
member.id```
huh
how can i make it that the message sends the id only to the owner
dm
guild owner?
yes
ok
im pretty sure there is a Discord API guild
get command person's id
get guild owner
check if command sender's ID === guild owner ID
if it isn't, error
if it is, do what we said earlier for getting IDs
ok how to do step 2-5
we literally just told you step 5
i mean 4
get the guild from the event
how
exapmle