#development
1 messages · Page 1604 of 1
i don't know how
A bot can intercept a webhook if you know how - although I just wrote a mini express server that runs next to my bot and interacts with it
how do i do that though?
Also, another way people do it is have a 'claim' command so when people vote they get the role and you do '!claim' to do the reward
Which is much easier IMO
You still need a Webhook
""
Yeah, use it at work - what you tryin to do?
To put it simply, when I click on a specific button it redirects me to another page is it possible to interact with the second page if so how? @brazen stone
Python question:
I have a config.json setup like this
{
"traders" : {
"userid1" : "user1schannel",
"userid2" : "user2schannel"
}
}
and have:
with open('./trader.json', 'r') as cjson:
config = json.load(cjson)
traders = config["traders"]
How would I be able to do an if statement to do something if ctx.author is a user id in traders
You should just be able to run puppeteer commands on the new page IIRC - Although I believe the chromium is sandboxed by default so that might be the issue if you're loading a webpage other than one on your machine
how can I do it because to tell the truth I did some research and it speaks of scraping something that interests me not
could someone give me the docs for server votes?
the part of the code that redirects me to the other page
await Promise.all([
await page.click('#app > main > div:nth-child(2) > div > div > div > div.vote.vote-now.text-center.position-relative.mb-4.px-3.py-5 > div.h-100 > a:nth-child(2)')
])```
Not sure why it's in a promise.all with await?
You should be able to do await page.waitForSelector('...something on the new page') then after that interact with the new page
It sends a POST request to the specified URL, with an Authorization header (specified on the webhook page, you should check this) and with a JSON body
I use this as a reference when writing my tests https://github.com/checkly/puppeteer-examples/tree/25a02618f6e5a2b1f2eda9e4a3b97b6091fc6491
JSON body’s main keys are guild (server id) and user (user id)
If you don't need the channel, you can do if str(ctx.author.id) in traders, but if you do need the channel, you can do if (channel := traders.get(str(ctx.author.id))) assuming you're on python 3.8+
That's basically equivalent to
channel = traders.get(str(ctx.author.id))
if channel:
...
So basically Ill be having a list of users that will be binded to a channel.
They run a command which will be ;postalert. If the user is in the trader list, it will post the given alert to their binded channel
there are examples for how to receive webhooks. once you receive them, what to do with them is up to you. you can easily do something like client.get_channel().send()
all i see is this
mongo should be done server side only
yea
thats the right way imo
are there docs for the web version?
Just so it is there while I make the rest api
or do I just do my function inside of html instead o fjs
okay so im redoing the way this gonna work.
if str(ctx.author.id) in traders should work if my json has a list like this right:
{
"traders" : ["userID1", "userID2"],
"traderschannels" : {
"userID1" : "channelID1",
"userID2" : "channelID2"
}
}
then i will later on call traderchannels to get the channel that is linked with them
that should work right
no, that's pointless really
just keep it as it was, there's no point in tracking the keys since you can retrieve the keys in the first place.
gotcha thank. appreciate it
one more thing im running into, when im running the bot, cant seem to load the json, saying no such file
when they are in the same direcotry
which is weird because ive never seen that happen before
try printing os.listdir() and os.getcwd()
ahh working directory is my user folder
weird
Is it possible to edit messages older than 30 days? If yes whats the limit a month, a year? If no how to edit it..??? I have seen many giveaway bots editing giveaways older than 30 days.
i'm pretty sure there's no limit
if you can edit old messages in the discord client, you most likely can with bots, too
Oo thanks 😄
I was just confused cuz of the 2 week limit in message deletion i thought this has a limit too
np
I have a
on_message_delete
Event which sends a message whenever someone deletes a message but whenever the bot deletes a message it counts itself too, is there any way to fix this?
Will this work: if message.author == client.user: Return
hes using discord.py
lol
Kinda what I had in mind
Thx for the help
convert it to py version
k
don't compare the user objects... compare the ids
ohk
Anyone here have any experience with discord logins for dashboards? And making them work despite cloudflare?
d.py will compare the id for you if you compare the objects doe
Tryin to get slappey to work. Every time I copy my token it comes up as one * instead of all of them Help?
Nvm
was another issue
What do I put here? Im using replit to host
https://cdn.discordapp.com/attachments/714045415707770900/812527312930996254/unknown.png
no need for :4000
Any ideas?
ok
Im trying to stablish an webhook with Patreon but it needs an SSL certificate and now i have no ideia what to do
halp
hey umm
cloudflare does not affect it
at all
what lib you using?
in sql, query, how do i pass params for "in" something like this,
select * from table where row_number in ($2)
/ lang
Reactjs
yeah
backend...?
It seems to remove the cookies and only use cloudflares
You can go see for yourself, link in my status as for what it does
Hey so for my webhook. I just want it to send a message whenever a user votes. how would I do that with the new sdk.
And also do I need a middleware()
iam
how did you run it then?
oh
In development mode the login works fine however in production it does not
someone help
xd
Nextjs
lol
alr ur on ur own
whats the problem btw?
whats your redirect uri in prod and dev env?
Both the same
like does the auth page doesnt open at all?
Go to the link in my status and try log in
It just sends you back to the main page
if i split it up like im doing it should circumvent all problems
atleast type it out
Anyone help :/
I get unauthorized
When I go to https://top.gg/api/docs#mybots
I get {"error":"Failed to lookup view "docs" in views directory "/var/botlist/views""}
Im trying to get my token
i still dont get what your problem is, it loged me in successfully
you're not handling isAuth
? Send a screenshot
Does your avatar display at the top right
by logged me in
i mean it redirected me back to home page
nop
have you handled it tho?
It does it in development fine
Hello?
you're using the same domain name for dev also?
Doesn’t make a difference, production doesn’t work locally or on the domain (as in the log in doesn’t)
Development works on both
well, redirect uri makes a lot of difference
are you actually check if the data came back?
The redirect uri is https://vade-bot.com/auth/redirect
Yeah it does
um
you can see the logs in prod mode as well?
that's not what the redirect uri should be
Everything is fine code wise which is why I assumed it would be cloudflare
nop, cloudflare is fine
No page rules need adding?
wait, how are you handling auth?
react gang
i have my own microservices and cookies to handle auth and sessions
nextjs gang
xd
oh yeah i wanted to learn next
how would i send a message once the bot joins a server? an example is the yggdrasil bot i believe
I’m not sure, I’m not the main web dev.
lol
We have simply tried everything else
well, i'll need to see some snippets
i swear every time i hear yggdrasil i can only think of overlord
guildCreate
that ^
ah ok ill check it out
I get unauthorized in my webhook.
when I go to https://top.gg/api/docs#mybots I get {"error":"Failed to lookup view "docs" in views directory "/var/botlist/views""}
Im trying to get my token to see if it will fix my unauthorization
Ok
anyone can help with this?
setTimeout(reset, midnightTime())
function reset(){
setInterval(async function(){
var d = new Date();
var weekdays = new Array(0, 1, 2, 3, 4, 5, 6);
var today = weekdays[d.getDay()];
if(today == 0){
//weekly reset here
}
//daily reset here
}, 86400000);
}
function midnightTime() {
var midnight = new Date();
midnight.setHours( 24 );
midnight.setMinutes( 0 );
midnight.setSeconds( 0);
midnight.setMilliseconds( 0 );
return (midnight.getTime() - new Date().getTime());
}```
Does anyone spot a problem, I am not getting any errors or anything but this isn't exactly something that I can test precisely
what's the expected vs reality result?
why are you making an array with the Array constructor kek
also, Date.getDay already returns the week day from 0 to 6, so there's no need for another array

(unless you're gonna use it later tho)
what kind of bot has never been made ?
you are right -- ty for that feedback
np
how do I make a child process in nodejs and send some objects as data to the process?
Hi @restive silo (contacting you here since I couldn't in DMs nor can I see any better channels in our mutual servers), I saw https://github.com/DevYukine/Kurasuta and wanted to give it a try once, is there any suggested amount of servers I should have per cluster?
Like for sharding, it's suggested to start around 2000 - 2500 servers and one shard can have up to 2500 servers in it, is there anything like that for clusters so that like x amount of servers per cluster is good and when it crosses y, you should consider adding one more cluster?
Or does it work in a different way which I don't know about yet?
Thanks in advance
I can't answer the lib specific questions but generally clustering is done to lower load on the bot host, sharding, on the other hand, is for discord's load
so it really depends more on your bot and how you deal with events
if you require every event and do lots of operations, might want to go a bit lower. for example, censorbot (tracks most user input events) does 5 shards per cluster
bass (music bot) has 2 shards per cluster
chip does the same
I don't really know much about clusters yet but I've heard that it's possible to host the bot in multiple servers when clustering which I really want to try once since that's more better sometimes like when bot gets ratelimited with 1 hour temp ban, I could avoid having the whole bot offline, instead could just have a part of the bot offline
This seems a bit hard to understand, I don't need much events for me tbh so what would I go for a bit lower? Number of shards per cluster?
im not sure, not too familiar with kurasuta nor much clustering
iirc cf ban is 50req/s
any competent library should keep requests under that
even with shitty code
You are CREATING problems by using a json database, not circumventing anything
Yea I mean it's hard to hit that but I was talking about just in case + I could also do it better since multiple servers means more internet speed so you wouldn't have to have all requests in one server and I also want to give this a try since hosting a bot in multiple servers seems like a magic to me so I more like also want to try it out and see how it works
it doesn't make sense for many bots tho
agreed!
I still want to give it a try tbh lol. At the end of the day, it's all giving me more experience and knowledge
What is the best module to use for welcome/goodbye messages, that shows a picture with the users avatar and name in it?
canvas 
canvas
ok cool, thanks 🙂
bit of a learning curve
yeah
yes you can

could i get some very small help
random parts of my python file keep disappearing
ctrl z or ctrl y dont bring it back
cache
yep
explain closed?
I am sorry I don’t know, was it on and working before
like offline or doesnt respond to commands
Well he says no error in code so probably is offline
So it’s offline now right
Idrk what could be causing this but perhaps someone else might help u
are you sure there are no errors?
why Ping ok?
ok. did you updated your discord token after regenerating it
why did you have an express server running that just pings stuff?
did you pasted the code into your bot?
you really should 1) get a proper host 2) learn js properly before hopping into bot development -> pins
Hi
hello
can i get the reason for kick from the guildDelete event?
client.on('guildDelete', async (guild) => {});
the guild object doesn;t have a reason field
dang, i'm still looking around.
The reason is only for audit logs iirc
yeah, i'm not having any luck finding it
Either the guild was deleted or the bot was kicked/banned/integration removed
ohh
my bot was integration removed
my bot detected as kick but it still can acsess the guild
can I share a package I made ?
Hey so
I made some stuff in html
I need to use nodejs with html as well to do some stuff
Any way how can I do that
:\
lmao
how u define dynamic like
Like content taken from a database
or which changes based on user input
or discord login
it does change at user input
like ?
i found this https://www.digitalocean.com/community/tutorials/how-to-use-ejs-to-template-your-node-application
I think it will help me
or learn React and build a nice app with it
yeah thats fine
It's basically voice-based AI chatbot
I tried learning react
not an easy task

i know but quite powerful and probably make some of the best looking stuff out there
use ejs if you know how to integrat your voice ai
I will learn it after I am done with my finals
ok mine r starting from 1st
yes
same
mine where finished like 4ish years ago
add me @delicate shore
👍
wait this where my 2nd finals, the first ones are about 8 years ago
wait you know royal gamer ? @delicate shore
ok lol
lol
let menumsg = await message.channel.createMessage({embed: menu})
.then(msg => {
console.log("here1")
message.channel.awaitMessages(test => test.author.id == acted.id && reqmet.includes(parseInt(test.content.trim())), {maxMatches: 1, time: 60000}).then(spmove => {
console.log("here2")
menumsg.delete().catch(err => {console.error(err)});
spmove[0].delete().catch(err => {console.error(err)});
console.log("here3");
}
}
``` Can someone help me here? The function terminates at one of the .delete()s and console.log("here3") is never reached.
oof - u r using djs11 code in djs12
also there are no errors
instead of createMessage use send
no, im using eris with eris-additions
than idk
nvm i fixed it somehow
Lol i never saw someone use {} that otfen kn python
Or am i just retarded
i just use {} to make my code more easily readable, also thats javascript
but this will just give a boolean?
Hey @earnest phoenix mind if i ask you something about repl.it? Is the hacker plan good so far? Does the bot stays 24/7 or does it unexpectedly resets still?
Thats some advertisement tracker
Lol noticed but "await" made my brain go BRRRR
find returns an element, some returns boolean
yes, lol tried it out, thx
When I eval number hi tho
It does null
And it is still false even when I do === NaN
It's only correct when I do !Number('hi')

¯_(ツ)_/¯
you check if something is nan with the isNaN function
NaN === NaN is false because maybe behind the scenes it compares 2 different instancees of NaN, that should be the only reasonable explanation
!Number("hi") returns true because NaN is a truthy value
Interesting 
It returns NaN
NaN is actually a falsey value, I thought it was truthy
Do you JSON.stringify the output
maybe
yeah
const NaN = Symbol("NaN");
if (Number("hi") === NaN) ...
oh
anyone any good at computer science?
well if you use a flask server with a monitor stays 24/7 without hacker plan but I know how you can get 1 year of hacker plan free
@cinder patio do you know what the proper name for "externalising a function" ?
not refactor
what do you mean by externalising?
make it external
taking afunction
and exporting it on another file
and requiring on the intial one
to clean it up
how can i send text as a file?
.send({files:[{attachment: "text here", name: "file.txt"}]})
that says app/text here is not a file or directory
maybe try .send({files:[{attachment: Buffer.from("text here"), name: "file.txt"}]})
yes that should work
yay thanks guys
can someone help me with playing my spotify playlist when i type in the commands it gives me an error
What error
15
let me see if i can post it
Invalid command
Undefined argument 'super' on command 'play'.
$spotify $list $super playlis
^
Failed at: 15
Is this not supposed to be an argument? Botify interpreted it as one because it started with the argument prefix ('$' or your custom argument prefix defined with the property command). If this was a mistake and the argument prefix is supposed to be part of the command input you can escape the prefix by putting a \ in front of it. E.g. play $spotify $trackname.
I could be wrong but i think It's the blank space between super and playlist
Try using _ and replace everything properly
Oh wait
Undefined argument 'superplaylist' on command 'play'.
$spotify $list $superplaylist
^
Failed at: 15
Is this not supposed to be an argument? Botify interpreted it as one because it started with the argument prefix ('$' or your custom argument prefix defined with the property command). If this was a mistake and the argument prefix is supposed to be part of the command input you can escape the prefix by putting a \ in front of it. E.g. play $spotify $trackname.
Can you send the code
Ye, for the command that's giving an error
oh trying to play my spotify playlist
english
coding lang
K u mest be memeing
im not using any coding
no the BOtify bot
go complain to the bot developer, this is not a support channel for bots
they told me to come here
@earnest phoenix I did hosted by discord bot in the same manner using flask server and uptime robot. Though it wasn't as smooth as expected and free repl server unexpectedly reboots itself every often in a one day. It was fine enough to host if the problems you face doesnt matter to you.
Yeah i dont mind hacker plan free or not, I just want to know if Hacker plan repls truly stays uptime 24/7.
sorry
that pricing is such a scam lol
you can probably find a provider with the same specs for 3 or 4 bucks cheaper
i.e. scaleway
well ifk but I don't have that problem
oh okay then
? are you talking about Repl.it? lol
yes
is posible to read the attachment file without downloading it localy?
download it to your memory
✨ buffers ✨ (on js)
ok
can you explain how?
varies from language to language
you need to fetch the attachment url but yes
and then how do i read it?
So i am making a join command but whenever I do bw.join then specify a channel it doesn't work. Any ideas why?
@client.command()
async def join(ctx, channel):
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name=channel)
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
await voiceChannel.connect()```
and is there anyway i can like
make it so it connects to the channel I am in?
This is in discord.py
Yeah it's expensive imo, I've shifted to aws and it's pretty good ngl
nice
Go to top.gg site and on the side bar click on "Add Bot"
Hey i have a problem with a bot , i cant vote im log in top.gg but i dont see the vote section
@bot.command()
async def join(ctx):
channel = ctx.message.author.voice.channel
await channel.connect()
Of course you need to handle in case the user is not in any vc
First, think that's a matter for #support, not development
Second, i guess it's a known issue, check #site-status
Ok thanks
holy shit!
I just got a message that i had to start a discord verification process. Does it require a picture of my id/passport? The problem is, i am under 18 (currently 17 years old). Will that be an issue?
Yes it does
Congrats on the 75 servers mark
And I don't know about the underage thing, sorry
But i don't think It's mandatory to be over 18
no
wait nvm
i thought you said it is mandatory
i need to dowload an attachment and then read it without storing it localy, someone knows?
It does require an ID, yeah. But I'm pretty sure it's fine if you're 17. It's just so that if your bot gets hacked and does some sketchy shit, Discord won't get sued for it.
what do you want to do with it?
i need to Dowload the file ( but not localy ) -> Read the content and check if its valid -> Store it on a DB
what type of file is it?
i have all already done but storing the file localy, and i cant do that
its a js file
It's python's lib for libsodium. Basically used for encryption, decryption, password hashing etc.
You can read more about it here https://github.com/jedisct1/libsodium
which library are you using for downloading?
why tf would I need it
i was downloading it with ```js
request.get(url)
.on('error', console.error)
.pipe(fs.createWriteStream(./rawConfigs/${message.guild.id}.js));
the request library?
that library hasnt been updated in 2 years and is currently abandoned, so i'd suggest using a different one
@quartz kindle edited the lib
anyway if you dont want to, its possible to still do it on it
I'm not sure to be honest, but it's needed to join voice channels, yeah.
popular libraries include: node-fetch, got, axios, superfetch, bent, undici, and many more
so i just like install it?
hey tim, i changed the image but it still doesn't work?
and i'm done?
It still doesn't show the background
what are you using to display it?
hmm, and how do i donwload a file not localy and then read it with node fetch??
python3 -m pip install -U discord.py[voice]
You can run this to make sure it's installed
ok
what
there request npms
if your downloading it you should use a file reader
i cant modify my vps and i need to dowload and read the file without it being stored localy
well
http libraries can download in several ways, you dont need to save files
instead of creating file streams, read the response as a buffer or as text
all libraries can do that
example from node-fetch
wait fuck
FUCK
I'm a moron LMFAO
You familiar with how hex numbers are in ASM?
That was the answer here, hex number
gg
I don't have that option ... in fact, I can't log in, the site asks for permission and I accept, but I still don't stay logged in ... is it being maintained or do I have to accept another permission?
I'm gettin g this error after I took my bot from my VPS since I switched PC's I did "npm install" and now i get this error:
did you copy the node_modules folder?
do npm rebuild
const response = [
`**Output:** \`\`\`js\n${this.clean(inspect(evaled, { depth: 0 }))}\n\`\`\``,
`**Type:** \`\`\`ts\n${new Type(evaled).is}\n\`\`\``,
`**Time Taken:** \`\`\`${(((stop[0] * 1e9) + stop[1])) / 1e6}ms \`\`\``
];
(node:3768) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function
ths
try npm rebuild --build-from-source
what it identified at?
is it like
this.clean = string/function
try npm rebuild sqlite3 --build-from-source
?
No one help me 
sigh...
you sent it twice
then do npm i -g node-pre-gyp
bro
which library are you using?
yup working now
Oh
Sorry, wrong code! 🤦♂️
try {
...
} catch (err) {
return message.channel.send(`Error: \`\`\`xl\n${this.clean(err)}\n\`\`\``);
}
This one errors.
still what is it identified as?
What do you exactly mean.
Oop
client.on("guildCreate", guild => {
// code here runs when your bot joins a new guild
})
im amazed luca didnt yoink that
like this ```js
this.client = require('./settings.json')
thats an identified
Hol up lemme fix that
identifier*
where does this.clean come from?
Thnx
what is this.clean?
Oh, but I never defined anything like that as I never use this.client as an example, is there a way I can use bot. instead?
lol
nono
thats where i get it from
you use this clean
i was showing an example of what to look for
where did you create the clean function?

async def invite(ctx):
await ctx.message.delete()
url = url.request("*link*")```
and getting the error of
```File "C:\Users\beast\Desktop\Windex.py", line 111, in invite
url = url.request("*insert my website here*")
UnboundLocalError: local variable 'url' referenced before assignment
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\beast\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\beast\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\beast\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'url' referenced before assignment
How do I make it like
open the url
@slender thistle WE GOT A PY USER
you're trying to use url before you create it
you cannot do a = a.b because a doesnt exist
True true
you have to do a = something else, not a
I don't think I made a function named as clean
then who did? why is there a clean function there?
I'm just tryna figure out how to make an api request, man, that's all
I just followed an !eval tutorial just to know how it basically works, but I don't think I made a function called clean
well the tutorial probably did
and you skipped it
clean is not a built-in function
Mans got hacked then someone made "clean" as a function to fuck his code up
Yes, that.
this is probably what it is
oh
why type it as any if it can only be used for text?
shhh
dw erwin
So how do I make an API request for it, Idk the code for it
your still my number 1 for simping
You know how I can fix the error?
I just found this video, and it's really cool:
https://youtu.be/W2Z7fbCLSTw
Learn about seven different database paradigms and what they do best. https://fireship.io/lessons/top-seven-database-paradigms/
00:00 Intro
00:45 Key-value
01:48 Wide Column
02:47 Document
04:05 Relational
06:21 Graph
07:22 Search Engine
08:27 Multi-model
#learntocode #data
Learn more about MeiliSearch https://fireship.io/lessons/meilisearch-...
😮
define clean then
(node:1360) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function
told you
clean(text: string) {
if (typeof text === 'string')
return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
else return text;
}```
there
spoonfed
erwin bad
lul
use aiohttp for HTTP requests in discord.py bots or anything asynchronous

its the same from the guide they were supposedly copying from
they just skipped it
also was in the pic i sent, was only gonna make them manually copy it
clean(text) {
if(typeof text === 'string') {
text = text
.replace(/`/g, `\`${String.fromCharCode(8203)}`)
.replace(/@/g, `@${String.fromCharCode(8203)}`)
}
return text;
}
``` It's like this..
what about API requests? Like a weather API or a Time / Date API
I didn't skip it.
though now that i think about it, that make sure they understood what it does
where did you put that in then?
API requests are HTTP requests
Ohhh
Outside the run function
Shhh I'm retarded lol
No problem
(it doesnt, but its easier to explain this way)
Oh, then what can I use instead?
just define the function and call it inside
you CAN call stuff from outseife the module.export
or whatever
as long as they are in the same file
just dont use ``this` keyword unless you are in an object
(again, doesnt work like that, but for the sake of explaining, im referring to it as that)
in your case, it does work like that, but this is a very confusing thing to get a hold of
basically
I am not willing to use this so what can I use instead?
Js scopes r v weird in places
module.exports = {
a:() => {};
b:() => {
this.a()
}
}
``` this is valid
this refers to the module exports in this case
this is very confusing, i'd avoid using it if i were you
you basically DONT use this
you call the function as is
like you would normally
Why i cant login for vote ?
const { MessageEmbed, MessageAttachment } = require("discord.js");
const { red, cyan } = require("../../other/colors.json");
const { Type } = require("@extreme_hero/deeptype");
module.exports = {
config: {
name: "eval",
aliases: ['ev'],
usage: "!eval",
category: "owner",
description: "Evalues a command!",
noalias: "No Aliases",
accessableby: "Attitude Developers"
},
run: async (bot, message, args) => {
// My code here...
},
clean(text) {
if(typeof text === 'string') {
text = text
.replace(/`/g, `\`${String.fromCharCode(8203)}`)
.replace(/@/g, `@${String.fromCharCode(8203)}`)
.replace(new RegExp(process.env.TOKEN, 'gi'), '****')
}
return text;
}
};
Ok, I did it like that, so?
I understood that.
Ok.
in your case using this is valid
otherwise
const { MessageEmbed, MessageAttachment } = require("discord.js");
const { red, cyan } = require("../../other/colors.json");
const { Type } = require("@extreme_hero/deeptype");
function clean(text) {
if(typeof text === 'string') {
text = text
.replace(/`/g, `\`${String.fromCharCode(8203)}`)
.replace(/@/g, `@${String.fromCharCode(8203)}`)
.replace(new RegExp(process.env.TOKEN, 'gi'), '****')
}
return text;
}
module.exports = {
config: {
name: "eval",
aliases: ['ev'],
usage: "!eval",
category: "owner",
description: "Evalues a command!",
noalias: "No Aliases",
accessableby: "Attitude Developers"
},
run: async (bot, message, args) => {
clean()
// My code here...
},
};
this is also valid
PS: too lazy to go format that, deal with it
K!
hey @quartz kindle are you here?
am i?
what does it do
Hm, but with yours that I am using, it yet errors.
it's really useless
this.clean is not a function
show ur current code + the error
have you ever wanted to RANDOMLy wanted to use js in the middle of your ts code?
or maybe the other way arounD
yes, thats what eval() from utils is for
well
or require()
not you dont need another file
This is the code as it is.
then you didnt save it
The error is this.
Discord.Boats, successfully posted your server count.
(node:10824) UnhandledPromiseRejectionWarning: TypeError: this.clean is not a function
at Object.run (C:\Users\hajji\Desktop\Attitude Database\src\commands\owner\eval.js:61:66)
at module.exports (C:\Users\hajji\Desktop\Attitude Database\src\events\guild\message.js:35:33)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:10824) 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:10824) [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.
Basically meaning that this is erroring
} catch (err) {
return message.channel.send(`Error: \`\`\`xl\n${this.clean(err)}\n\`\`\``);
}
it also has a chance to fail 30% of the time due to mixing good lib with shitty one
this.clean is not a function
guess what?
in the code i sent you
there no this.clean
lol
It's only clean(), not this.clean
so whatever you did, its on you
i told them what was wrong
🤦♂️
lmfao
lmao
i said
there is no this.clean
unless you add a this.clean and put your clean behind it then they said
"what"
i explained BOTH so they would understand both methods
i even sent a damn example
both would work, not mixed
this clean = clean()
this is valid
they said and i quote
so is this
"no"
if you dont understand what this means, dont use it
we're just repeating ourselves by this point
this.
#development message
This is what I am trying to do, I am trying to remove all the this from all the code.
One second.
const response = [
`**Output:** \`\`\`js\n${this.clean(inspect(evaled, { depth: 0 }))}\n\`\`\``,
`**Type:** \`\`\`ts\n${new Type(evaled).is}\n\`\`\``,
`**Time Taken:** \`\`\`${(((stop[0] * 1e9) + stop[1])) / 1e6}ms \`\`\``
];
I also have this this.
Should I remove it as well?
You should read up on this and decide for yourself
To https://github.com/ChickenDevv/MMBot.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/ChickenDevv/MMBot.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
What do I do here?
I did git push origin main
It tells you
but I dont wanna pull
Then you cant push
This is the whole point of version control
So shit cant get mixed and overriden
Object.defineProperty(this, "is", {value: {not: { how: { it: { works: false } } } }});
this.is.not.how.it.works;
this.is = {not: { how: { it: { works: false } } } }; also works
I am back and i have another question. So whenever i wanna play a song with this code it doesn't work and gives the error TypeError: 'NoneType' object is not subscriptable. Can someone help me fix this??
@bot.command()
async def play(ctx, *, url):
player = music.get_player(guild_id=ctx.guild.id)
if not player:
player = music.create_player(ctx, ffmpeg_error_betterfix=True)
if not ctx.voice_client.is_playing():
await player.queue(url, search=True)
song = await player.play()
await ctx.send(f"Playing {song.name}")
else:
song = await player.queue(url, search=True)
await ctx.send(f"Queued {song.name}")```
does it show which line the error ocurred?
can u do a favor and write print(player) right before that line
and send here what it returns
ok
so?
it returns nothing
ye thats about right
ur music.get_player is not finding the guild by id
try replacing ctx.guild.id by ctx.message.guild.id
if not (voice and voice.is_connected()):
voice = await channel.connect()
if not (voice.is_playing() or voice.is_paused()):
try:
voice.play(discord.FFmpegPCMAudio(queues[guild_id][0][1], **FFMPEG_OPTIONS),
after=lambda e: self.play_next(ctx, guild_id))
while voice.is_playing() or voice.is_paused():
await asyncio.sleep(5)
await voice.disconnect()
except discord.errors.ClientException:
pass
this is my functioning play command
no
kek
just a sec
this is the proper indent
cause i couldnt fix it on discord formatting lol
oh btw
voice = discord.utils.get(self.client.voice_clients, guild=ctx.guild)
ok
oh thats in cog format
this is a regular file
some variables u will need to replace by your own code's context
u need to download ffmpeg with pip as well, i forgot about that
and there's also this that i also forgot
FFMPEG_OPTIONS = {
'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
'options': '-vn'
}
ah-
and i also forgot this:
def play_next(self, ctx, gid):
"""
Plays next song when current finishes.
"""
voice = discord.utils.get(self.client.voice_clients, guild=ctx.guild)
if len(queues[gid]) > 1:
del queues[gid][0]
try:
voice.play(discord.FFmpegPCMAudio(queues[gid][0][1], **FFMPEG_OPTIONS),
after=lambda e: self.play_next(ctx, gid))
voice.is_playing()
except AttributeError:
pass
else:
del queues[gid]
damn i forgot a lot of things
lol
this is for connecting ur bot to the vc and playing the song if something isnt already playing
this is the audio config with ffmpeg, do "pip install ffmpeg" in ur cmd
this is a function to automatically play the next song when one is finished or skipped
just be sure to remove all "self." and change the variables that u r using with different names
also, the queues variable im using is for the bot being able to play on multiple servers without one interrupting others, its a dictionary
so
I'm making this API with express to communicate between 2 files but i get this error: Only absolute URLs are supported
fetch(`127.0.0.1/users/259776081316282368`)
.then(response => response.json())
.then(data => {
console.log(data.uuid);
})
how would I fix this?
why are you looking for url's
https://
FetchError: request to https://127.0.0.1/users/259776081316282368 failed, reason: connect ECONNREFUSED 127.0.0.1:443

is it not up yet?
try http://
same error
if that doesnt work its your port
no it definitly works in the browser
^^
atually*
I forgot the port
bruhg
now it works
H @opal plank see im smort
finally
still how do you make a commmand in js again
do you need one?
so like
i just forgot how to make one
how do you plan to get commands
so a command handler 
you dont need a cmd handler for commands lol
the normal way
yes
idk many bots which don't use a command handler
why should you not
im not talking about cmd handlers
a command handler lets you dynamically create commands without having to check every single time for the prefix
how the hell do i make a damn command
that's up to you
H
it can be as simple as an object
depends on how you do you comand handler
import { CommandOptions } from 'discord-rose/dist/typings/lib';
export default {
name: 'Berry',
usage: 'stinky',
description: 'Berry is stinky.',
category: 'misc',
command: 'stinky',
permissions: [],
botPermissions: [],
owner: false,
exec: async (ctx) => {
ctx.reply(`@slim heart`);
}
} as CommandOptions;
my commands
const helloCommand = {
name: 'hello',
description: 'Says hello dumbass',
async execute(message, args) {
await message.channel.send('Hello');
}
}
this is a basic example
wait you're moon
I don't understand
understandable have a nice day
explain wtf
not that i understand
no
but i tried convincing them long ago
I swear
Do you use the message event directly for commands
y e s
wtf cringe
this guy makes the whole bot in a single giant index.js
actually
you do permissions checks on each command?
This is top tier programming
i d c
lmfao
ok well comand handlers basically just call a shit load of find functions then run the shit
i already know how a cmd handler works
so do a giant switch/case
million.
ezpz
Million
in having yandere dev flashbacks
is moon secretly yandere dev
H
you said you weren't using command handlers
:painsive:
Wait
so just switch/case the commands and do shit in index
Is this what u want:
a command


