#development
1 messages ยท Page 377 of 1
@prime cliff xmlhttprequests/fetch
Yea im trying multiple methods and they all fail ;-;
@abstract mango https://i.imgur.com/qBSktnB.png im just always getting a status of 0
But donut is using the same method and it works for him >_>
This is driving me nuts AHHHHHH
Can I ask.. I can't import DBLClient! How do I fix this?
https://please.zbot.me/Ok0GAPHP.png
when you make a request to googles API for search, you can add a parameter called "safe"
if you search google through a package, see if theres a way to enable safesearch through the package

;p
Safesearch aims to disable nsfw shit. Right?
Yeah
yeah thank god
but what if they manage to show something else
_> Im using both jquery getjson and xmlhttprequests and it never works even with multiple methods AHHHHH KILL ME
@austere meadow
What do you recommend, moderate or high?
nvm dont know how to edit it
i suppose high would be ideal
it requires json stuff and s
so i wont deal with that
i was using a different api key
@earnest phoenix Hey if you are not busy can you help me use javascript httprequests in my bot page i have been trying for 1/2 hours and its KILLING ME
what are you trying to do @prime cliff?
Using httprequests in my bot page to get json from an external api
All im getting is network errors and status 0 with every method i have tried
@prime cliff use the request function already on the page?
Xmlhttprequest?
bot pages have this
Ah so i need to define a json with the options and then use the request function
Ill try it later i just got off my computer on mobile atm thanks Tonkku
So, I was going to actually run my bot, but in Python 3.6.2 the error was :
ImportError : cannot import name DBLClient
Any ideas that could work?
there is http://lizardsuc.cf/google
hello are tickety down?
HOW do i check my dbl api?
Does anybody know how to make a Google-searching command, that can teach me?
How do I grab a random image from this imgur link?
I want to grab a pretty birb
@mortal mural https://github.com/appu1232/Discord-Selfbot/wiki/Google-API-Setup-for-Image-Search-Command
๐ ๐ ๐ ๐ get that ToS breaking thing out of here
has anyone had experience with Grafana and NodeJS?
whats the issue?
I can't set up a panel (graph) and docs don't help whatsoever
elaborate?
guys any know about a good guide that teaches me how to use help : "jhjdsja" and make a command handler for that?
or what its called?
client.on("ready", function() {
const snekfetch = require('snekfetch')
setInterval(() => {
snekfetch.post(`https://discordbots.org/api/bots/stats`)
.set('Authorization', 'supersecrettokenverynice')
.send({ server_count: client.guilds.size })
.then(() => console.log('Updated discordbots.org stats.'))
.catch(err => console.error(`Whoops something went wrong: ${err.body}`));
}, 3600000)
console.log(`Ready! with - ${client.guilds.size} servers!`)
client.user.setActivity('fn!stats | fn!patch', { type: 'PLAYING' });
client.user.setStatus("online");
});
this just doesnt update
how long did you wait
idk like a minute
(node:9636) ExperimentalWarning: The http2 module is an experimental API.
C:\Users\Jake\Desktop\stats\node_modules\snekfetch\src\node\index.js:93
options.connection.close();
^
TypeError: options.connection.close is not a function
so that meaning its an 'experimental api' i cant use it?
what does the error actaully mean?
TypeError: options.connection.close is not a function
close is not a function
Your actual error
on the connection object
right
so its my connection?
no
thats not even in my code here
its a snekfetch error then
nan
ok so I am back with the issue of the server count, I don't want to get the server count of just one shard I wan't it to print the server count of each shard, in the order like
Shards Guilds
1: 1000
2: 340
like that but when I use
>eval client.shard.broadcastEval('this.guilds.size').then(results => {
msg.channel.send(`${results.reduce((prev, val) => prev + val, 0)} total guilds`);
})
it still display's 0 guilds as I mentioned above yesterday
is there a way to share a constructor along multiple classes
How do you mean?
classes can extend each other but I'm not sure if that's what you're asking..?
so what im doing is im making an api wrapper
my main file is class api { constructor(token) { this.token = token; } }
and in my other file i have ```js
class AuditLogs extends api {
async test(userid) {
return userid;
}
}
im trying to be able to use the function test but just doing
const user = new api("token here");
api.test("220271040658407424");
but im not sure how to actually do that
you'd need to do
const api = new AuditLogs()```
because AL is a child of api
and that's not how OOP works
yeah ^ afaik, you don't extend that way
I'd do something along the lines of
module.exports = class AuditLogs {
async test(id) {
return id;
}
};
and then
class API {
constructor(token) {
this.token = token;
// read all of the sub-modules and append them to `this`
}
}
Keep in mind that's if you explicitly want to use classes for the submodules
async test() isn't the constructor
oh ok thanks
but again, that's if you want the submodules to be classes, they probably don't need to be tbh
i tried asking in Coding Den but they werent very helpful
@uncut slate i tried it the way you said with appending the modules with this but when i try to do api.test("359038337228472320") i get Class Constructor AuditLogs cant be invoked without new
how did you append them
this.test = require('./types/AuditLogs');
in what way should i pass new
this.test = new require(...)
oh and api is
const api = require('./src/index');
const wrapper = new api("");
passing it as this.test = new require(...); also doesnt work for some reason
same one as before
new (require(...))()
show code
wrapper.test aint a function
show code
// Index.js
class api {
constructor(token) {
this.token = token;
this.test = new (require('./types/AuditLogs'));
}
}
module.exports = api;
// AuditLogs.js
class AuditLogs {
async getAuditLogs(id) {
return id;
}
}
module.exports = AuditLogs;
// test file
const api = require('./src/index');
const wrapper = new api("");
console.log(wrapper.test("359038337228472320"))
erggg
So i'm trying to check my bot's vote with the node lib.
const DBL = require("dblapi.js");
const dbl = new DBL(client.config.discordbots_org);
console.log(dbl.getVotes(true))```
However, all i'm getting is `Promise { <pending> }`
i imagine its something stupid that i'm just not noticing
it returns a promise
not the direct content
really gotta update the docs
but
dbl.getVotes(true).then(votes => {
// Do something with the votes
console.log(votes)
}).catch(e => {
// There was an error getting votes
console.error(e)
})
thanks
can someone explain this error, is it related to snekfetch
C:\Users\Jake\Desktop\stats\node_modules\snekfetch\src\node\index.js:93
options.connection.close();
^
TypeError: options.connection.close is not a function
client.on("ready", function() {
setInterval(() => {
snekfetch.post(`https://discordbots.org/api/bots/stats`)
.set('Authorization', '')
.send({ server_count: client.guilds.size })
.then(() => console.log('Updated discordbots.org stats.'))
.catch(err => console.error(`Whoops something went wrong: ${err.body}`));
}, 360000)
console.log(`Ready! with - ${client.guilds.size} servers!`)
client.user.setActivity('fn!stats | fn!patch', { type: 'PLAYING' });
client.user.setStatus("online");
});
/api/bots/stats isn't right
oh is it for my bot?
you need to provide your bot ID
how can i acsess that sorry?
your bot ID.. the ID of your bot, you know
right click the avatar and then select copy ID assuming you have developer mode
the right endpoint is /api/bots/$ID/stats
id needs to be in template literals?
so this snekfetch.post(https://discordbots.org/api/bots/${417138013852663808}/stats`)`
@uncut slate ๐
No, ahah
first of all, don't put the $ there literally
you also don't need to percent-encode it, it's just the path
hm?
it's not required
tonkku whats the error from?
C:\Users\Jake\Desktop\stats\node_modules\snekfetch\src\node\index.js:93
options.connection.close();
^
TypeError: options.connection.close is not a function
correct
looks like a snekfetch error
use superagent kek
sure, but I don't think it's an error on their side unless it's severely outdated
or a recent version broke
gg
reinstalled, same error
snekfetch code got weirdly complex all of a sudden
try installing a past version @earnest phoenix
npm install snekfetch@4.0.0
im going to console.log something and see if its something else
ok il give that a go
npm ERR! code ETARGET
npm ERR! notarget No matching version found for snekfetch@4.0.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Jake\AppData\Roaming\npm-cache_logs\2018-02-25T19_12_02_690Z-debug.log
ya
Should i host my bot in time4VPS
so no such version as 4.0.0
how odd
oh?
I wonder what the last released version was tthen
GUYSSSSS
chill out man fuck, use whatever you want, free heroku, paid, glitch
im trying request.post
request is not defined
ik
Pืฉืื
Paid plz
@earnest phoenix 3.6.4
3.6.4?
ight
@bitter sundial sorry for the ping
- works great Updated discordbots.org stats.
Which host service should i use
is that trixter
no
@earnest phoenix whatever works for you and your budget
that's what you should use
@abstract mango
that will get you some good stuff at most cheap providers
look here
a vps will support any program linux (usually) can run
node isnt a plugin 
discord js
you need to install it on the vps
how
lowendbox isnt the best deal
there is a full GOOD tut?
VPS providers:
- Digitalocean (i have referral code, DM me)
- Linode
- Scaleway
scaleway has the lowest prices but currently it has available only ARM boxes which aren't really fast
does anyone else have problems while pushing to the API with the example provided for python in #312614469819826177 ? ```python
TypeError: _request() got an unexpected keyword argument 'json'
@abstract crystal wrong, their ARM boxes can be faster than intel machines with the same price
provided your application can leverage multiple cores
so web servers and microservice based bots are going to work better there
i have one vps on scaleway (C1) and DO (2GB one) and DO is better (YES web and bots work better, agreed)
yes
but everything open source is almost guaranteed to work
Any experience on vultr?
its too expensive for my tastes
Scaleway looks interesting, but I doubt they are able to provide the resources you pay for without overloading the machine
Vultr is a very good host and very reliable
its expensive
Been hosting with them since 2016 and they've never let me down
Yes but well worth it if you dont need good specs
bc 24/7 uptime on a fast network
its great
or they cache last 1000 messages in each channel in RAM in a global var as d.js message objects oof
I should switch to hdd caching
where do you (host them)?
I use VPSDime
I am switching hosts and so rn I am running my bot on an old computer in my grandfathers basement (they have really fast internet)
4 intel xeon cores with 6GB of RAM for $7

general performance?
hmmm
I've been with them for a few months now and they've been really good with hosting @cosmic shoal @cinder stream and @clever fog as well as a few other things outside of Discord
RX bytes:2597627340356 (2.5 TB) TX bytes:1937242466639 (1.9 TB)
same here
I had a TB limit for two months
had to get that shit off
bc once we reached 900GB of usage
it started crashing PUBG
Ping: 3.587 ms
Download: 591.51 Mbit/s
Upload: 255.88 Mbit/s```
all providers in my country have unlimited data
current internet (scaleway)
yeah my home internet is around 300Mb down and 10Mb up
Well I've vowed to switch if I get more multiday outtages
mine's 50/50
lemme get my bot server speed
The only outage I've had recently was when I acidentially ran poweroff on server instead of local
but i usually get 20-40 up/down on my laptop
because reasons aka brother hogging up all internet
its usually around there
hmmm
I have 10/0.5 at home
my grandparents have 500/50 ;-;
and they pay half as much as me
Define good specs (about vultr)
Most intensive app would be probably lavalink
Well figure out what specs you need
and compare prices
ยฏ_(ใ)_/ยฏ
idk ur budget
Just for lavalink nodes, planning on 2x 20 dollar vpses in eu and us
lol
What exactly is funny?
\๐
if it isn't a custom emoji, just do :emoji:
doesnt really work that well for me
i mean i dont know how much it uses
But probably just gonna start with $10 one
Don't know where to ask about resource usage though 
pretty low
you can probably handle 50 VCs with 1GB/4C
and still have resources to spare
(scaling my bot's usage would be close to that, and both use LP)
Thats good to know, thanks
is there a way to check when a user voted? I would like to reward people who vote everyday with extra currency.
you have webhook ( weebhook ) or just the usual GET
How could I setup a webhook that my bot can listen to (JS)?
You will need a webserver, I think you can use express
I don't know if you use Eris but afaik you can combine express and eris just fine
discord.js
I'm not sure about combining Express and discord.js
Otherwise, my solution is, although for python, to have a separate webserver and bot which are both connected to the same database
Using redis pubsub which triggers something in another bot that shows vote count in a channel, and the main bot can just read the vote count from the database
could i possibly put a discord webhook URL in, and have it post in a private channel the webhook's data?
and then have my bot parse it
no
out of curiosity, why wouldnt that work?
the webhook format that dbl uses
isnt a message webhook
its a data webhook designed to be received by bots
ah
if you have redis and want to use a pubsub i have a (go) webserver that pushes to a redis pubsub for webhooks
resource usage should be fairly low
You could parse the data yourself to transform it into a discord webhook
and you'd have to handle ratelimits
if for whatever reason you got, say, 6 upvotes in 5s
tfw you 429 DBL
you'd get a 429 on the discord webhook
I just use webhooks on a server I mod for twitter and weather
Just says everyday at 7:00 that's its hella cold and the bot hopes y'all freeze to death
But yeah I'm still thinking about a feature to use for upvote locking
But first dbl needs to actually fix the upvote login bug
Hmmm
About webhook security
You could paste a webhook url with a secure string in it
Like
GET /hook/:hookToken
Or post
Or whatever
Hmm
Have your webserver check the querystring
Something like that
I've actually posted in #414124730715734068 that there should be a way to set an Authorization header
So it's a header and not a querystring
Although afaik post requests are decently secure
Anyone know a lib that is more efficient than discord.py?
yeah, what's up
I keep getting this error every time I load up my bot
and then it closes automatically
try installing aiohttp again
python3 -m pip install aiohttp
Or your OS's equivalent of pip
ye
Ok, I'll try
Stop
@earnest phoenix your internet also might be going
speak russian in #memes-and-media
to create a bot you need to have your website ready?
you need to run a webserver
@quasi marsh Thanks! @abstract mango Thanks!
GET /api/bots/:bot_id/votes
np
you need the (dbl) bot token
Is there a way to get how many bots are in a server in discord.js?
@earnest phoenix It is possible to create a script that goes through all the users in the server and see if they have the bot property. https://discord.js.org/#/docs/main/stable/class/User?scrollTo=bot
Yea that is too easy 
SUGGESTION:
Bind Bot to Channel, Make it so the bot can not be moved from channel, if it is it auto goes back to channel ID
No
The server owners can do that, only the bot owners can
And right now bots can only speak in #commands it #265156322012561408 or #265156361791209475
Anyone know why async is underlined and I get this message from pylint?
oh nvm
it disappeared
and it appeared again wtf
C:\Users\q\Desktop\Bots\events\message.js:16
let perms = client.elevation(message);
^
TypeError: client.elevation is not a function
at Client.module.exports.message (C:\Users\q\Desktop\Bots\events\message.js:
16:22)
at Client.emit (events.js:165:20)
at MessageCreateHandler.handle (C:\Users\q\Desktop\Bots\node_modules\discord
.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\q\Desktop\Bots\node_modules\disco
rd.js\src\client\websocket\packets\WebSocketPacketManager.js:102:65)
at WebSocketConnection.onPacket (C:\Users\q\Desktop\Bots\node_modules\discor
d.js\src\client\websocket\WebSocketConnection.js:325:35)
at WebSocketConnection.onMessage (C:\Users\q\Desktop\Bots\node_modules\disco
rd.js\src\client\websocket\WebSocketConnection.js:288:17)
at WebSocket.onMessage (C:\Users\q\Desktop\Bots\node_modules\ws\lib\EventTar
get.js:103:16)
at WebSocket.emit (events.js:160:13)
at Receiver._receiver.onmessage (C:\Users\q\Desktop\Bots\node_modules\ws\lib
\WebSocket.js:146:54)
at Receiver.dataMessage (C:\Users\q\Desktop\Bots\node_modules\ws\lib\Receive
r.js:389:14)
wft?
thats not a thing
^
what were u trying to do
Read the error. โclient.elevation is not a functionโ @earnest phoenix
@frail kestrel normal
since linters can't see how the function => command, it assumes it's unused
Guys how do i send messages in specific channel? Discord js
use the get functions on a collection of channels avaliable in the client object
to get the channel by id
How do i choose channel id?
hmmm
Dude plzzz
@earnest phoenix you want to find a channel name?
client.channels.find('name', 'logs'); I think that works
Logs?
How would I go about making a page system in discord.js?
Not noww
@earnest phoenix name means you want the channel name
if you wanted the id, you would use id
OK'
Discord??? I want to make if there's more than 10 songs in a queue it creates another page

you essentially want to display a page
Yeah
@Apophis#6414 it's client/bot.channel.find
to switch page/exit
Without send?
You would set the channel as a var
you should have a look at https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=awaitMessages as well as https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=awaitReactions @quiet bobcat
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
What var?
alot
with those 2 you could create a decent reaction based or message based system
for paging
๐
so var sendthemessagehere = client.channels.find('name', 'logs')
Buy a vps
๐คฆ
i want
Prefer paid
free
Oh dear
and paid
ok
@gusty topaz ok
Comprehensive list of hosting companies
Free
https://glitch.com/ - They can host node.js programs, needs some setup
https://heroku.com/ - They can host boats in almost any lang, needs some setup
Paid
https://www.ovh.com/ - Cheap servers, not very fast network, quite decent reliability
https://www.scaleway.com/ - Cheap servers, decent network, decent reliability
https://www.vultr.com/ - Expensive, very good servers, excellent reliability
https://www.digitalocean.com/ - Expensive, extremely fast network, excellent reliability
https://vpsdime.com/ - Cheap, never have had experience with it
https://cloud.google.com/ - Expensive, scaleable, hosted by google, has free trial,
https://aws.amazon.com/ - Expensive, scaleable, hosted by amazon, has free trial
https://azure.microsoft.com/en-us/ - Expensive, scaleable, hosted by microsoft
Any feedback relating to this list, please ping me
ehm
how to disable OG embeds
thx
That needs a ๐
ffs discord
I need to fix that message
so the links dont embed
ok
I figured it out
ok
I had to enclose links in <>
And I agree about ๐
pings mod to pin
nah
I will just mention it in #general

For now I will just save it in a pernament gist
copied from dapi I see
sure
k
@gusty topaz what is the best to host my bot
is it
both are fairly decent
good
ok thx at all
I'm using a Core 2 Quad based system to host bots
and it's really good
XDDDDDDDD
no
This is how I would do prefixes right? py prefix = ["b!", "Brooklyn, "] bot = AutoShardedBot(command_prefix=prefix, description=description)
How would I go about adding reactions to a message in a specific channel in discord.js?
Ping me if you know how (going to sleep)
How can I hide the server / shard counters on my bot's page? please DM or ping.
Has anybody ever experienced and fixed this issue with Captcha's?
https://je-moeder.is-een-plopkoek.be/nGCTqn.png
iOS?
When i slice message content how can i remove mention
No Firefox and Google Chrome
Nodejs
@gusty topaz Actually iOS was the only one that did work
When i slice message content how can i remove mention in discordjs
What is .slice do?
if (message.content.startsWith(config.prefix + "say")) {
if (message.author.id !== ("344671380412956673" && "275804941916962817")) {
return message.channel.send(":x: Soupyz Only Command :x:")
}
message.delete(1);
message.channel.send(message.content.slice(5, message.content.length));
}
});
This no work
Only the second id person can use it
I tried || but it doesn't work as we;ll
Tried using ^ aswell ;-;
Oh
wait lol && is and
Lol
but others no work
Oh ok
;-
is
if (message.content.startsWith(config.prefix + "say")) {
if (message.author.id !== ("344671380412956673" || "275804941916962817")) {
return message.channel.send(":x: Soupyz Only Command :x:")
}
message.delete(1);
message.channel.send(message.content.slice(5, message.content.length));
}
Coorect syntax?
Should be
Wait
lemme try again
gotta get the second person to test it
NOPE
it dont work
Halp
if (message.content.startsWith(config.prefix + "say")) {
if (message.author.id !== "344671380412956673" && message.author.id !== "275804941916962817") {
return message.channel.send(":x: Soupyz Only Command :x:")
}
message.delete(1);
message.channel.send(message.content.slice(5, message.content.length));
}
Try this @olive ridge
hello anyone here do a canvas?
Ok, Pete! :3
It works! Thank you Pete. :3
I will remember to retype the message.author.id !== part.
np
does anyone know a lot about forking / spawning child_processes in nodejs?
no
oh, its all good thanks @restive silo
figured my problem out lul
wat you aren't the real ken 

memes
i c
was still logged into my alt so yes
o
How do i make a clear messages command discordjs
bulkDelete is what you want
@restive silo and how i can use it for sfecific amount of messages, example plz.
What page are you currently looking at
How do i set the number?
by typing it?
@solemn obsidian its suppost to be var?
I'm deceased
read the first argument description to bulkDelete
xd
Hello, im trying to find some support ticked bot to host my self, like the bot TIM and TICKETY.. some one knows of a bot ? i want to host it my self for a "cean" bot pacage on my srver
parse error: Expected another key-value pair at line 17, column 3
parse error: Expected another key-value pair at line 17, column 3```
what does this mean?
it wont load any shards on my bot
probably json
Hey guys, heroku says that my free dyno hours have been used up for February 2018 so my bot is offline. If I don't do something fast i'll get pulled off this list. Can anyone help me to get the bot online or give alternative and free hosting solutions ples?
I created a new account on heroku and a project on that account to host my bot as a backup however I don't know if's it's actually working
You won't get pulled off the list for being offline
At least I rarely see them doing it
you wont aslong you aren't certified
oh thank you. so I can figure it out at my own pace i see
Locally host it for now.
are there any other free hosting services. i couldn't find any good ones
Raspberry Pi
how would i keep it 24/7 on local?
You cant
rip that's what i thought
well you can but you'd be killing your pc doing that 
^
hmmm
most PCs arent harmed by being on 24/7
some older hard drives can go poof
but if you have an SSD
then it shouldnt be an issue
also fans
it's still not exactly the best thing to do though
meh, I had my PC on for 2 months at one point
what the hell
afaik my pc was running since 2017 until today's windows update
runs well, just need to clear the cache at some point
and get a virus to delete all your registry keys
that was already fixed
and you should never use bleeding edge BETA versions on prod servers
the biggest issues of having a computer on 24/7 are power usage and noise
but you should turn it off every once in a while
^
power usage for me
noise not an issue
My computer is silent as fuck
But yes indeed that can be a problem, unless you store it somewhere
afaik depends on your PC for that
also if your power runs out/internet has issues
you'll have downtime
datacenters usually have backup power sources and more than one internet connection from different ISPs
Unless you're crazy enough to buy a UPS
The internet would still be a problem though
lel i have 5 operating systems on my mac. sure i could use 1 distro of linux to host ๐
Honestly power in most places of the word per kilowatt is pretty cheap and if you host it on a PC that doesn't use much power this shouldn't be an issue
anyone help me with install windows-build-tools ๐ญ
powerhsell
Why I have a prob with installing is I am in linux env
๐คฆ
There is no cmd or powershell
linux-build-tools
you don't install windows-build-tools on linux
@gusty topaz ``npm i -g linux-build-tools`
yes
npm i -g build-tools
@gusty topaz Package not found..?
dont use the linux- prefix
what error
So server is working. I'll mention you when its done
@gusty topaz
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-02-27T17_35_12_646Z-debug.log
part of err
ok
put it on a paste/hastebin
guys i have c;ear command
and when the command is not giving a num to clear
the bot crash
like ?clearall
check if it's a number then
that's for discord.js
or all js for that matter
what do you mean by "something wrong"?
that not true
um... installing build-tools not solved
like if (i = gay) FALSE { YOURE STRIGHT}
it's like
sry enslish bro
oof
if (condition) {
// do stuff
}
its literally basic language syntax
yes
but if its false do it
if the condition evaluates to true, do stuff is executed
its else
oh you can negate a condition
@gusty topaz do you know why??
and if its false?
if (condition) {
dostuff();
} else {
dootherstuff();
}
the ! operator flips a condition
@gleaming summit I have no idea anymore
if (!condition) {
// do stuff
}
@gusty topaz Also thank you very much
so like
if (!person.isGay()) {
// the person is straight
}
if (condition) do stuff
using your.... admittedly weird example
phanta
if (condition) {
dostuff();
} else {
dootherstuff();
}
is better than the ! approach if you want to handle both cases
use the typeof keyword
?
How do i send message to specific channel
Are you using discord.js
How that called
?
Wtf
What to search
there
What to look for
...
look client or smth
there
rest you have to do yourself
How do i choose channel with his name
wym?
How to i send a messgae to a channel by his name
like send logs to channel named staff
google it?
You probably should learn basic javascript syntax and how to use docs before doing a discord bot
hello
Keep greetings out of #development (;-_-)
hello ๐
did you relaunching
How would I get this to send a picture not link
const Commando = require("discord.js-commando");
const Discord = require("discord.js");
const { get } = require('snekfetch');
module.exports = class PrefixCommand extends Commando.Command {
constructor(client) {
super(client, {
name: "catimage",
memberName: "catimage",
group: "basic",
description: "Get a random image of a cat!"
});
}
async run(msg) {
const response = await get('http://random.cat/meow')
const Link = response.body.file;
msg.attachment(Link);
}
}
@steel heath
Iโm thinking docs confusingly dumb
then continue not to
K

@heady zinc can you help
do smth smart
like idk send a message back
if you use commando cuz you don't know js at all, you may want to at least learn the basics
I used to use commando because lazy
And it's not like you don't have to know the basics to use it
Ok so
In the file you want to run
You have to have a fuction
And all code in it
You do
module.exports = function(args) { code };
Then you do require('./filePath')(args)
Yes the command file
Well
module = file
If you put ./ Before the file name
It will load from the directory you are in
Not node_moduless
So essentially ./help would load help.js
./ = put that shit in front of file names if you want to call one
From your folder
in your code*
Well
I can go in depth why you use that in bash to run a file as well
But walls of text are hard to type out on a phone
Nooo
Its module.exports
for example: ```javascript
const OwO = require("./mmLol.js");

I already mentioned it
Previously
require('./ping')()
Dont forget ./
Before filename
And no js extension
So ./ping
And yes
That will work
even though I barely helped, yw
nope
I have an object; let's call it result.
console.log(result) looks like this:
[ { '$': { num_results: '1' }, METAR: [ [Object] ] } ]```
but when when I do `console.log(result.METAR)`, it returns `undefined`.
Can someone help? This is JS btw
looks like result is an array
so to access METAR you need to look for it from the first (and only?) element of the array
.
o
wow I didn't notice that
mfw haven't touched JS in like a year; fml
Thanks for the help lmao
idk dfdffdf
don't post random things in #development
@terse quarry I don't know how to use the apis tho
Use a JS Reddit wrapper
@terse quarry don't know what that is
...
- Please do not ping me every response
- Google is your friend
ok
@unborn stone Did you figure out what you needed?
yes thank you
np
how do i send messages in specific channel by his name d.js
i used it
I'm trying to add economy bot code.
Here is the part that seems troublesome:
let userData = JSON.parse(fs.readFileSync'Storage/userData.json', 'utf8'));
The console returns:
C:\SoupyBot\Storage\bot.js:8
let userData = JSON.parse(fs.readFileSync'Storage/userData.json', 'utf8'));
^^^^^^^^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
WAIIIT
forget an (
can you help me after?
ok tnx
C:\SoupyBot\Storage\bot.js:82
fs.writeFile('Storage/userData.json', JSON.stringify(userData), (err) -> {
^
SyntaxError: Unexpected token >
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
client.on("message", (message) => {
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
//Economy Commands
if (!userData[sender.id + message.guild.id]) userData[sender.id + message.guld.id] - {}
if (!userData[sender.id + message.guild.id].money) userData[sender + sender.id + message.guild.id].money = 1000;
fs.writeFile('Storage/userData.json', JSON.stringify(userData), (err) -> {
if (err) console.error(err);
})
its there
its => not ->
how do i send messages in specific channel by his name d.js
if u use
message.channel.send it will send the message in the channel the command was writtin.
ok
you can grab channels in a guild by using guild.channels and then using the get function on that
so channels.get(id)
same goes with client.channels
let channelss = guild.channels.get("name", "staff");
is it fine?
channelss.sendMessage({embed: {
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open 'C:\SoupyBot\Storage\Storage\userData.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.<anonymous> (C:\SoupyBot\Storage\bot.js:8:30)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
if (message.content.startsWith(config.prefix + "ping")) {
message.channel.send({embed: {
color: 3447003,
description: ":ping_pong: Pong!"
}});
}
``` my embed
comd
Not related to error
?
@earnest phoenix yeah that will work
although
you'd need to use find not get if you're using "name"
and i dont know why you're using sendMessage
it wrote that guild is undefined
then you can get a guild with the same method
client.guilds.get(id)
i want by name
ReferenceError: guild is not defined
at Client.client.on.message (C:\Users\user\Desktop\TheTeller\bot.js:194:25)
at Client.emit (events.js:160:13)
at MessageCreateHandler.handle (C:\Users\user\Desktop\TheTeller\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\user\Desktop\TheTeller\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\user\Desktop\TheTeller\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (C:\Users\user\Desktop\TheTeller\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)
at WebSocket.onMessage (C:\Users\user\Desktop\TheTeller\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:160:13)
at Receiver._receiver.onmessage (C:\Users\user\Desktop\TheTeller\node_modules\ws\lib\websocket.js:137:47)
at Receiver.dataMessage (C:\Users\user\Desktop\TheTeller\node_modules\ws\lib\receiver.js:409:14)
the id change







