#development
1 messages · Page 2018 of 1
they'll make it privileged
only affecting varified bots?
but even then if a bot already uses normal commands and cant function on /comands what will they do then?
cuz they cant humanly just go "lol sucks to suck"
For the Web Dyno,
I can enable a web dyno with heroku ps:scale web=1 as I have a few available, but I need a web process type configured in my Procfile. I did have it as web: python bot.py, mimicing the worker process type I have for my bot. While the web dyno did spin up with no errors, once I sent a test vote request it crashed.
Do I need to configure flask or something to listen for the Post request on my bot, or do I need to build a Web solution in node to listen for the request?
every bot
you'll have to switch to slash command
they gave you a year and a half
yeah but non varified you can just activate the intent manually on non varifed
that sucks tbh
but then thats what hapens when you give literally any bot the ability to see every message in every channel in every server its in
kinda sad they didnt make it "secure" from the get go rather than having a rethink like half a decade later
personally i hope they come up with something better or just make /comands more usable cuz last time i tryed getting into that stuff it just felt like some redneck half-assed workaround bolted on the side
and now even more?! thought they expanded the deadline
so i got this code and i want to see if the dino varible is not inside the arr array but whatever i do everything passes or nothing does ```js
let ifBreed = [
{ "dinos": ["giga", "mosa", "pt"] },
{ "dinos": ["theri", "mana"] },
{ "dinos": ["rex", "tuso"] }
]
let dino = "h";
for (let x = 0; x < ifBreed.length; x++) {
for (let y = 0; y < ifBreed[x].dinos.length; y++) {
if (!ifBreed[x].dinos[y] === dino) return console.log(${dino} is not getting breed)
}
}```
You should use !== instead of !... === ...
Though keep in mind that it'll immediately return if the current inner iteration passes, which I'm not sure is what you actually want.
if its the dino variable is not in the array i dont want it to continue
then nothing comes through
That's because both of your loops stop at the first wrong dyno name
so you don't want to return
function isDynoInArr(dino, ifBreed) {
for (let x = 0; x < ifBreed.length; x++) {
for (let y = 0; y < ifBreed[x].dinos.length; y++) {
if (ifBreed[x].dinos[y] === dino) return true;
}
}
return false;
}
Then just use that function instead
or you could use a variable but in this case function's a lot better
when u do !something === ... you actually changed the datatype to boolean and compared to another thing that was also boolean-casted (true if null, false otherwise)
but when u do something !== ... you're checking equality (true if not equals, false otherwise)
i got more code after so i cant return true
also the way u structured it is quite inefficient
if all keys are the same, just use an array
let ifBreed = [
["giga", "mosa", "pt"],
["theri", "mana"],
["rex", "tuso"]
]
it also has other information so i wanted to keep it basic
shouldn't u be using objects then?
actual objects I mean, instead of anonymous (as in, classes)
this is the whole thing json [{ "_id": { "$oid": "6248817a243b8d326c6d3eb2" }, "guildID": "494567290990493696", "userID": "330064750862139393", "dinos": ["giga", "mosa", "pt"] }, { "_id": { "$oid": "624881da243b8d326c6d3eb3" }, "guildID": "494567290990493696", "userID": "491298338784673817", "dinos": ["theri", "mana"] }, { "_id": { "$oid": "6248820f243b8d326c6d3eb4" }, "guildID": "494567290990493696", "userID": "811586423933108254", "dinos": ["rex", "tuso"] }, { "_id": { "$oid": "62489fd660e500b13afd2374" }, "guildID": "494567290990493696", "userID": "836670704120365087", "dinos": [], "__v": { "$numberInt": "0" } } ]
ah, mongo
have u considered using sql? (since you're dealing with relational data on a non-relational database)
for your current case, you can use includes to check if the dino is in array
obj.dinos.includes(otherDino)
that worked, thank u very much
yw
What kind of discord bot payment integrations exist
preferably one where you redirect the user to a secure environment like a website run on a browser and not one where they enter their credit card number in dms
what non-phishing bot is asking you to send your credit card information in dms
bad ones
imagine how many people sent their credit card info through mail at the dawn of CCs
can't imagine since I've never seen that
The one without limit I guess
though I do see people emailing themselves regularly
oh
amazon forest isn't gone yet
this is a real company in 2022
you have to send them an email or a letter in the mail, with the above fields filled up
seems safe
Probably more save than entering your data on a suspicious Russian phishing site sharing your data with 10000 other evil platforms immediately
dayum i just saw the april 30 deadline has been extended by 4 months
idk
I still havent 👀
yeah lmao
i really need the date picker and variadic thing
i can do without, but it will be so much better with it
and I need a way to set multiple signatures for a single command
thats what subs and groups are for no?
but its kinda awkward to work with, i also need that
/a date time options
/a name time options
/a name date options
/a date date options
etc.... lol
in theory yes, but they are very limited and awkward af
it would be good to have for example "one of option1 option2 option3 is required"
I'm more for "if A is supplied then B is required"
like /cmd [optA optB] optC
where [] is a param group
Once you managed to setup anything without it, they will introduce those field types, I would bet
i kinda already did the variadic thing
didnt do the date picker yet
I wonder if discord even works on basic things like other field types or … hey hey where’s actually the promised sub command grouping?

Guess we will see more trash coming in the future instead of working on the basic features lot of people could use as they have to switch to application commands anyways
Being tired of repeating myself for one year now
lel
guys plz help
i am losing it
yeah os dev that doesnt know how to use the linux file system hahahahahahhaha shut up
anyways
this is supposed to print the phrase "hello w"
but it only prints "hello"
also tried printing the whole file
(my next step is interacting with the file in raw binary btw)
c++ btw
or c btw
yea found that out
stupid design but wont judge
now im confused why opening a file in read and write mode clears the original contents
static char* readFile(const char* path) {
FILE* file = fopen(path, "rb");
fseek(file, 0L, SEEK_END);
size_t fileSize = ftell(file);
rewind(file);
char* buffer = (char*)malloc(fileSize + 1);
size_t bytesRead = fread(buffer, sizeof(char), fileSize, file);
buffer[bytesRead] = '\0';
fclose(file);
return buffer;
}
``` might be useful to you
Didn’t write that btw, got it from a website
what is that cryptic text in the tree branches lmao
ah
i'll really be making use of binary mode
if i understand what it does correctly
nevermind i have no idea
append at app end
thank you very much thats useful
now i know you can seek to positions
which is vital to my project
so im guessing i'd really just use r+ mode (read and write)
for random access and storage of data
not strings but bytes
ah binary mode is for non ascii data
does anyone
know
how to execute a function only once?
I want ChooseSound to be executed only once
make a boolean
but the Update method, is like a for loop
and when the method runs make it true
what do I do if I wanna restart those booleans
wdym
both of those will constantly switch
from chase to idle
but the boolean trick will work only once
no idea then
ikr 😭 what do I do
tim probably knows
maybe, he's smart
indeed
idle = false
if(idle) { chase; idle = false; }
if(!idle) { idle; idle = true; }
mind blowing
as long as idle is outside of the update function
just wondering, i want to use buttons for polls and giveaways would this mean i have to store every button press in a DB? or is there a better way to do this?
you can store data inside the button's unique id
it's not :/
then put it outside
i mean like a user that voted in a poll
then put it outside
then how do I make it play again if it's outside update
yeah you probably need a database
how do you call update?
so reactions are still best for polls and giveaways if I dont want to store it in a DB 😢
it's like for loop for c# Update is called every millisecond
is it actually impossible to do that?
it is outside the update function
thats what i said will work
oh I thought you mean the first if statement
i meant the bool variable
they're different, the second one lacks the !
how?
oof, this is an issue
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
this is definitely not good
I think he was giving you pseudocode
if(!playerInAttachRange && !isPlayingJumpscareAnim) {
if(playerInSightRange) {
ChasePlayer();
} else {
Patroling();
}
ChoseSound(idle ? SoundManager.playingIdle : SoundManager.playingChase);
idle = !idle;
}
I want to do 2d unity but I'm too lazy to learn unity
I think my knowledge of C# is good enough to do it though
c# is fairly similar to javascript, if you know this language it won't take you long to learn it
I already know C# pretty well
It’s not C# that’s the problem, it’s learning Unity/game dev and learning how to structure a game “properly”
ah, that took me quite a bit to learn properly
gayme
maybe because I started off big, normally you'd supposed to make UI based games, then 2D games and lastly, 3D games
I went straight to 3D
I tried to get into 2d game dev but I got bored of the low level stuff with C++ and SDL
@quartz kindle lol I suppose it works in switching between the statements but it still executes every time update is called
I'm saying it's impossible
physically cannot do this
it's more fun to develop games with Unity, trust me
just the plain interface is what makes it more enjoyable
then what do you want to do?
suppose you have a infinite function like so
setInterval(() => {
if (statement) {
//execute only once, then wait til you need to be executed again.
}
if (!statement) {
//execute only once, then wait til you need to be executed again.
}
}, 1);
it's simple to do it with one if statement
it's just one bool
but if you have to constantly switch between the if statements
what defines when it will be needed again?
it's impossible
playerInSightRange = Physics.CheckSphere(transform.position, sightRange, whatIsPlayer);
playerInAttackRange = Physics.CheckSphere(transform.position, attackRange, whatIsPlayer);
this
both of those are bools
but if statement is true then it goes constantly
same with !statement
i still dont get what you're trying to do
you want ChoseSound to be called when?
the first time the if statement is called, the if statement will keep getting called, but ChooseSound only executes once
same with the second if statement
damn, wanna try unity game dev again but my shitty mac cant even run unity properly
excuses, I get less than 30 fps on some of my projects yet I don't complain
so you want to call Patroling only if not already patrolling is that it?
no, patrolling is being called always
only choosesounds is called once
bro i get like 15 fps just 2d project with 2 sprites wdym
okay well
that's a little bit low
tf do i supposed to test the movement
that's why I hate apple though
so only call ChoseSound(idle) if not already playing idle
I can't detect it
oh actually it might work now that I think about it
just give me a couple seconds to verifty
if(!playerInAttachRange && !isPlayingJumpscareAnim) {
play = false;
if(playerInSightRange) {
ChasePlayer();
if(idle) {
idle = false;
play = true;
}
} else {
Patroling();
if(!idle) {
idle = true;
play = true;
}
}
if(play) {
ChoseSound(idle ? SoundManager.playingIdle : SoundManager.playingChase);
}
}
well its not always 15 fps but when it happens it just destroys my mood and made me quit testing
@ancient novais this what you want?
not sure
I'll test it
cause my brain is melting and I can't run the code in my head
should play be in update?
yes play can be inside update
then it doesn't seem to work
this is so weird
can you maybe do this? @quartz kindle ```cs
// both of these if statements are called in Update() meaning they will constantly be called, as if it were an infinite loop.
//is called if everything is false
if (!playerInSightRange && !playerInAttackRange && !isPlayingJumpscareAnim) {
Patroling(); //<- will be called everytime the if statement is called
ChooseSound(SoundManager.playingIdle); //<- make this be called only once, until the second if statement is called.
}
//is called if everything is false, but playerInSightRange is true.
if (playerInSightRange && !playerInAttackRange && !isPlayingJumpscareAnim) {
ChasePlayer(); //<- will be called everytime the if statement is called
ChooseSound(SoundManager.playingChase); //<- make this be called only once, until the first if statement is called.
}
thats exactly what i did
yeah but it doesn't seem to work
no sound is playing whatsoever
meaning nothing executes
Any idea why this is showing wrong?
well, show the code you actually did
it uses a different format
seconds
oh my bad
if(!playerInAttackRange && !isPlayingJumpscareAnim) {
play = false;
if(playerInSightRange) {
ChasePlayer();
if(idle != false) {
idle = false;
play = true;
}
} else {
Patroling();
if(idle != true) {
idle = true;
play = true;
}
}
if(play) {
ChooseSound(idle ? SoundManager.playingIdle : SoundManager.playingChase);
}
}```
left it almost exactly the same
can you create variables in c# without defining them?
like dont you need something like bool play = false or var or whatever?
I do
private bool name = state;
I define them outside of the function
play = false overrides it
show the entire class
do you want the entire code?
yes
it's not really that long
okay give me a second
@quartz kindle https://pastebin.com/58MJhDuf sorry it took me a second
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.
it should work, the only problem i see is that patrolling will not play until you chase once, because idle is initialized as false
can you initialize a boolean as null or undefined/unset in c#?
are these sounds played in a loop?
or do they have a specific duration?
can set it to null
if they have a specific duration, you need an additional variable to check if its currently playing something or not
there isn't anything specified as undefined, but null could work
if (!AmbientSounds.isPlaying)
this is how you'd check if the music is playing
then you can get rid of the idle variable altogether
can you do it and send the code back?
lol
i solved thanks
🥣
if(!playerInAttackRange && !isPlayingJumpscareAnim) {
if(playerInSightRange) {
ChasePlayer();
if(!AmbientSounds.isPlaying) {
ChooseSound(SoundManager.playingChase);
}
} else {
Patroling();
if(!AmbientSounds.isPlaying) {
ChooseSound(SoundManager.playingIdle);
}
}
}
``` this is literally all you had to do since the beginning lol
it's important to take breaks to fight burnout
since you have a way to check if something is playing or not
really bruh
wait but what if I want it to change abruptly
can you check which one is playing?
I think so, let me check the docs real quick
if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle) { hooseSound(SoundManager.playingIdle); }
yeah it might be something like this
actually no
wait
I'm at a dilema cause normally you'd use that to set a clip not check for it
what type is AmbientIdle?
if(AudioSource.clip == clipToTest && AudioSource.isPlaying) { ... }
yeah so that's what I got from the docs
you can use it like this
ambientidle is an audiosource
so yeah, just invert the if
you want to check if its not playing, or if its not playing the right clip
should I use &&?
if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle)
gotcha
if(!playerInAttackRange && !isPlayingJumpscareAnim) {
if(playerInSightRange) {
ChasePlayer();
if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientIdle) {
ChooseSound(SoundManager.playingChase);
}
} else {
Patroling();
if(!AmbientSounds.isPlaying || AmbientSounds.clip != AmbientChase) {
ChooseSound(SoundManager.playingIdle);
}
}
}
let's hope this works
my bad thought you set them like that on purpose so didn't change
@quartz kindle holy shit I think it actually worked
thanks
I couldn't have done this without you
it's awesome how you always manage to help me even if I use an entirely different language lmao
most of the logic is the same in all langs
yeah, but still, some of the functions are different
Holy that's hard to read
you're hard to read
dang it now I'm stuck on this
incrementValue += Time.deltaTime * 0.5f;
float result = Mathf.Lerp(1,0,incrementValue);
this.transform.position = Vector3.Lerp(initialValue, PlayerFace.transform.position + (1.5f * PlayerFace.transform.forward), result);
the player ends up going below the this object
Wouldn't it be better to use double? Since you're dealing with position
unity works more with floats iirc
Using zlib and NodeJS, how would I extract the contents of a .7z, .tar, etc. archive to a folder?
Can't u pass the file through tar command?
tar -xtract ze files
Now u never forget
not with zlib alone
Ah ic. Thank you I'll look into child processes and alternatives.
Call tar from the main process
Idk abt node, but in java you can even wait for a result
I don't think you can execute another process within the main process. It would have to be done with a child process
unless you mean spawn under main process as a child process of main
Any reason this error could be popping up?
I am trying to use mongoose to put store a document, but just keep getting this
your connection is probably too slow
gotcha
lemme try something rq
Tried to run it outside of my VM and still got the same error
i found this on stack https://stackoverflow.com/questions/65090440/how-to-solve-mongoose-v5-11-0-model-find-error-operation-products-find-bu probably solution to ur problem
Already took a look at this and tried everything, no luck
const connectToDb = async () => {
await mongo().then(async (mongoose:any) => {
try {
console.log('Connected to DB')
} finally {
mongoose.connection.close()
}
})
}
await connectToDb()```
this worked, up until just recently
like, I was adding things to the db just fine about an hour ago
why do you close the connection immediately?
shit
lol
you imported discord while already imported discord
looks like copy-paste codes
overview
that's what hit my eyes first
the 1st line of async run
you could just Discord.MessageEmbed
why not most of the time?
names are case sensitive
if you named it Discord, then its Discord.MessageEmbed, not discord.MessageEmbed
does anyone happen to know databases like sqlite work under the hood?
like how do stored records get physically represented in a file
because im interested in how they deal with fragmentation because of deleting records
https://sourceb.in/Ibt3EzeiDe how can I make the quiz with award? The code i provided are not working
y
js { label: "Channel Updates", description: `${client.emoji.THEME} | ` + "Set the channel for logging channel updates", value: "channel_logs", },
iirc descriptions only support text and numbers and no special chars or emojis
But the select menu option can have an emoji
heelo there
the deleted entry is probably just replaced with a marker that it was deleted, it wont actually be removed until you run vacuum
vacuum lmao
I'm just thinking of a strategy on approaching this issue
since you can't just delete bytes
unfortunately
so will they be replaced or
is there an index of deleted blocks
so they can be replaced
yeah there are many strategies for this
all of them have drawbacks
there isnt a single best solution
i made it
raw web sockets
good
well, you're pretty much set up then, now it's just working on the front end

did u find it hard or pretty straightforward?
in between i had never made anything in phpMyAdmin and the layout confused me but other then that it went pretty smoot
oh, phpmyadmin
use pgadmin4
php<something>admin is generally used as a fallback alternative to manage the database
I asked regarding the websocket itself
thats just what i can use on my hosting
yeah lol
is it the only database available?
Can anyone help me with my topggpy? I wrote this but it did not work. I tried asking in #topgg-api but no one answered so I wanna ask here 😭
import discord
from discord.ext import commands, tasks
import topgg
from config import *
class TopGG(commands.Cog):
def __init__(self, bot):
self.client = bot
self.token = DBL_TOKEN # set this to your DBL token
self.dblpy = topgg.DBLClient(self.client, self.token, autopost=True, post_shard_count=False)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
def setup(bot):
bot.add_cog(TopGG(bot))
what error?
There was no error. just the bot didn't print out when I voted
What is route?
It's the part that goes at the end of your webhook url
http://serverip:port/dbl for example
Oh
Bro Can I DM You For Help?
If you want, but its often faster asking here or in #topgg-api.
Others often catch things I don't ^_^
No one answer me tho- Also, I need help with my webhook API so I don't want to leak the url here
You probably shouldn't share your webhook url with me either.
Maybe I will change another one then, after I get the structure
Help me please 😭
did you fill in your url and auth on your bots edit page in the webhook section?
Yes
- I tested it
and you didnt use a discord webhook url correct?
I did
topgg webhooks dont work with discord webhooks
ah no
I converted it through https://webhook-topgg.com
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
ah
if you want to use this code you cannot use that site
Do you know any site that I can connect?
topgg only allows one webhook at a time, as far as I know you cannot use two on any site.
I mean, do you know how to get a valid topgg webhook?
Like links that I can get the routes one
hello
what are you using to host?
ie, a vps, dedicated server, heroku, replit, home?
vps
your url would be
http://VPSIPHERE:PORTHERE/ROUTE
Oh
But bro, we really have to host a webhook?
how else do you expect to receive the events?
webhooks are pretty standard for receiving data.
I want to get the event if the bot got voted
yeah, webhooks are the easiest and most performant way of doing that.
But idk how to get a top.gg webhook
you're doing it now.
this code creates a webhook listener
well, its incomplete
webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000
is missing
but idk webhook_path 😭
it can be any standard characters
kiandkiasndkd
would be a valid path
you're the server, you get to decide those things
But the VPS only hosts the bot tho-
most vps providers allow web requests
Oh
@solemn latch So the stucture is <IPAdress>:<PORT>/<anything here>?
yeah, as long as <anything here> is the same on topgg and webhook_path='/<anything here>'
What about the auth?
the auth you decide, as long as its standard characters
a-z A-Z 0-9 and a few others are allowed
ohh
cool
@solemn latch Bro can we get the url in Vote tracker bot?
you can use vote tracker or your own webhook.
not both
what will be the route in that url then
we only provide webhooks.

if you are really determined to use a third party service and get a vote event you can just listen for the message sent from vote tracker or this service.
but no one really does that, and I dont know python to help you.
Oh
deleted for privacy reasons
the webhook url cannot be visited in a browser, its only for server to server communication(otherwise it would be called a website)
Should I finally give in and use bcrypt or continue hashing passwords using SHA?
BCrypt and salting
Doesn't bcrypt require salts by default?
there's argon as well
anyone know a good tool to look inside a programs memory (including heap) and search the contents?
i tried cheat engine but it doesnt support regex text searching
bcrypt rolls its own salt
SHA is relatively fast because it's general purpose. Password hashes are specifically meant to be slower to make brute force even harder so you should probably switch
Yep. Thanks, Xetera.
I guess that’s new, when I used BCrypt with C# I had to use one of their functions to create a salt
Yeah it was common to define your own salt in previous php versions too which has changed the last years
Bcrypt does generate its own cryptographic safe salt key
(by default)
But you shouldn’t set the generation cost to a too low value
How would I use ES modules in a commonjs file? Ex.
import someModule from someModule;
// But I want:
const someModule = require("someModule");
Reasons for this is that I don't want to have to go through every single file and change require to import. Most of the modules I use are not ES modules anyways, so changing such things for just one module would break a lot of things.
you'd have to use const someModule = await import("someModule");. there's no other way besides migrating to ESM and using search & replace function of your editor
HI i'm making a website with nodejs first time on web dev how do i fix this
require() is only in node
huh
browser JavaScript is not node
if you're making a website in node.js, chances are the backend is in node.js
How do i change the backend
i'm not sure what you're trying to do
what part of your code has require() in it and what is it for?
making an url shortener so i'm using bitly api and i'm requiring node-fetch
why are u running the code in the browser console?
i'm not
its giving me 403
main.js:4 POST https://api-ssl.bitly.com/v4/shorten
then you can't POST to that url
For some reason I am getting a permission error even though the bot has permissions and intents to ban (which is what I am trying to do)
show the error and the code associated with it
Any reason that this could be happening?
Here is the error:
check your bot's permissions again
because the likely reason is that you didn't check the right perms
are they manageable?
https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=manageable
Found the issue.. It's because of the fact that bot was below the role that the user had..
Is there a way to catch this and just return an error in Discord saying to make sure the bot role is above the person you're trying to ban?
its called manageable
how do I uninstall all global packages, with yarn?
is there any way to delete the timeout using d.js?
clearTimeout
target.timeout(null)``` answered my question, btw thanks
Hey there...
I am using MongoDB as a database and am trying to check if a certain value within a document equals something.
What I am trying to do is check if the user wants to display the ban publicly and does not have a channel configured using this code:
if (isPublic && dbdata.publicChannel == "none") {
interaction.reply({
content: 'there we go'
})
}```
the `publicChannel` is set to `"none"` when a bot is added to the server and then is updated using a command.
Anyways.. When I run my code, all I get is an error saying the application didn't respond or whatever with no error in the console.
Any reason this could be happening?
Thanks in advance
isPublic is a boolean the user provides
dbdata is the findById that I have set up
And everything works fine when I remove this if statement..
And I would just remove it, but it is needed
you also have to think about what happens if that if statements doesn't run. It's possible that your execution branches off to somewhere else and then you don't have a response
might have a fix.. hol on
yarn global remove $(yarn global list | grep info | sed 's/^info "\(.*\)@.*".*$/\1/')
What here could not allow my bot to reply to interactions?
Use Slash Commands ?
have it
are you returning deferReply ?
Nothing can deny you from responding to interaction commands
I thought you have problem with reply 😄
nope.. just a normal js interaction.reply({ content: 'Hello world!' })
Then how come my bot is not sending messages at all?
because your logic is flawed or dead-ending
but it's just a command that says "hello world" 
Show your code so we can help better
import { ICommand } from 'wokcommands'
export default {
category: 'ban',
description: 'Bans the user, for the reason given. Will also display the ban in the configured channel',
slash: true,
testOnly: true,
guildOnly: true,
permissions: ['BAN_MEMBERS'],
options: [
{
type: 'USER',
name: 'user',
description: 'The user you want to ban',
required: true
},
{
type: 'BOOLEAN',
name: 'public',
description: 'If "true", the log will be sent to the configured public channel. If "false", it will not.',
required: true
},
{
type: 'STRING',
name: 'reason',
description: 'The reason you are banning this member.',
required: false
}
],
callback: async ({ interaction, guild }) => {
const configSchema = require('../schemas/config-schema')
const user = interaction.options.getUser('user')
const buser = guild?.members.cache.get(`${user?.id}`)
const isPublic = interaction.options.getBoolean('public')
const reason = interaction.options.getString('reason')
const dbdata = await configSchema.findById(`${interaction?.guildId}`)
function isReason () {
if (reason) {
return reason
} else {
return 'No reason provided.'
}
}
const logChannel = guild?.channels.cache.get(`${dbdata.publicChannel}`)
if (logChannel?.type === 'GUILD_TEXT') logChannel.type === 'GUILD_TEXT'
else return
const publicEmbed = {
author: {
name: `${user?.username}#${user?.discriminator} was banned!`,
icon_url: `${user?.displayAvatarURL()}`
},
description: `
• **User:** ${user} (${user?.username}#${user?.discriminator})
• **Moderator:** ${interaction.user} (${interaction.user?.username}#${interaction.user?.discriminator})`,
fields: [
{
name: 'Reason they were banned',
value: `${isReason()}`
}
],
color: 0xff0028,
footer: {
text: `Bannin' Bonnie | User ID: ${user?.id} | Moderator ID: ${interaction.user?.id}`
}
}
const succEmbed = {
description: ` **${user?.username}#${user?.discriminator}** has been banned!`,
color: 0x3cb371
}
interaction.reply({
content: 'hello'
})
/*if (!buser?.manageable) {
const errEmbed = {
description: ` This user is not manageable!\nPlease make sure that the bot role is above the person you are trying to ban!`,
color: 0xff0028
}
interaction.reply({
embeds: [errEmbed]
})
return
}*/
}
} as ICommand```
I have the one part commented out for troubleshooting
How interactions works as compared to message command handling is that you HAVE to respond. Simply returning without telling the user anything does not help the user or you
Soooooooo.. Are you referencing to this:
if (logChannel?.type === 'GUILD_TEXT') logChannel.type === 'GUILD_TEXT'
else return```?
So even though the command that sets the channel makes sure it is a GUILD_TEXT channel, I should also make sure it is here in the ban command?
And then, if it isn't for who knows what reason, return an error embed or something alike?
And that helped
THANK YOU @lament rock

always sanity check yourself because unintended logic will always occur if you allow room for it to
If something so simple got me stuck, I would go insane too. Something did happen yesterday where I was working on a Discord gateway lib I maintain where if Discord asked my client to reconnect, it would connect to the gateway, but it wouldn't receive the HELLO packet (which Discord always sends). Turns out that I removed all listeners from the ws implementation which was a relic of old design. Needless to say I shouted plenty of obscenities at myself after 4 hours of console logging and debugging
Discord token and refresh. one time, I had no error on console everything was perfect I was getting the response from discord api but I can't send the request. Slash command auto complete was showing nothing even if I send data back. I have a friend who is newbie on programming he told me that dude refresh the token maybe it expired. afterwards, I refreshed the token and it worked 😄
its the little things. I'm at the point of js mastery, but I'm still dumb as fuck
what permissions do you need to send to other channels?
Just the send messages permission, correct?
I think Send Message is covering for that ?
VIEW_CHANNEL and SEND_MESSAGES
@lament rock he is asking on discord application permission area / I believe
That area doesn't matter since guilds and channels are what takes precedence
wellllllll
slighhhtttttt isssueeeeee
i have those and am getting a perm error:
users with MANAGE_ROLES can change the permissions anyways
💀
Welp. Those are the permissions, so check again
like I said, that page does not matter whatsoever
the channel overrides are what matters
okay
now
how would I check if the bot has permission?
to send messages to that channel
Thank you, got it
how can i add canva image on embed?
upload the image as an attachment first and use the url
Would someone know a way to remove a role automatically when another role is granted ? I have a visitor role, but once people are granted "member" role, I want visitor to be removed. Member role is granted through a bot (easy applications).
How to make Vote required commands ( Discord.py )
apply an event listener when a member's role list changes
in theory I think I understand what you mean, in reality I have no idea on how to do that though. Do you have an example somewhere I could look into (and copy :D) ?
depends on what library you use
none I believe ? I just use a few bots and that's it.
i got a map of userIds from a queue i made and want to turn it into user tags instead, ik i can use client.users.cache.get for ids if they are in a string but it doesnt look like it works in a map js const stringArray = queue.map(obj => `${obj.queue.userID}`); console.log(stringArray); const joinedString = stringArray.join('\n'); console.log(client.users.cache.get(joinedString));
or if it much easier just tag the user but i preferably wouldnt
can I access a global variable inside a js function?
coz, I hv a local variable with same name, in that funciton
const users = queue.map(o => o.queue.userID).map(client.users.cache.get);
If queue is an Array, that returns an Array<User>. If it's a Collection, that would return Collection<string, User>
global.variableName instead of just variableName
global is a constant
if it's webjs, you'd use window
doesnt fetch works in nodejs?
by "tag" do you mean <@mention>?
yes
just replace the very first line in ur code with```js
const stringArray = queue.map(obj => <@${obj.queue.userID}>);
no need to get anything, discord will parse that into a mention
[Error_Handling] :: Uncaught Exception/Catch (MONITOR)
TypeError: client.voice.onVoiceStateUpdate is not a function
at VoiceStateUpdate.handle (/home/container/node_modules/discord.js/src/client/actions/VoiceStateUpdate.js:29:22)
at Object.module.exports [as VOICE_STATE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/VOICE_STATE_UPDATE.js:4:35)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:351:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:526:28)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1137:20)
at Receiver.emit (node:events:526:28)
at Receiver.dataMessage (/home/container/node_modules/ws/lib/receiver.js:513:14) uncaughtException
[Error_Handling] :: Uncaught Exception/Catch```
anyone know how to fix it ?
TypeError: client.voice.onVoiceStateUpdate is not a function
i would prefer to only get the username but with that i could just send it to one person
?
like, if u want the username u do need to get the user object
that's why I asked "with 'tag' do you mean <@mention>?"
thats why i said or if it much easier just tag the user but i preferably wouldnt
how does axios works in both browser and nodejs?
and that just prints @polar olive
i also replied in discord
to list a queue from a database
no, I mean, is it public or dev-only?
currently me only but i will make it public
if ur going to show members of other servers then yes, you need to grab the username
im not
then using a mention is fine
since members of the same guild will always show as a valid mention
just put the mentions inside an embed or disable mentioning users so they don't get pinged
well, it didnt ping me
is it inside an embed?
no
then it should be disabled globally, else it'd have pinged
i found a bug in my bot that will take awhile to fix. if i delete it from top.gg will i be able to readd it again later (assuming with review)?
yeah, but why would you want to remove it? just leave it there, nobody cares lol
cause first impressions, ya know?
Here You see that Emoji ? i wanna know how to do that in discordjs
You can use the setEmoji() method on the MessageButton class instance to do so
https://discord.js.org/#/docs/discord.js/stable/class/MessageButton?scrollTo=setEmoji
For example
import { MessageButton } from 'discord.js';
const button = new MessageButton()
.setEmoji(...);
...
oh shit you are right
what iff i encode it real hard
Also this is a project i am not taking really seriously
@pale vessel come here heheh
does encoding work
like would it make it safer somehow
when i map all my guilds, some guild id, guild name and icon are undefined, someone know why?
what are u mapping it to?
fs does not exist in browsers precisely because its a security risk
i am aware but i think intead of that i can use smthn else which i forgor about
but i did use something similar to fs on a vanilla project earlier
For a server list
there is the browser FileSystem api which can access temp files and such https://developer.mozilla.org/en-US/docs/Web/API/FileSystem
show ur code
nahhh he afraid u gonna steal the masterpiece
also how come developer.mozilla is sooo advanced when it comes to dom stuff and vanilla js
like it has more info than stackoverflow
the answers are there lmao
it is basically the top js documentation source
it has a huge community maintaining it
ohhh that's why
const guildData = await data.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).map(guild => {
return `Name: ${guild.name} ID: ${guild.id}`
});
i've been always wondering
I dont see anything wrong with the code
But some guild return undefined as id or server name
data is the client
is the client logged in?
u have to fetch the members first
do you have sharding? do you use guilds.fetch(id) anywhere?
do you use guilds.cache.set() anywhere?
No i dont have anything this is just a 10 line script where i map all guilds
'957844928900247612' => <ref *62> Guild {
id: '957844928900247612',
name: undefined,
icon: undefined,
features: undefined,
//...
uhh what?
i mean in other places where you use client
not only in this script
show how you define data
const bots = new Collection()
bots.set(guild.id, new Client({ intents: 32767 }))
const data = bots.get(guild.id);
await data.login(token)
// and the map after this
what

Yes
don't just copy and paste code please
why are you creating multiple clients
I need a different bot for each guild
why?
I dont
thats not how it works
Custom Bots
u are hosting all of them on 1 vps?
you have different tokens for each guild as well?
Yes
botghost hosting concept
i mean
you have to keep in mind that each client will not have only that guild, and that if two bots share the same base guild one of them will be overwritten
also, awaiting the login is not enough to receive all guild data
that is why you are seeing undefined
guild data is only guaranteed to exist after the ready event
that's prolly cuz the ready event has done it's job?
Damn a custom bot for a "Claim your nitro" server Ooof
as i said, guild data is only available after the ready event
just what i said hehe
okay thanks
yes it work now, thanks you :)
message.channel.messages.fetch();
am getting ratelimits on fetch so what i have to do
any optional idea?
What are you fetching the messages for?
The simplest solution is don’t fetch that many messages™️
When you get denied for message content but too lazy to switch to slash commands
lmao
yes, lets fetch every single message we receive, that sounds like a good idea
Aye... if we're not allowed to receive the content anymore, just take down the API with spam as protest
so i just added a new bot i made to a server and i am getting this error here DiscordAPIError[20012]: You are not authorized to perform this action on this application at SequentialHandler.runRequest (D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:198:23) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async SequentialHandler.queueRequest (D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:99:20) at async D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\src\functions\handleCommands.js:31:17 { rawError: { message: 'You are not authorized to perform this action on this application', code: 20012 }, code: 20012, status: 403, method: 'put', url: 'https://discord.com/api/v9/applications/811586423933108254/guilds/494567290990493696/commands' }
application.commands

hey.. So umm, I sort of started hosting a website like a month ago
and completly forgot about it
and now I forgot its hosts name 😅
any of you know a host thats litilary named Git? I tried searching for it but all I got was the Git (not a host) and Github
ping in replies
just spent some time seeing how small we could get our compiled bots. we agreed on something like this
#include <dpp/dpp.h>
int main() { dpp::cluster bot("token"); bot.start(false); }
someone said 'oh in rust i can get a similar bot compiled and stripped symbols and it is 5mb'... so i did the same and...
brain@neuron:~$ g++ -std=c++17 -o testsize2 test2.cpp -ldpp -Os
brain@neuron:~$ strip testsize2
brain@neuron:~$ ls -alh testsize2
-rwxr-xr-x 1 brain brain 6.7K Apr 6 19:35 testsize2


i did the same and stripped symbols off triviabot... heres what happened
brain@neuron:~/triviabot/build$ ls -alh bot *.so
-rwxr-xr-x 1 brain brain 630K Apr 6 19:46 bot
-rwxr-xr-x 1 brain brain 24K Apr 6 19:46 module_bandwidth.so
-rwxr-xr-x 1 brain brain 89K Apr 6 19:46 module_diagnostics.so
-rwxr-xr-x 1 brain brain 32K Apr 6 19:46 module_presence.so
-rwxr-xr-x 1 brain brain 1.1M Apr 6 19:46 module_trivia.so
nice
@wheat mesa I hate bnf
first time trying to write a custom language compiler for intellij and I hate bnf
what is bnf
What is bnf
Just use regular expression form instead (whatever it’s called)
This thing
Ah okay I see
for example <test:any:R> is a parameter called "test", with type "any" and is required
but that FEELS like regex, but isn't regex and I hate that
With a parser and everything
for intellij gotta use that
also it's fun that you could theoretically make a theme where all colors are random
just supply (int) (0xFFFFFF * Math.random()) when passing highlight color
it'll change everytime you do something
bruh, I spent 1 hour trying to find why this is capturing [] too
Lol
guess why?
damn unicode
now why understand why people use [A-Za-z] instead of [A-z]
lmao
yeah you should be careful if you don't wanna match ascii chars, too
If you don't care about the case sensitivity then simply add the i flag
[A-Z] or [a-z] will then both match the right chars but no ascii chars
yay it works
My bot was public and random people added it to their servers. How can i make my bot leave these servers like how premium bots leave servers? when you add them without premium subscription?
discord.js?
if so it's as easy as guild.leave()
what language
Js, Thank you all, my friend helped me,
I don't have much experience with sharding Discord bots. So, if I have messages that need to be fetched every time the bot is restarted, what would be the most efficient way of doing so?
broadcast eval fetch it
How do we go about fetching users in discordjs v13? is it still client.users.fetch?
Ah wait nevermind it has to do with my intents
how can i delete the embed that was sent
in this case, q1
like after it checks everything ofc
You edit the message and let it’s content as it is but pass an empty array for the embeds options
iirc message.edit({ embeds: [] }); will not affect the content
If there’s no content this will cause an error as a message can’t be empty
one does not simply edit an embed :^)
Tf I don’t get that English
One?
hi
meaning "a person cannot simply walk into X"
its impossible or too hard
I'm trying to import an ES6 module in commonjs, but client keeps returning undefined.
let client;
import('es6-module-thing').then((_) => {
client = new _.default();
});
module.exports.client = client;
you cant do that
Is there any way then I can import an ES6 module into commonjs without having to change all my require statements to import and modifying my package.json?
treat it as an async function like it is
the closest you can do to that is this:
module.exports = function() {
return import('es6-module-thing').then(_ => new _.default());
}
// file
const createClient = require("yourmodule.js");
// inside some async code
const client = await createClient();
Okay tysm!
And I assume yourmodule.js is the file that contains the module.exports statement?
ye
but you might as well just use the import line directly
its a 1 liner anyway, not much use putting it in a separate file
const client = await import('es6-module-thing').then(_ => new _.default());
ah ic okay. tysm this is super helpful
await?
is that a question, or...?
Usually the rule of thumb with dependencies is you import anything that is statically available from the moment the app starts (function definitions, constants, classes) from files and anything that is not available the moment an app starts like a database connection, client etc you pass around your app as parameters or as state
obviously there are exceptions to that like all rule of thumbs but it's a helpful way of thinking about managing when you need things and when they're available
yeah but you cant import esm from cjs like that
ye I recognize there's a more important underlying issue here in specific
assign
const msg = message.channel.send(...);
...
msg.delete(); // async
Thanks, took time, but fixed
How to do Mention a Button, and a SelectMenu in SlashCmds ??
hey, i was wondering how i would make it so when i say !help it sends the normal help cmd (which i already have) but then using buttons below you could click stuff like moderation, utility, etc and it will edit the message to show that. I've already got that but my issue is when i click something like moderation it edits the message but removes the buttons. how do i do that and still keep the embeds so it removes the moderation button and adds a "help" one and keeps every other one
im using discord.py
import nextcord
from nextcord.ui import Button, View
from nextcord.ext import commands
class Help(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def help(self, ctx):
mod = Button(label="Moderation", style=nextcord.ButtonStyle.green)
uti = Button(label="Utility", style=nextcord.ButtonStyle.green)
ambed=nextcord.Embed(timestamp=ctx.message.created_at,colour=0x2986cc)
ambed.set_author(name="Heroku Moderation", icon_url="https://media.discordapp.net/attachments/961439698750943243/961465912886697994/Hemi.png")
async def button_callback(interaction):
await interaction.response.edit_message(embed=ambed, view=None)
mod.callback = button_callback
wmbed=nextcord.Embed(timestamp=ctx.message.created_at,colour=0x2986cc)
wmbed.set_author(name="Heroku Utility", icon_url="https://media.discordapp.net/attachments/961439698750943243/961465912886697994/Hemi.png")
async def button_callback(interaction):
await interaction.response.edit_message(embed=wmbed, view=None)
uti.callback = button_callback
embed=nextcord.Embed(timestamp=ctx.message.created_at,description="Heroku is a mainly Moderation & Utility bot, our goal is to make Heroku as simple and\neasy to use. Heroku is always in development and being worked on / getting huge updates, if you want to help out with Heroku dm `herq#4281`\nwith command idea's, or to become a developer for Heroku (If we are looking)",colour=0x2986cc)
embed.set_author(name="Heroku", icon_url="https://media.discordapp.net/attachments/961439698750943243/961465912886697994/Hemi.png")
view = View()
view.add_item(mod)
view.add_item(uti)
await ctx.send(embed=embed, view=view)
def setup(client):
client.add_cog(Help(client))
if you could help or if i don't make sense pls ping me
components: [row, button]. That is not the correct syntax to send multiple items in an array
ty
What version of Discord.JS are you running, and on DiscordJS client init what intents are you providing?
See https://discordjs.guide/popular-topics/intents.html#privileged-intents
As an example: const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
you should add an extra button with one of the button callbacks and in that same callback, disable a different button (I don't think it's possible to delete one entirely from the message):
i.e.
async def button_callback(interaction):
new_button = discord.ui.Button(label=f"Play Amogus", style=discord.ButtonStyle.green, emoji=":video_game:")
original_button.disabled = True
# Or smth like that
I hope that helps
17
they are asking me for verification but whenevr i upload my documents they say its invalid
i am uploading my adhaar card as my identity proof
can someone help me in it .
How? The lates DiscordJS version is 13.6.0
And what about my second question, what intents are you passing in currently? It is a required field
maybe they meant node 17
yeah 😄
Yeah that is not relevant atm tho 😂
What is the answer for my other two questions lol. Kinda hard to help when you avoid them 
😄
Best place to ask would be the discord developer server https://discord.gg/discord-developers or via a normal support ticket to Discord
Yeah you need to pass a discord intents array in there too. It became required by the Discord Gateway some time ago
yeah support ticket being unresolved from last month
What country are you from, India?
yes
I am guessing a PAN card is a aadhar card?
Humm... reading from the other server people mentioned a "aadhar card" worked. Are you 16 years or older?
Maybe try taking a clearer image in a brighter room?
19
its different
what u want is pagination
check if there isn't a lib for that, making your own pagination handler can be quite hard to explain
Lol
so.. what you think would be the best way for me to, within my app, show how many users are currently using the app?
I'm thinking of, within the app, pinging some api with some random unique id that gets regenerated when the app reboots, and then on my api i can just count how many unique id's within like, the past 5 minutes
but idk
use a websocket
but then each active app would have a constant connection to my server, and that doesnt scale as nice as an occasional ping for a counter to be returned
I mean, online games use mostly websockets to track player actions
yea, but games would mostly already have an active socket for sending data
wouldn't it be the same for your app? it's a 1-N relation
You could use UDP instead of websockets
One message removed from a suspended account.
hmmm or you could just go with your solution
One message removed from a suspended account.
I mean, my app doesnt need to be sending any other data though. using a socket just to check how many recent users seems kinda overkill 😄
but having some api that just gets pinged seems messy somehow
well, either way you do need to set a connection between client <> server
websockets don't necessarily mean it'll be a bidi connection
yea, but lets take scale into account too. you can only have like 1000 sockets connected to any single endpoint iirc
for something thats sending a ping to get a counter once every 5-10 minutes, that seems like an unnessicary obstacle
let day1 = 2
let day2 = 2
let day3 = 1
//Let's check for the best combination and refuse the bad combinations
if (day1 === 1 && day2 === 2 && day3 === 3) {
console.log(`Perfect :)`)
} else if (day1 === 2 && day2 === 1 || day1 === 3 && day2 === 1 || day1 === 3 && day2 === 2 || day2 === 2 && day3 === 1 || day2 === 3 && day3 === 1 || day2 === 3 && day3 === 2){
console.log(`balls too`)
}else{
console.log(`balls`)
}
look guys javascript
so i'd either have to implement some kind of load balanacing with multiple servers ready to spin up to record a counter, or just use an endpoint, and count how many uuid's in the past x time
That's like the same thing on all programming languages

Why only 1000?
idk, isnt that the limit on how many sockets can be connected to any single port or whatever?
oh, apparently nginx has a hard limit of 65,535 concurrent connections 😄
64K for TCP
wth, why am i over here thinking 1k 😂
but still, keeping a connection open constantly vs a ping every x minutes, is it really better to socket it?
rather than just connect then close each time with a regular request
I guess then it would really depend on how often im actually going to be polling the api
if i want users within 5 minutes, or an hour, or 24 hours, or whatever
like, if im doing it every 5 minutes maybe a socket would be better, but i think anything over one per 30 minutes would likely be better to just ping an endpoint
or i could just add google analytics to my app and get the data there 😂
but ~ eww, google. (sorry mr feud)
if (day1 < day2 && day2 < day3 || day1 === day2 && day2 < day3 ||day1 < day2 && day2 === day3 || day1 === day2 && day2 === day3) {
console.log('Gucci')
}else{
console.log('No good!')
}
which one? lmk if u got a better solution
this or the latest one
If you really care about speed and performance you'd use UDP over HTTP
😂
yea im likely going to set it up with udp as i think i do wanna be sending updates fairly frequently
if you're pinging every 5 minutes you dont need sockets
sockets are meant for connections that update many times per second, if you're only doing it once every 5 minutes, you will end up wasting most of it to some kind of keepalive heartbeating
that was kind of my initial thinking in using just a basic ping type request. like, just having unrequired connections alive seems like a pointless waste of resources.
and its literally just to send some data like uuid and app version 😄
and to get a number returned
UDP is connectionless
one socket sends data other receives it, a connection is not required
with HTTP you're basically starting a connection and then closing it once you receive your data. So theoretically there's more overhead using HTTP than using UDP
if (day1 <= day2 && day2 <= day3) {
}

finally
dealing with autocompletion in intellij is annoying af
but at last my syntax checker is done
java
Thats ok too but the one Kuhaku did is good
rlly?
Thats the only lang i can get a job with in my country
Otherwise i would have to do frontend which i hate
I do know c# a bit
learn either lang and you automatically learn the other
Used it for unity
then u know java
well, code migration is difficult when going from a dynamic lang to a static one
HOWEVER, to ease ur migration I'd recommend groovy
consider yourself lucky
since it has a syntax VERY similar to js, but is technically java
and it's also dynamic
js and java are incomparable imo
Hmm
that's true, that's why I suggested groovy
The thing is i shall learn it just cuz thats what companies use here
Nodejs is almost unknown
Its either php or java
I dont wanna make a step back and learn php

unknown where you are? I hear lots of jobs involve node.js
Albania
makes sense
one is a country and one isn't
If you plan on learning Java I recommend you check out Hyperskill
Taught me a lot of it
But the thing is if i find a company that uses nodejs i can get paid good
Since there is not many nodejs devs out here
Giv me sum $$$ and good advertsment
what is this
s!eval ```groovy
def getOr(var a, var b) {
return a ?: b
}
getOr(null, "abc") // prints abc
getOr(5, "abc") // prints 5
this see the similarity with js?
my custom language I use for parsing arguments
Shushhh
I didn't mean email






