#development
1 messages · Page 1758 of 1



@quartz kindle you were the one that mentioned a chrome extension that hides old tabs and puts them in a separate area to conserve cpu and memory?
hmm
seems tons of people think cancelling a subscription to a subscription service will cancel it at the end of the month, even when it says on the screen that it will be cancelled immediately.
is it really that normal that cancelling your subscription gives you a grace period? I mean iirc Apple TV and Amazon etc don't do this?
is it really that normal that cancelling your subscription gives you a grace period
i mean, yeah
you pay for the whole month, you get the whole month
spotify and netflix do this
it might have something to do with the billing cycle
I purposefully set mine like this
as in without that grace period
and it clearly says so before they cancel
but it happens over and over that they just don't read
I mean it's a financial transaction do people really not read that
it's not in my control
oh
that's on the payment gateway side
oddly enough very few ask for a refund or anything
in react, Can/Should I give a key to both single same element which is rendered on a condition
Like,
isTrue ? <Button key={1} x={100} /> : <Button key={1} y={200} />
will this effect/improve anything?
you can, but it doesn't matter iirc
however
if you have a use case like the code snippet you provided
instead of conditional rendering, do conditional props
actually I hv more attributes to paas, which are completly different
ah
ye
tab wrangler
ah ty
Like this?
<Button { ...(isTrue ? {x: 100} : {y: 200}) } />
[PostgreSQL] I'm using deferrable foreign keys to try resolving a circular reference issue where I can't insert or remove data since two keys depend on each other.
I have a media, media_titles, and media_titles_translations table. Each of them have an id, created_at, and modified_at column. There are a few other columns—the most significant with media_id being a native_title_id referencing media_titles_translations, which later references media_titles, which later references media (see hence circular reference).
I'm unsure how to write a query to insert a new row into the media column and hold on to the id column returned and use it in another query (2 in this case since I need to use it for media_titles and media_titles_translations). How could I accomplish this?
@solemn latch
@earnest phoenix thats against discord tos.
Most Postgres clients will return the inserted row after an INSERT. If you’re using node it should be available in the callback res object... though I need more info on what platform you’re using
Your titles also suggest there are multiple titles/translations... maybe a key/value store like Redis might be a better fit for your data
Puedes mencionar por mandar el ID del role con <@& y > alrededor
Por ejemplo para un role con ID 1234 se manda <@&1234>
Gracias
I want to do a cooldown with the db, there is a type for date or I have to put it as a String?
What database?
im a bit confused
i have this: document.getElementById('role id here')
but it returns null for some reason, any idea why?
it'd be so much better if you didnt use a db for command cooldowns (if thats what ur saying) but u'd wanna use interger
a good practice is to store a date of the command's last usage then compare to now
that way if you change the cooldown or there is downtime everything still works as intended
that is usually the pattern I use in a relational db to track cooldowns
i've never heard of someone using a db for cooldowns, bc who has a downtime of just 2 seconds
and its 2 seconds, thats about the same time anyways
for just 2 seconds that wouldn't make a lot of sense but for longer intervals it does
if you have a high performance keyval store like Redis you can make keys that autoexpire then just check if they exist on invocation
yeah sure my guy
SET <uid>:<cmd>:cooldown y
EXPIRE <uid>:<cmd>:cooldown 2
GET <uid>:<cmd>:cooldown --> y or null
In my context, it needs to be executed as one transaction. Relying on the previous value via execution, get, and execution would be two separate transactions. I used deference to try solving a circular problem caused by foreign keys (hence transactions restriction)
since you're using postgres you can chain inserts in a single transaction ```sql
WITH media_insert AS (
INSERT INTO media(...)
VALUES(...)
RETURNING id
),
media_titles_insert AS (
INSERT INTO media_titles(...)
VALUES((SELECT id FROM media_insert),...)
RETURNING id, media_id
)
INSERT INTO media_titles_translation(...)
VALUES((SELECT id FROM media_insert),(SELECT media_id FROM media_titles_insert),...)
quick question
You know how some websites have a login via discord
Is there a tutorial or a link to the documentation on that
you mean oauth2
yes
Ight thank you
module.exports = {
name: 'ban',
execute: async (client, message, args) => {
let toBan = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(x => x.user.username.toLowerCase() === args.slice(0).join(" ") || x.user.username === args[0]);
if (!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("You need permissions!")
if (!message.guild.me.hasPermission("BAN_MEMBERS")) return message.channel.send("Bot need permissions!")
const reason = args[1] || "There was no reason!";
toBan.ban({
reason: reason
})
message.channel.send(`${toBan} has been banned from the server!\nReason: ${reason}`)
}
};```
This command is like... realy simple.. and Idk how I get an error: Cannot read property 'ban' of undefined...
I defined toBan tho..
if all of your chained expressions return undefined then toBan will be set to undefined. You need to add an error handler for that
you also forgot to lowercase the username provided in the args in the find lambda
How do I implement this into my bots code?
int serverCount = ...; // the total amount of servers across all shards
api.setStats(serverCount);
You can have a socket server that issues a get all stats command from all shards and then combine all values in the server and send back to the command issuer
Don't use var, also, ain't that already black?
is there a way i can unfollow an announcement channel with discord.js?
hiii
nvm figured it out
client.on('message', message => {
if(message.content.startsWith(prefix + "dm")){
var args = message.content.slice(prefix.length).trim().split(/ +/g)
var args = args.slice(1).join(" ")
client.guilds.cache.get("716718729186246757").members.cache.each(m =>{
m.send(args)
console.log('message sent to' + m.user.tag)
}
)
}
})```
error
```js
message sent toDyno Premium#3743
message sent toAl Handroo#5536
(node:7828) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
at RequestHandler.execute (C:\Users\gamin\OneDrive\Desktop\dm bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)```
and bot crashes
why tf is that there?
Use catch
damn it that pic was tehre
isnt var to make vertible?
also I got a bug..
Idk why it happens
my button stuff for that is this:
<nav>
<a href="./aboutus.html">About Us</a>
<a href="./discord.html">Home</a>
<a href="./serverStats.html">Support Server</a>]
<a href="./botstats.html">Bot Sats</a>
</nav>```
wait
nvm
I jsut saw that ]
I am really dumb after drinking lots of cold juice dude lol
also
wahts up with #topgg-open-source
how can we bypass it like it just says in logs that cant dm and continue to dm rest of the persona
bot dont crash
dont know how to use it in this situation please explain
pls help me i also want to make cool bots so many ppl suggest me to learn programming language 1st so pls tell me which programming language i need to learn 1st
i want to learn javascript but some ppl are saying u need to learn html and css before javascript pls tell me something what should i do
Hi
You do not need to learn HTML/CSS before learning Javascript. The language you choose is entirely up to you. It depends on what you can read the best and what you feel the most comfortable with.
Breaking Tos Speed run
wanted to find out how many total members i had....uhh....guess that wasn't the way to do it 
not sure wym breaking tos
there's nothing in that which breaks tos 
what did you think I did 
please re read message 1
what 
I personally thought, spamming their API was against TOS
it is if you spam it and dont respect rate limits
as in you hit the rate limit, and keep submitting requests despite being rate limited
hi
i have this weird problem
my bot randomly goes offline and online on its own
i used a flask backend server to host it 24/7 on uptimerobot
and all other bots on there are doing fine
however this bot goes offline and comes back online on its own, and idk why
it also sends the bot on_ready message multiple times
does anyone know why
p.s the bot is on a super active server of 20k members i think
idk if that might be a reason
This isn't your bots problem. Its basically your host.
I suggest going for a cheap hosting supply
btw, uptime robot pings your website 5 minutes apart
Please dont say you use glitch
so basically it would go online and offline in sudden instances
Your bot restarts every 5 min
you might need to tweak that in uptime robot or something
how can i C# bot on AWS?
of course
Add a print statement or any kind of logging in the beginning of your bot file and the on_ready
See if it's your bot disconnecting or your host annoying you
for react, if we pass a new object as a prop, with the same values. Does it trigger for a rerender? (for being a new reference?)
I belive it does
It causes a rerender but if the object is used in the state then the state won't update (assuming you're using funcional components)
ok
this too plz
I don't think that'll matter, keys should be used only when you're creating elements in a loop
so there would be 2 different buttons created depending on isTrue?
hey guys a small help?
this is my command taking code:
bot.on('message', async (msg) => {
if (msg.content[0]+ msg.content[1] !== prefix) {
console.log('no prefix')
return
}
const args = msg.content.slice(prefix.length).trim().split(' ')
console.log(args)
const command = args.shift().toLowerCase()
console.log(command)```
but in this case i have to give commands like this ``.shelp``
i wanna give command like this ``.s help``
what is the change i should make in my code?
To check if the content starts with the prefix, use <String>.startsWith() instead of that condition in your first if statement and use .split(/ +/) for that instead of .split(' '), that should work
how do I transform the if statement?
!message.content.startsWith(prefix)
works perfectly. thank you so muchhhhh
Why NOT to choose Heroku as a hosting for bot???
your bot got ratelimited when another non ratelimit respecter comes
Moin, ist hier auch deutsch?
☹☹☹idk what to say because I typed that in my terminal and it worked mmmmm....
ja aber das gehört in #general-int
Any idea of other music packages which do not use ytdl core? Because ytdl-core cant play live stuff and i am using js
lavalink
Will try to use that. Thanks
hey is there a way to DM the user with oauth?
does io.sockets.emit() will emit event to all client?
or only to the render client?
I have problem cause I want to pass io.on('connection', socket => socket variable to the routers
module.exports = (app, io) => {
io.on('connection', (socket) => {
require('./socket_events')(socket).then(() => {
console.log('New user has been connected to the server');
socket.emit('client_request_location');
socket_io = socket;
})
})
app.use('/', require('../routes/-.js')(io));
app.use('/api', require('../routes/-api.js')(io));
}
I can only pass the io but not the socket
:<
nice ghost ping
sr, I pinged u
but I think im gonna bother u so i deleted
but can u help me
:<
because its async
either put app.use inside the socket callback, or put everything inside a promise
I tried to put app.use in socket callback, but it return 404 not found /
because / must be render and then dom socket can connect to server
that mean / must be render, then socket DOM can be connect
im stuck at that
because its async
whatever you are doing in your other files, needs to wait until the socket connection happens
so await io.on() ?
ahhh
bruh
module.exports = async(app, io) => {
const socket = await io.on('connection')
require('./socket_events')(socket).then(() => {
console.log('New user has been connected to the server');
})
app.use('/', require('../routes/-.js')(socket));
app.use('/api', require('../routes/-api.js')(socket));
}
like this @quartz kindle ?
events do not return promises, you cannot await them like that
hmm, so how i can do it?
what are you doing outside of that code?
wdym?
what exactly do you want to do with the socket and the server?
passing variables
you cant
hmm, then how I can pass variables between client and server?
not like that
you have an http server, this http server generates html pages that you can access by visiting your website, right?
then you connect to the socket, you can send variables between client and server, and you want these variables to change the html page?
yes
you want that the next time you reload the page, the page is different?
yes
then you need to use some sort of global variables
the render needs to get the variable from somewhere, then the socket can update this variable
the socket cannot pass the variable directly to the render, otherwise the render will not exist until you connect the socket
the render must be created before the socket
yes that what I thought about too
and btw why do you need a socket for this?
because I dunno any other way to pass variable between client and server
ajax? rest?
and Im trying to do like a real time update
but you want the page to be reloaded
socket will lose the connection on reload
socket is meant for real time communication without reloading the page
like chat apps
in this case it has nothing to do with the render
the render has to create a blank/default page
and the socket messages have to add stuff to the page on the client, with browser js
not on the server
hmmmm, maybe I should remove the socket and make a api
also an option
hmm
umm
Anyone knows Golang here who would help me in unslowmode command.... unslowmode dosent work if i put value as 0 and works with 5
func (cmd *Commands) UnSlowMode(s *discordgo.Session, m *discordgo.Message, ctx *Context) {
channel, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{
RateLimitPerUser: 5 ,
})
if err != nil {
s.ChannelMessageSend(m.ChannelID, "Couldn't turn off slowmode on this channel. Maybe check perms?")
return
}
s.ChannelMessageSendEmbed(m.ChannelID, &discordgo.MessageEmbed{
Description: fmt.Sprintf("Successfully disabled slowmode for <#%s> To 5 Seconds.", channel.ID),
Footer: &discordgo.MessageEmbedFooter{Text: fmt.Sprintf("Slowmode turned off by: %s", m.Author.Username)},
Color: 0x36393F,
})
}
const { Client, Collection } = require('discord.js');
const { config } = require('dotenv');
const fs = require('fs');
const command = require('./handlers/command');
const discord = require('discord.js');
const Discord = require('discord.js');
const client = new Discord.Client();
const cacheMessageOne = client.guilds.cache
.get('843061318700367872')
.channels.cache.get('845367058463588452')
.message.get('845367708484108288').content;
console.log(cacheMessageOne);
So yeah, The code is supposed to just list the content of the message specified, But it doesn't work, Instead I get this;
C:\Users\user\Documents\tests\index.js:17
.channels.cache.get('845367058463588452')
^
TypeError: Cannot read property 'channels' of undefined
at Object.<anonymous> (C:\Users\user\Documents\tests\index.js:17:3)
yea theres a print("Ready") statement and ive see like 10 of them on the console
why the heck you require discordjs twice?
It does log in
Just
okay here;
const { Client, Collection } = require('discord.js');
const { config } = require('dotenv');
const fs = require('fs');
const command = require('./handlers/command');
const discord = require('discord.js');
const Discord = require('discord.js');
const client = new Discord.Client();
const cacheMessageOne = client.guilds.cache
.get('843061318700367872')
.channels.cache.get('845367058463588452')
.message.get('845367708484108288').content;
console.log(cacheMessageOne);
client.login('wack');
I have no clue why it doesn't work
you know using require("discord.js") 3 times dosen't make the code better
you're trying to get messages before your bot is even connected to discord
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOH
I am so fucking stupid
Thank you
And the reason I got that is because the current code is a abomination of different code snippets but I never bothered to change the name
All the other Imports are woking but these two are not, any fixes (Both are in official PyPI website, with a ss of code, i did the same, but these are not importing into my files) pyrandmeme and Fivem Packages.
are they installed ?
yes
@quartz kindle yo wtf
how does this break my welcomer messages?
isnt it GUILD_MEMBERS that output updates for guild_join and guild_leave?
yes, that
which lib are you using, some require a full member object (including the presence) to emit the event
is there an event for when window.hash changes
Why the star import
i sort of want to make a discord bot. but i dont have a good idea.
i'm making an SPA with window.history.pushState stuff and i want the react component to rerender when the hash changes
also i might want to learn a new lang for it
Hey i had another question,
so basically i know what i am doing is wrong and is lazy but,
let getPrice = async () => {
let result = await fetch(`https://api.wazirx.com/api/v2/tickers/${command}`)
let json = await result.json()
return json
}
let com = await getPrice()```
and i have another function for description, i,e ==>
if (command === command && 'info') {
let getInfo = async () => {
let result = await fetch(https://api.coingecko.com/api/v3/coins/${command})
let json = await result.json()
return json
}
let com = await getInfo()```
to use getPrice command it .s btcinr
to use getInfo command is .s bitcoin info
but when I call for the latter, the former if condition gets called and it doesnt work.
prefix: .s
without that star, it was showing module not callabe
i also couldn't understand the reason behind it but ya its true
your 2nd if statement will probably never fire
do u know why to import star 🤔 @slender thistle
What is this shit even suggested
I'm so sceptic of this package and I literally just found out about it
that is exactly the problem. How can i generalise the use of my command so that the if statements dont interfere?
i love how you are using wazirx api for price and coingecko api for info
maybe look into switch cases or use a different way to check if the 2nd argument exist
😂😂
btw both have diff prices for the same crypto, i use them
use coingecko's api for both
yea lol I am gonna change it, i am in an experimenting phase right now
it shows the average price of a heckload of exchanges
with wazirx's api you're gonna get the price on only that exchange
yes yes or better is use Coinbase or Binance if avaliable @vagrant sorrel
Hi I'm looking to make a vote reward command , ie vote to use command , how can I do so , any example , I'm having issues understanding the docs
yes I was working on implementing coinbase
Ok
So yea any way on how i can make both the if statements work simultaneously?
put the info one first
and make the ticker one an else if statement
if (info stuff) {
do shit
} else {
do shit
}
actually you dont need the second if part
i am going to put more functionalities so i will require else if
Why are you even using that package
Like
I just opened its init and found this
>>> loop.run_until_complete(pyrandmeme())
<discord.embeds.Embed object at 0x000002B689499160>
>>> loop.run_until_complete(pyrandmeme()).to_dict()
{'image': {'url': 'https://i.redd.it/ol7aaw9xpn071.png'}, 'color': 15277667, 'type': 'rich', 'description': 'Meme Request', 'title': 'Meme'}
Something you can do yourself
else iffing doesnt work, it still goes to the first api and fcks up. "i did not get anything, i wont even check what comes after me, sorrryy"
Now on to FiveM
Okay this package didn't even success at being a proper module
Just where the hell did you grab this from
Why can't you just use aiohttp for this 
🥲🥲 i m noob, i dont even know how to use aiohttp
learning day by day
also i started a python course
to learn python
Yeah well pyrandmeme is kind of acceptable, although a redundant package
ohh
As for FiveM, you can ditch it
If FiveM has an official API, look into it. But first, I'd really advise getting hang of basics of Python before getting into more advanced projects
btw that api is for fivem server dev, and this if to collect data from server and send it here
Let me see their node.js package
ohk
Python wrapper loosely based on node wrapper which is based on the C# wrapper
Ya well I give up here kekw
😂😂 u see its not officially build
No one can help until you actually ask your question ^_^
use react-router
My bot named yoink will be offline for one month.. So please don't decline it
they dont care lol
if so then yeah
Yo
In the strf.time the %M for the month right?
First of all, what library and what language
like ```ctx.guild.created_at.strftime(" %#d /%M/ %Y")
rtfd moment
>>> dt
datetime.datetime(2017, 4, 26, 18, 8, 17, 125000)
>>> dt.strftime("%Y-%m-%d %H:%M:%S.%f")
'2017-04-26 18:08:17.125000'
>>> str(dt)
'2017-04-26 18:08:17.125000'
Traceback (most recent call last):
File "d:\Taufeeq Riyaz\Projects\Discord Bots\astro-bot.py", line 25, in <module>
async def hello(ctx):
File "C:\Users\Taufeeq Riyaz\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 1263, in decorator
self.add_command(result)
File "C:\Users\Taufeeq Riyaz\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 1155, in add_command
raise CommandRegistrationError(alias, alias_conflict=True)
discord.ext.commands.errors.CommandRegistrationError: The alias hello is already an existing command or alias.
i'm getting this error 🥲 please help
The alias hello is already an existing command or alias.
Why would you have your name as an alias
Is that the issue kekw
@client.command(aliases=['hello', 'hey', 'hi'])
async def h(ctx):
responses = ['Hello, how are you?', 'Hi', 'Wasssuup!']
await ctx.send(choice(responses))
yeah, i'm still learning 🥲
I mean, you could've removed the hello from the aliases, but that's fully up to you tbh
i removed it and now it shows
Traceback (most recent call last):
File "d:\Taufeeq Riyaz\Projects\Discord Bots\astro-bot.py", line 25, in <module>
async def hello(ctx):
File "C:\Users\Taufeeq Riyaz\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 1262, in decorator
result = command(*args, **kwargs)(func)
File "C:\Users\Taufeeq Riyaz\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 1433, in decorator
return cls(func, name=name, **attrs)
File "C:\Users\Taufeeq Riyaz\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 221, in init
raise TypeError('Name of a command must be a string.')
TypeError: Name of a command must be a string.
I-
You removed the hello from the aliases as well as passed a list on to the name parameter, name can only be str
;-;
Sound familiar?
it's working now, thank you ;-;
you could make a rectange with the same width and height as the canvas before you draw the image
Use fillRect() first?
yes, use fillRect before you draw the image
Wh-why would you add it back?
it's working now 🥲
I can't
I legitimately can't
FYI though, in case you don't know, if nothing was passed on to the name parameter, it'll take the function name as the command name
What's not working?
why did you post a image with a dead dude?
bruh
@rustic nova
What?
oop
Huh
and hes gone
there where a dead due that got shot
I don't think that was a real dead guy tho
It was a dead guy leaking blood from his stomach
lying infront of his car
yeah nah
lmao it looked like it mightve been an album cover or something ?
Nice to see nothing has changed much
also if you post this stuff, some context would probably help
gimme a sec
It's an album cover?
even then i wont post it here lol
@opal plank i use TS and detritus now for about an hour and managed to break it entirely, nice.
sounds like TS
how do I get the bot to wait for audio to finish before playing the next
like it cant find node-fetch even tho its installed
yea figured this out, but even when they are installed they dont get picked up
and i now know why it started to yell, somehow it doesnt want to pickup dontenv properly
wait what
dotenv doesnt have something to be picked up
its just process.env
yea it got a bit weird and doesnt want to pickup installed modules, requires me to restart vsc
did u install ts globally?
ye
I have a little question, I made an application in react, it works fine, the proxy is set to 3001 and the api is already working 3001, everything is fine until here, but when I connect it to the domain "example.com/api/get" does not respond to me here and react directly redirects to the website? Should I do it as "http: //ip:3001/api/get" or is there any other solution?
ive had import 'dotenv/config' working, but now it doesnt want to
the typings are deprecated
which types are deprecated?
if u used my config it should exclude node_modules
so when you compile with ts-node it wont scream about it
thats precisely why i told you to use it instead
^^
was about to comment on that
theres no need for dotenv
also, i assume you got the 3 libs in the bottom installed on ur project too
tslib, typescript and ts-node
though its stupid to mark is as dependency
i mean just straight up installed as dev-dep
you dont wanna ship it with this unless you use scripts with it required(which i do, specially debuggers)
@lusty quest if u get stuck, dont sweat about asking
the configs i sent you should make it rather painless to run it
dotenv is usually my go to stuff for having stuff like API keys inside
@opal plank looks like ts ignores all files for some reason
what's your file structure
got it solved. added "resolveJsonModule": true,to the tsconfig
?
yea i know
i just removed mine when i sent you
i thought it was excluding the folder cuz of that path
no it just ignored the json file, probably the .env file too
ohh wait yea makes sense
yea my config is also outside of /src
but still wont read it
unless ive added the line mentioned above to the tsconfig
hmmm thats a bit odd, that should only happen when you run the code
that's just how ts handles json
ide shouldnt be bitching about it
errorlens just cried about it, when ive added the line it just worked fine
yes
yeah, then it makes sense
es6 imports cannot import json that's why there's a specific option
hypothetically if i were to hire a developer to do something where would i go 
fiverr
if u want something cheap
doesnt coders-den have a channel for advertising that?
idk maybe
Personally, I would choose friends
sorry, but my friends are idiots
not gonna find any better here

i mean depends on what you want to buy
idk honestly seems like too much trouble

sure ig, if you don't want to learn and just want a finished product that's the easiest way to do things, just pay a person to make you a bot
assuming you want a bot
have had a few people ask me the same thing before
i get treated with this error when i try to shift all my commands to another js file and then export them
referenceError: client is not defined at bot.module.exports
just need some code for a time sensitive feature, not a bot
Hey erwin do yo know java? @opal plank
in all honesty, most devs that wouldt be competent for a decent job at all
whats the feature and the lang woogie?
not enough to give feedback on it, no
using tradingviews charting library and making a png of the charts generated by it in nodejs
@opal plank is there a smart way to get a dynamic command handler? the example bot you sended modifies the vanilla detritus client for it.
i mean you can definitely save money, you can just ask in the official discord api server or even search it up on google, you can 100% avoid spending money imo
define dynamic command handler. the commandClient IS a command handler
so i could just export the commandClient and call it in other files and it will pick them up?
anyone?
let me give you a basic example so you know how this works
yea sorry that i ask so much, but the docs are not the best
thats nice compared to d.js
anything inside the folder u point to, will import anything you export default
look
this is an example command
anything exported default will be picked up to be imported by the commandClient
nice
the extension is just so i dont have to repeat the same thing over and over on every command
which is basically this
just i dont have to add those on EVERY SINGLE file
which is just plain annoying and repeating
but you dont need this at all
the only thing that you need to know is that commandClient will import anything in the folder you have in ur files, always the default export
it will NOT import anything else
ok
at Client.module.exports (/home/runner/Stonks/commands.js:27:3)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/Stonks/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Stonks/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/Stonks/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/Stonks/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/Stonks/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/Stonks/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
(node:525) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:525) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
realistically, this is all u need to worry about has far as "dynamic" hot-reloading goes
read the error
i need to get the stuff in my head first, but thanks a lot.
this is simple
first of all i need to work with that bot thing i used in my main js file which the commands js file cant acess, second the api functions are unable to do anything cuz there is no catch statement?
if its still confusing, let me knopw, i can try explaining better
what to do?
define it
i will get it eventually, but i can process informations the best if i hammer my head with them and then take a break to let it sit a few hours. rinse and repeat until you dream from it.
learn how to debug
it will make ur life easier and ours even more
fair enough. Well, like i said, this is really simple. look at the types for ts <CommandClient>.add()
const bot = Client? or const bot = new Discord.client()
thats basically what your file structure can/should have
you need to learn js
you clearly copying stuff that you dont know what it does
np
yea i get this already. but if you want it to become more popular, reworking the docs would be a good place to start
i already told cake that same thing
there is so much stuff that just say what type it expect
no explanation what it does
thats why the best way to get to know it is intellisense and checking his bot's repo as a base
this is an issue, indeed
it is a more sofisticated library, as is rn, it expects you to know ts already
intellisense and the discord docs should guide you, but for new users? yeah, its a mood killer
i cant google "How to add a reaction in detritus?" and have 58 stackoverflow answers
I'm sorry, but how?
if you dont know how functions and/or variables work, you dont know js
welp, good luck
cool
how many people actually check read and listen to that page
probably not many
but better if you did if you don't wanna stand there completely dumb
also only that section
many people probably use that site
lol
its a great guide
client.on('message', message => {
if(message.content.startsWith(prefix + "dm")){
var args = message.content.slice(prefix.length).trim().split(/ +/g)
var args = args.slice(1).join(" ")
client.guilds.cache.get("716718729186246757").members.cache.each(m =>{
m.send(args).catch(err => { return });
if(!m.send(args)){console.log('Cant Dm This Person')}
console.log('message sent to ' + m.user.tag)
}
)
}
})```can i add 10sec cooldown?
yes
use setTimeout
oh that
and check if the timeout has expired
I was gonna send
that
smh
speedy
Hello I am getting this error while installing discord-rpc https://gyazo.com/4e2f3913774a81eebdbc8ec4cd2c8549
Whats the solution for this?
can you guide
read the guide
djs is probably not the user you're looking for
There's https://www.npmjs.com/package/discord-rpc but I've not had experience using RPC
ok
- learn js
- you are not using classes properly
- learn js
shh alr -
if you have a constuctor
you use a new statement first
new Discord.MessageEmbed()
like this
ahh yeah ty
@marble juniper Can you help me?
no Idk how to fix that
ok
@slender thistle my favorite error
naisu
const { MessageEmbed } = require('discord.js');
module.exports = async (client, member) => {
if (member.guild.id !== '814044423473070103' || member.bot) return;
const channelWelcomeEmbed = new MessageEmbed()
.setColor('#ffd6d6')
.setTitle('Welcome!')
.setDescription(`${member} just joined the discord! Make sure to read #rules!`)
.setTimestamp();
member.guild.channels.cache.get('814044423473070103').send(channelWelcomeEmbed);
const dmWelcomeEmbed = new Discord.MessageEmbed()
.setColor('#ffd6d6')
.setTitle('Welcome!')
.setDescription("For Help Using DavBot, Send The Command `<help` In Server")
.setTimestamp();
member.send(dmWelcomeEmbed);
};
Somebody knows why my bot doesnt send the embed?
You need to specify that it’s an embed in the .send parameters
member.send({ embed: dmWelcomeEmbed })
but it also doesnt send the mesage in the channel
🤦♂️
Yes, you need to do the same thing for that as well
oh im not that good in english sorry
That’s okay!
Not only your English is lacking...
good motivation XD
im new in coding so sorry
general ik its a big step but im reading books about java script and so on
what would you recommend for starting
I mean... js is perfectly fine for starting...
Python and JS are fine for starters
js and python are good choices
They are simple and straightforward
imho JS is easier to learn
yes i also think its very simple
Turbo Pascal, fuck you
They simplify a lot of the more complicated aspects of OOP languages like C++ and so on
just learn assembly first
wont ever struggle with other langs
and haskell for you to get into the insanity level a senior dev has
Enjoy using 10000 lines for your first program
@wheat mesa can i dm you for a small question
I’m not sure if I could answer it, you should probably just post it here
okay because i dont want to get hate becasue of my begining skills but yea i ask it here:
the bot still doesnt send the message heres again the code:
const { MessageEmbed } = require('discord.js');
module.exports = async (client, member) => {
if (member.guild.id !== '814044423473070103' || member.bot) return;
const channelWelcomeEmbed = new MessageEmbed()
.setColor('#ffd6d6')
.setTitle('Welcome!')
.setDescription(`${member} just joined the discord! Make sure to read #rules!`)
.setTimestamp();
member.guild.channels.cache.get('814044423473070103').send({ embed: channelWelcomeEmbed });
const dmWelcomeEmbed = new Discord.MessageEmbed()
.setColor('#ffd6d6')
.setTitle('Welcome!')
.setDescription("For Help Using DavBot, Send The Command `<help` In Server")
.setTimestamp();
member.send({ embed: dmWelcomeEmbed })
};
ah thats good
i try it once without dm and then i look if there error is in the dm
^^
the funny thing is there is no error
How are you executing this code in your main file
the bot starts everthing is fine than i join with my second account on my testing server and nothing happens
its in my event folder
what do you mean
@opal plank any idea why it cries about this?
if im seriuos i dont know what you mean
ah okay i send it
const fs = require('fs');
const discord = require('discord.js');
const client = new discord.Client({ disableMentions: 'everyone' });
const { Player } = require('discord-player');
client.player = new Player(client, {leaveOnEnd: false, leaveOnEmpty: false});
client.config = require('./config/bot');
client.emotes = client.config.emojis;
client.filters = client.config.filters;
client.commands = new discord.Collection();
fs.readdirSync('./commands').forEach(dirs => {
const commands = fs.readdirSync(`./commands/${dirs}`).filter(files => files.endsWith('.js'));
for (const file of commands) {
const command = require(`./commands/${dirs}/${file}`);
console.log(`Loading command ${file}`);
client.commands.set(command.name.toLowerCase(), command);
};
});
const events = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
const player = fs.readdirSync('./player').filter(file => file.endsWith('.js'));
for (const file of events) {
console.log(`Loading discord.js event ${file}`);
const event = require(`./events/${file}`);
client.on(file.split(".")[0], event.bind(null, client));
};
for (const file of player) {
console.log(`Loading discord-player event ${file}`);
const event = require(`./player/${file}`);
client.player.on(file.split(".")[0], event.bind(null, client));
};
client.login(client.config.discord.token);
there is a open source discord bot and im trying to intergrate some special things in the bot
im learing
yes
I would follow the discord.js tutorial docs to get started on a bot first.
for command?
You should learn js before attempting to build a bot as well
use this ```ts
import { Context, ParsedArgs } from 'detritus-client/lib/command';
async run(payload: Context, __args: ParsedArgs): Promise<any> {
@lusty quest ^^
ok
https://discordjs.guide/ @tribal quest
still cries about client could be null
i have it already open
You should follow the tutorial on creating your first bot there rather than copy pasting some open source code and modifying it. It's much easier.
hello
yea i get what you mean
async run(payload: Context, __args: ParsedArgs): Promise<any> {
const message = payload.message;
const cc = message?.client.commandClient;
if (!message || !cc || !message.channel) return;```
added optional chaining, but if client is null it would be quite annoying
i add that ontop
can ts-node hot reload like nodemon?
i wouldnt recommend tbh
why do you need reload like that?
if you want to re-import the files, just cc.clear() and cc.addMultipleIn() onto another reload.ts command
you could use tsc -w which watches the changes and nodemon .
which would run the code
i would disencourage that tbh
what do you do then?
i click here like a civilized person
debugger always attached, since its development workspace
okay so bye thanks for the motivation have a great day and bye
what exactly yells at you?
some file called loader.js
it doesnt want to take the script
One message removed from a suspended account.
yea got it running
even tho in the time ive made discord bots i never used the debugger
i give it a shot
who needs a debugger
ayy got now a working command with base command constructor
Hi
How can I pass React.js api calls (localhost:3000/api/get) to express (example localhost:3001/api/get) ?
No, it's not like that, for example, when a request is received to localhost:3000/api/get/user/123456789, it should forward it backwards, but it doesn't work.
forward it backwards
I'm not sure what you mean
localhost:3001/api/get/user/123456789 this works but my domain is connected to port 3000
No, it doesn't exist, for example when a request is received to localhost:3000/api/get/user /123456789, it should redirect to backend, but it doesn't work. @cinder patio sorry my bad english
You can't use uptimerobot for your bot if you are hosting it on your PC - also, it's pointless as you can make your bot run 24 7 yourself by just not stopping the process
In d.py
After fetching diff things from Api, how to send them in this format using embeds [player id]: player name
Code i wrote, but its just sending an embed with only one person:
for player in players:
em = discord.Embed()
em.add_field(name='Players', value=f'Player Id:{player.id} , Player Name:{player.name}')
await ctx.send(embed=em)```
I mean I guess you can use it but with tons of setup
@opal plank does isClientOwner reference to the Account who created the Bot application or the Guild owner?
embed = discord.Embed()
for player in players:
em.add_field(...)
Don't recreate a new Embed object in the loop
let me try'
I mean I guess... if repl is the way you host your bot
actually I use uptimerobot to do what it was supposed to do. Keep track of uptime
Still, using it on a server which is hosted by your PC is hard, you have to setup portforwarding so uptimerobot can ping your IP
also, for a discord bot you don't have to use uptimerobot, you can keep track of the uptime yourself
with fs ?
that'd be hard
Even if i use a db it'd be harder
is CLIENT owner, its the owner of the bot
setting up an entire http server just to keep uptime is overkill
Also I don't host on my pc (I use a VPS)
aka ur userId
the person I was replying to were
thx
lemme introduce you to express
import express from 'express'
const server = new express()
server.all('/',(req,res) => res.send("okay")});
server.listen(3511)
(This works somehow without nginx too)
- I'm lazy
and I encourage everyone to be lazy
overkill for a discord bot
if (!member.hasPermission(`ADMINISTRATOR`)) return `Missing 'Administrator' permission`;
[returns member not defined]
link sus
@rustic nova
steam shouldnt have a ru tld
suspicious link
or spelling steam and community wrong
sterm community lmao
-b @earnest phoenix steam scam
Banned Jⱥภภiร | ŦE丹M 420Hคze#4553 (@supple rose)
yeah anyways member is not defined
ok
it's permissions.has()
yes
all it is.. is some shop.json stuff
maybe he was trying guild.me or something I guess
which isn't the problem
where did you define member ?
in the index.js file
😩 man
b r u h
show the code where you defined member
how are we supposed to help you when you are giving us basically no information
ok
he gave us some info actually
member is defined in index.js
and
he has a shop.json file
Just ask your magical glass ball 
guys, i managed to set up the environment and the scripts for my bot in digital ocean, how do i host it 24/7 ?
he broke his one
it's in python
ok
in DigitalOcean it's always 24/7
i can't find member in the js file
but it's not running rn
send your entire js file then
*calm down don't kill that little guy he's trying to get help here
ok
with token
i can suggest a hosting, come dm
no
the token is in token.json
as u wish
why wherever i ask for help regarding digital ocean some dude DM me with server links lol
well, lets test it
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Digital ocean
they want you to use their shitty vps service
i already know a bunch of them but i want something better
what do you use to start your bot?
python3 filename.py
@regal jacinth https://youtu.be/lskn1Xr-q8E
Digital Ocean is the hosting company I use for my own Discord bots. In this video tutorial I go over how to how your bot for as low as $5 a month. Using my referral link you'll also get $100 credit to get started for free. Keep in mind that this credit expires after 2 months.
🐳 Get $100 of Digital Ocean credit:
https://wornoffkeys.com/digital-o...
you would need to use a process manager or something idk
where do u host
I use pm2 for nodejs
digital ocean
2 Geometry Dash, gamer
TWTG GDPS and RobTops GD
I don't see a member in this paste file
is it paid or free??
paid
Did you save your file
its in a command
yes
use message.member not member ig
ok
@near stratus the video is in js, i code in py lol
what fs did you use ?
fs?
FTP
I'm guessing the bot isn't starting
he did
hmm?
i just did ssh root@IPaddress then set it up
i installed the requirements and uploaded the files
ok so what's the problem
it cannot read perms of null
it's just not online
you have to manually start it
did you start it ?
doesn't know how to host it all the time
install a process manager and run your main py file
i tried python3 filename.py but it just runs until i close my pc or editor
hm.... it shouldn't stop when you close your pc or editor
hmm
maybe you're actually running it locally?
no
i tried to close the terminal and it stopped
why would it stop when you close the ssh
pm2 is trash
the vps is still running
on DigitalOcean
you're just no longer connected to it
it does
because they are only doing python filename.py
i use cmd prompt
hmm then how should i run it?
That's why we use pm2 but IDK Python has PM2
it stops everything when the ssh ends
^
there are a few ways to do it
you could use screen/tmux
services
you could also use pm2, I think (im not sure lemme check)
yes you can
pm2 is for node right ?
comes with npm but can be used for much more
oh
wait a second lemme try
why is it so hard to use digital ocean 
its not
Python Manager 2
Yea, you can do pm2 python3 main.py
this is all vps things
qts
alr
Production Process Manager
you're likely going to need to install pm2
anyways mone works too
yeah figured it out the hard way
Why even bothering with external packages? Just create a service and that’s it.
simpler
this
IDK how I use it in my case so I suggest it
pm2 is overkill
But easier
at the cost of more resources
Just do npm i -g pm2
what is web v9?
my bot is 24/7 music 🙂
Googling how to setup a simple service will show you how easy it is
external tooling is always trying to get in your way
do you mean gateway v9?
no, I'm seeing firebase documentation. There is web v9 code snippets
oh
You just need to create a file, enable the service and start it - 3 easy steps
how do i get a list of all members in a guild
The guild object contains a property members
Not all of them
any way i can view all of them?
a bunch of scam bots just joined my server and im trying to get rid of them fast
You need the guild members intent
ok i have that enabled
What library are you using?
discord.js
ill await your promise
Resolve your promises or get rejected.
literally
i made an embed where i retrive the information from an api and the value is big enough that it could not fit in one embed, then how to send the rest of information as next embed
d.js has a split method
py
you could just slice the string into 2k parts
can i do (channel obj).send(embed) or do i have to do (TextChannel obj).send(embed)
You usually need the instance.
its actually em.add_field(name='Players', value=f'Player Id:{player.id}') so once embed fills with 25 fields, rest info is not shown, i want to send the rest info in next embed
many bots do this
i have a counter that resets at 10
you get the idea
just send an embed for each slice of the string u have
this package works
@rapid wharf you'd need to break the embed into chunks.
If you want to send multiple embeds.
it will be 125 embeds then
if you want to paginate instead, see what shivaco sent.
correct
you havea 6k limit on embeds either way
i guess you could add fields on it instead
to bulk 2 a ta time
per message
😂😂
How would I archive a channel into an image before deleting it?
a what
u cant archive channels
u will be able to do some stuff of the sort with threads tho
but not channels
You can before they are deleted, most support bot features this type of thing.
I'm meaning the contents inside, messages, images, etc.
Legit you can I watched a bot do it.
you are not saying things that correlate
you cant archive a channel. period
what you are explaning is a delete-logs
where it'll copy a message's content into another channel
thats not archiving at all
archiving is a thing that'll be present in threads, and its not public yet
or you mean a lockdown command
where it'll prevent people from saying anything else in that channel
Does someone know how to align these two things horizontally in HTML / CSS?
I think something with a container, but I am not 100% sure how they work
Then what the hell is this?
Its a channel archive of a ticket I closed a while ago.
Those things differ per each bot
I'm looking to try something like it, I understand it differs but I still want to try.
looks like a ticket system
Yeah, I'm trying to improve my ticket system with an archive.
also what is up with that english
what archive?
theres no archive in a ticket system
just dump the conversations in a database
I give up.
you are not explaining what you want
,
I wanna take a picture of inside the channel, all the messages, all the attachments, and shove it into an image or a .txt file.
Canvas is what I am looking for.
I'm not sure, try wrapping them in a p tag?
you'd need to render it, i would recommend doing what i said and saving the logs in chat and in a database instead
I'll try that, thanks c:
Yeah and I'm fine with rendering it, I'm not shoving it in a database.

