#development
1 messages ยท Page 1594 of 1
yes
auto imports are really something huh
import { Message, Client, Collection, MessageAttachment } from 'discord.js';
k, now what
here's where things get more complex
oh boy you can't just do that in ts
๐
you gotta add a .d.ts file
maybe I should get back to require
something like enviroment.d.ts for example
require won't fix that
but you can use pretty much anything
didn't throw an error like that
declare module 'discord.js' {
interface Client {
commands: Collection<string, CommandOrWhatever>;
}
}
in your .d.ts file
because Client doesn't have a commands property
yeah I know
Or just this in your main file
declare interface Client {
commands: ...
}
the tutorial did that long time I go
you can't just modify stuff that doesn't exist
How do i do to make an code in HTML who says if my BOT is online or not?
well, I'm gonna do my own ig
How do I get my bot's topgg token
now instead of calling for bot.commands I'll call for commands
swapping manually won't hurt
just create a enviroment.d.ts file in your src folder with this
well you can name it whatever you want as long as it ends with .d.ts
Note that you don't really need a .d.ts file to make it work, you can place this in the file where you use Client:
declare interface Client {
commands: ...
}
i don't know if it's a good habit creating properties
bru why not just use .get()
well alright
hey guys i need some help:
trainers[targetMember.id].mons = [given1]
trainers[targetMember.id].spawnId = [given1.spawnId]
trainers[firstmember].mons = [given]
trainers[firstmember].spawnId = [given.spawnId]
fs.appendFileSync("./trainers.json", JSON.stringify(trainers), "utf8");```this actually doesn't add the trainers to specific trainer in trainers.json, but it actually makes antoher array:
how do i fix taht?
you don't really need declare, right?
i think you do need it
isn't it just to specify that it's existing
hmm
const command = commands.get(commandName) || commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
cmd also doesn't have .aliases
well add it
yeah JS is free bad habits everywhere
Use an interface to describe a command object
or a class maybe?
probably an interface
This is pain
TS obliges you to learn the good way
this is the way
yes, I know how to
do u no the wae
n0
just looking at the things before doing anything alone
trainers[targetMember.id].mons = [given1]
trainers[targetMember.id].spawnId = [given1.spawnId]
trainers[firstmember].mons = [given]
trainers[firstmember].spawnId = [given.spawnId]
fs.writeFileSync("./trainers.json", JSON.stringify(trainers), "utf8");
```why does this literally overwrite all my pokemons
make a basic api for the bot, and use it in the dashboard
how do I assign array as type?
interface cmd {
aliases: array[string];
}
wasn't something like this?
Java flashbacks
but it has to be
working like an IDE is better than just free of will
yea
how should I organize this?
your commands variable must have the type Collection<string, cmd>
interfaces are Capitalized btw
so you would probably want to name it interface Command
Need help in bot
const commands = new Collection(); so this isn't enough
but Command is down there
so you should do
const commands = new Collection<string, Command>()
ah k
maybe you can't use command before declaring it
not sure
interface Command {
aliases: string[];
}
const commands = new Collection<string, Command>();
way up there
does that work
yeah, no red lines
aight
aw man
you need to add execute to command
but execute is a built-in function
interface Executable {
run(): void;
}
wait what
try {
command.execute(bot, message, command, db, lang, language, prefix, args, serverSettings);
}
catch (err) {
console.error(err);
message.reply(lang.error.cmd);
}
at least in JS
what do you mean by built-in function
it's not built-in, you define it in your command objects
idfk, weird expressions I use
example
I didn't declare execute anywhere
never
I grabbed this execute thing, a long time ago, when I was learning how to make a bot
for command handling
you need to add an execute method on your command interface
you do, as a property of the object you're exporting
it's in the screeenshot, lol
interface Command {
execute(arg1: SomeType, arg2: SomeOtherType): void;
}
Nead help
Js
The bot is dm ing how to change to channel
I search in code to change user to channel
const db = admin.firestore();, what type is this?
Help bro
no idea tbh
Returns _firestore.Firestore
straight up stop using require() unless its json
import will import the types too
yeah, just did
require() resolves to any
@quartz kindle help
so you have to cast it
but at that point, just import it
Show code?
Shill I dm
index.ts:50:8 - error TS1259: Module '"C:/Users/ragsf/Desktop/Gumball-and-Penny/node_modules/firebase-admin/lib/index"' can only be default-imported using the 'esModuleInterop' flag
50 import admin from 'firebase-admin';
~~~~~
const admin = require('module') as Type
Try import * as admin from 'firebase-admin'
or that ^^
in discord.js is it possible to make a message like this
fixed
are you using body selector to change background?
* means everything iirc
ik but w the info
what info? those are fields
yoo, l my bot is working, I fixed everything!
.send() can take an object
how do you calculate the ping without a message
.send({embed:{/*embed content*/}})
@quartz kindle see dm
ik how to send an embede
you can check websocket
how
no
body {
background: color-here !important;
}
.bTmyJW {
background: transparent !important;
}
0 errors, fully working with no problems
now it's time to rewrite the commands and functions
i need to rewrite my whole reminders system
and its massive
i really dont want to
but i wanna make it dynamic
ยฏ_(ใ)_/ยฏ
I dont use JDA, and youre straight up using a premade open source bot. Ask the author
Life is a son of a bitch
The bitch is a child of Life
Never seen so many sons of a bitch
I'm my fucking life
it's a saying from my country, something like that
but in Portuguese sounds better
@quartz kindle might be the only one to undertsand that proverb

anyway, i digress
i should go code
xD
in translator, it goes like
Life is motherfucker
The whore is the daughter of life
Never seen so much motherfucker
In the whore of my life
hey guys
i recently installed visual studio to get into c#.
However, now vsc gives me problems when installing packages:
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS *******************************************
*******************```
You have any code
code doesnt work like that
hahahah
he be like
Like wich
The code i have only works for me
Lol
Because code is made specific for each situation
I have one problem only
daddy tim prob knows the issue
You need to ask the one who coded it
roflmao
nvm i just deleted vs. Works again.
I don't know him ๐
dm them, surely they put contact info on their github
you can open an issue tab in github
Or just dont take code from github if you dont know how it works
Ok
The code is on github. You open an issue and ask there
boys what the fuck is this
Thats what github issues are for
So am I
What is this
slash commands
Slash commands
Means
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
this
There's no meaning, just slash commands

i can'install packages anymore cuz of vs
remove all node modules
Thx
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows```
thanks
Update vs
I don't have vs installed. I deleted it
I am
yarn v2 is nice
@opal plank btw how to avoid / cmd
yarn is cool
wdym how to avoid it?
theres no way to avoid it, you added a bot, its there, it has the commands
theres no "avoiding it"
remove the bot
ยฏ_(ใ)_/ยฏ
Dont use / as prefix
^^
Yup
Why would you use / as prefix knowing that slash commands works with /??
it worked @opal plank . Thanks!
Maybe they didnt know
np
older bots
before we even knew about slash commands
though they were talked about for quite a while
@glossy spoke ^
i think we got early stuff a bit before d.js v11 got deprecated
?
wut
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
This

What about that?
So why did you ping me replying to that message? 
For full details
??
fuck, im in a little bit of a halt

@quartz kindle hilp
What the hell are you talking about?
Ya but why did you mention me replying to that message?
Need to test webhooks for vote. Topgg token is already being used in main bot. Need to test in beta bot. Cant apply for beta bot cuz its not a production bot, so no reason uploading it to get an extra token, though it'd be nice.
Could pontentially hit the express endpoint with the same request top.gg sends,maybe? to mimic a vote?
I meant that wasn't neccesary
Sure one moment
can we listen to slash commands without listening to every message? ie without client.on('message', messageListener);
Like, i cant foward my bots to another ip, since it sbeing used in prod, even if its being used for 20 minutes for testing, anyone in that gap would lose their vote rewards
best thing i can think of would be doing a manual post request to my api with the payload top.gg usually sends
you could technically just use postman to make a test request
thats what i was thinking of
i assume theres no way i can upload a bot thats almost a clone of my other while having extra features right?
Do you have atleast something you can host the webhook on?
@rustic nova is there a way to change a bot's page owner? My last acc was disabled
like, i do have the webhooks running
the issue is that i cant test it via the page itself
cuz it can only foward to 1 adress
dm a mod, if it isn't approved yet, you can dm me, if it is approved, dm a full mod
Ok.
could potentially make a temporary webhook to re-emit the payload back to both the bots
And yes, it's approved.
You could dm me the url and make a few test requests if you want
its IP, since im using my local ip prob not a good idea, i dont have much setup here
What are the odds of uploading my beta bot to the site?
having an extra token would come in really handy for developing
It wont get approved if it is just the same thing, i generally would say beta bots shouldn't be on the site
Hope
why is my whole visual studio code set to fucking c#?
u smelly
yeah thats what i assumed too
It removed all my extensions Visual studio removed all my vsc extensions.
you have to count it yourself
okay so i have this in discord.js
let t1 = await client.api.channels(statusChannel).typing.post()```
Makes Discord think the bot is typing
How do i find the ping from that
How
tru'ish
you could scrape
from the website directly
fetch the json and parse the count from the bot's page
U mean top.gg bot token
Similar
you dont share your bot token to anyone
no
bot token is your bot itself
its your user bot
api token allows you to use top.gg's api
but i see you dont have a role
so im assuming you dont have an approved bot
hence you cant use the api, so your options are only scraping
but people wont be able to vote yet on ur bot until its approved
so, not sure what you trying to acocmplish there
okay so i have this in discord.js
let t1 = await client.api.channels(statusChannel).typing.post()```
Makes Discord think the bot is typing
How do i find the ping from that
My bot ownership id lost and i deleted bot from top.gg
well, if you dont have a bot, you cant use the api
function cpsTest() {
click++;
document.getElementById("something").innerHTML = click;
counter = setTimeout(function() {cps = click / 10;
document.getElementById("totalclicks").innerHTML = `You have ${cps} clicks per second! Noob!`;
document.getElementById("something").innerHTML = "Click the button to play again!";
document.getElementById("cpsbutton").innerHTML = "Restart"
document.getElementById("cpsbutton").onclick = restart}, 10000)
}
function restart() {
click = 0;
document.getElementById("something").innerHTML = '0';
document.getElementById("totalclicks").innerHTML = "Clicks";
document.getElementById("cpsbutton").onclick = cpsTest;
document.getElementById("cpsbutton").innerHTML = "Check your cps!"
}```
the restart button goes back to cpsTest but then it also keeps clicks at 0
it also goes instantly instead of waiting the 10 seconds
UnhandledPromiseRejectionWarning: Error: sqlite: filename cannot be null / undefined what is this?
what are you naming your db file
Problem is basics
are you sure you're properly directing it to that file
can i see how you define filename
if theres no other folders that db is in, it should be ./db/mainDB.sqlite
okay so i have this in discord.js
let t1 = await client.api.channels(statusChannel).typing.post()```
Makes Discord think the bot is typing
How do i find the ping from that
sql.open(`./db/mainDB.sqlite`);
fs.readdir('./events/', (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
let eventFunction = require(`./events/${file}`);
let eventName = file.split('.')[0];
client.on(eventName, (...args) => eventFunction.run(client, ...args, sql));
});
});```this is all.
const {open} = require('sqlite')
function openDB (){
return open({
filename : './mainDB.sqlite',
driver: sqlite3.Database
})
}```
i think this is how it shoulkd work
should*
then u can define db as
const db = await openDB();```
ping
also dis
a cps test but it doesn't work properly
SDK
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
is it possible to do w bots
no
oof
Is not able to count
thats not the one i sent for you
for you its this
that one is for @sterile lantern
i mean, just read the damn docs?
how do i make my bot send message when it invite to a new server
listen to guildCreate event
that gives you the guild payload of the guild that just added your bot
ohh
i assume this means when someone invites(adds) their bot
oml
thx
๐
im working on custom css for discord
im working on rewriting my reminders
wait what
custom css for discord?
yeah, thought the same
yeah
i can also just dance for you to define my gratitude
thats against ToS, shouldnt really be talking about that here
well, better than the idiot i saw yesterday
ok i will delete it
busted 
i will just go it the discord file and change it their
this genius here went on discord-developers full of staff and said this
HWHAHAHA
if theres anything star worthy i posted today, that'd be at the top
i cracked when i read that
bruh
i delete it but it still the same and i restarted
i just download betterdiscord and install this
i might be wrong, but i think they are stored in each channel
so you'd have to iterate through all channels or map them
<channel>.messages.cache.size ?
should be something like that
i'd be surprised if d.js doesnt store messages inside channels
๐
what do you pass in <channel>
a channel?
i said, you need to iterate through your bot's channels
thats what im having issues with
and you define an id and then pass the variable in
Heya I'm trying to turn on my discord bot but its not working it has worked before
you know how loops work?
what library are you using and how long ago it worked before?
im using visual studio code and it worked like a week or 2 ago
what version?
<client>.login("TOKEN");
how do i update discord. js
Why would you try to update it? You already has the v12
oh
show your code
DONT forget to remove your token
do not share your token with anyone
YEP
lmao ik
TypeError: Cannot read property 'client' of undefined at at new MessageEmbed (/app/node_modules/discord.js/src/structures/MessageEmbed.js:13:60). My code: ```js
if (message.author.bot) return;
if (!db[message.author.id]) db[message.author.id] = {
xp: 0,
level: 0
};
db[message.author.id].xp++;
let userInfo = db[message.author.id];
if(userInfo.xp > 100) {
userInfo.level++
userInfo.xp = 0
let embed3 = new Discord.MessageEmbed()
.setColor("RANDOM")
.setDescription("Congratulations sensei, you have leveled up")
.setFooter("Bot is hosted for โธโธ ๐ฟ ห laziness myths โก!")
.setImage("https://media.giphy.com/media/B6SyssSlTgPXq/giphy.gif")
.setThumbnail(message.author.avatarURL())
message.channel.send(embed3)
}```
i cant make a status like that i cant use zip
what?
sad times
Wut
your status
what does zip have anything to do with this
one min
i cant download it bc of zip
Wich db are you using?
quick
Does quick.db works like that?
am i blind or you copied the wrong snippet?
theres no client in there
TypeError: Cannot read property 'client' of undefined
lmao
@lucid prawn you unzip it, extract it with 7zip or winrar
Just download WinRar and extract it
i think windows explorer can extract it too
Imagine the entire server inside 1 voice channel
cant, 99 max
It's an hipotetic case
easy to see, multiple times have i been in 99 capped voice channels
usually on raids
@left nacelle regenerate your token
ok
and then change the token for the new one
ok
there is no client there
where?
but heroku seems to be funny
Also, to copy your code without changing the token or doing whatever to hide it, you can put the token inside an external file and the require that file to use the token on the bot's login.
if (message.author.bot) return;
if (!db[message.author.id]) db[message.author.id] = {
xp: 0,
level: 0
};
db[message.author.id].xp++;
let userInfo = db[message.author.id];
if(userInfo.xp > 100) {
userInfo.level++
userInfo.xp = 0
let embed3 = new Discord.MessageEmbed()
.setColor("RANDOM")
.setDescription("Congratulations sensei, you have leveled up")
.setFooter("Bot is hosted for โธโธ ๐ฟ ห laziness myths โก!")
.setImage("https://media.giphy.com/media/B6SyssSlTgPXq/giphy.gif")
.setThumbnail(message.author.avatarURL())
message.channel.send(embed3)
}```
there no client here
i know
then theres no client there
ah damn i forgot what the command was to start the bot
How the fuck is heroku being that funny then
node . if you have a main entry.
wth ...json db
i heard json db
Ya
yeah awsome is a stubborn one
did i hear json db
woah erwin you using json db's
ya
i personally told them to NOT use it dating back november last year. Now they're whining that the code grew too big to port it
ยฏ_(ใ)_/ยฏ
me, of course i am, json dbs are the best
erwin...
Lmao
nice
i tried jsoning it was pog
i liked node-json db better tho
how do i fix im dumb
cause you can like write your own functions
RPC is deprecated btw RIka, just fyi
We can't help if you hide the error
ยฏ\_(ใ)_/ยฏ
its my token tho
oh and python
The SDK that this documentation references, Discord-RPC, has been deprecated in favor of our new Discord GameSDK. Replacement functionality for the Rich Presence SDK can be found in the Activity Manager of that SDK. This documentation can be referenced for education but does not entirely reflect the new SDK.
source: https://discord.com/developers/docs/rich-presence/how-to
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
thats why i hid it
And why do you have your token on the main file?
wait nvm
just came back form a 57 question test
my mind is still wonky
lmao
literally told you NOT to share ur token
Token*
At login
i have a pro tip: separate your token into 3 different files then call each file in a function so it runs it as one file
very pog
this code is bad
import RPC from 'discord-rpc'
import fs from 'fs'
console.log("Attempting to start RPC...");
const client = new RPC.Client({ transport: 'ipc' });
const data = fs.readFileSync('./status.json','utf8');
const activ = JSON.parse(data.replace('"Date.now()"',Date.now()));
console.log(activ);
var pres = activ.presence;
pres.buttons[1] = { label: "โญ Create a Custom Status โญ", url: "https://discord"}
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity: pres
}).then(() => {
console.log("Custom status has started!");
}).catch(error => {
console.log("There was an error with your custom status.");
console.log("Error for nerds:");
console.error(error.toString())
})
})
client.login({clientId: activ.clientid}).catch(error => {
if (error.toString() == "Error: RPC_CONNECTION_TIMEOUT") {
console.log("There was an error starting your custom status. Please try again.")
console.log("This is a common error that can be fixed by re-running the program.")
} else {
console.log("There was an error with your custom status.");
console.error(error.toString());
}
})
it not working
what
U
just salt your token 21 times and then base64 it, then split every character of the result into different files using the current timestamp as the order
true
me personally
so that means theres a error with my token?
i just reverse regex it
@lucid prawn i literally told you
then regex it again
no
,
it just says its not defined
anyone wanna help me 
wut
also i love how i said ik not to share token but then do it lmao
At login you must write the token inside ""/''/``
i gotchu extreme
im dumb
chatis full of special snowflakes atm
Lol
@lucid prawn check what i sent
the bot. login(token) part?
Ya
you called it differently
U used JSON.stringify in your eval
in the one you said you eval you had JSON.stringify(data)
Yeah
in that one its just data
I can console.log(data) and it will give the same thing
but its null correct
Oh wait
It is because I am running it locally
And that is from my server
LMAO
u said RPC is deprecated btw RIka, just fyi
Don't mind me...
yes, RPC is deprecated, its literally on the docs
https://discord.com/developers/docs/rich-presence/how-to read the second line @lucid prawn
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
oh
Token goes where it says 'token'
it is there
oh

Should probably learn js before creating a discord bot and fucking with discords API
how do I get bot developer role bc i develop bots
i used to know but i forgot lol
Lmao
@quartz kindle I installed the SFTP plugin you mentioned and ran a script that updates a certain database on my pc, the database works fine here but on the VPS its all fucked up and its not even recognized as a database anymore, is it the plugin that is not supposed to transfer databases or i fucked up somehow (i had a backup so its fine lol)
it shows this and that is not the client id
What?
it doesnt let me type
Refresh
i did
I've never heard of someone having this issue.
Try using a diffrent browser? Or reclicking the text box.
Don't worry about sanitizing input, yes I already know it's a good habit, and I already took precautions just tell me what I am doing wrong in this line right here.
error: syntax error at or near "WHERE" | setup clan exist query
what database?
NVM
node . | node index.js
remove the comma
sqlite
@quartz kindle the developer is telling change user to channel ware to change also don't know
i just ran the database update script on the vps itself using the ssh client and now it works fine too
wut
im pretty sure it might be a problem with the way the plugin updates the database to the vps
can someone help me code my bot
how can I get a users Avatar URL from oauth?
im new to coding
isnt it just sent with the user?
what programming language?
can u help me
javascript
you should study the language and then try making a bot
Well I can't call any functions from discord.js because it isn't
It is oauth
It just shows some sort of code
oh?
@blissful coral check DMs
is there an easy way to code an anti-raid bot or should I ban users according to their account creation date?
https://cdn.discordapp.com/avatars/136583532972605440/0292de8c83b3e8e3558e9be9886b02cb.png?size=128
so this is mine for example
or
https://cdn.discordapp.com/avatars/USERIDHERE/HASHHERE.png?size=128
is this correct
if(!message.content.startsWith(prefix)) return;
if(cmd == 'ping') {
message.channel.send('pong');
try it
the guide isnt the only right way to do a djs bot
could anyone answer this? kind of urgent
I think most anti raid bots have multiple methods for detecting a raid
that's why I asked that
I could raise the percentage by detecting certain things
then if the percentage is above a specified amount, it would ban the user
age is fine, I would also check how many users have recently joined, and compare it to the normal average rate of joining
well how to i keep the bot online because it only comes when VSC is running and the cmd node . has been typed
i need it online 24/7
for example a server which normally has 100 people join a day suddenly getting 100 in 10 minutes its probably a raid.
you generally should pay for a VPS(virtual private server) to keep it online 24/7
ok
oh weird, that looks right to me, i dont know if the cdn supports webp however
is there a free way?
im 13
It does
replit is free, but its not good typically.
did anyone know api service that make image effect with member avatar url etc?
bot.on('guildMemberAdd', newMember => {
const newMemberEmbed = new Discord.MessageEmbed()
.setColor('#00FF00')
.setTitle('New Member')
.setDescription(`Welcome ${newMember} to * `)
newMember.guild.channels.cache.get('<channelID>').send(newMemberEmbed);
return;
});
okay so for some reason its not giving me any response when a new member joins my server, i dont see whats wrong and i dont get any errors whatsoever in the console? any ideas? ive tried troubleshooting a little but nothing has worked
Heroku if ur bot doesn't do anything complicated
when you inspect the page does it show correctly?
i have VSC
ok
img doesn't even show up anymore
It did before I added ``
now it does
You replace <channelId> with an actual channel id, right?
yes
Do you have the members intent turned on?
i only changed it to <channelID> for the representation here
members intent?
yeah
wdym
i forget my syntax, isnt it <%= %> for inline stuff?
oh...
if(revoketime < 345600000)
is this to big for node.js?
So that's a no
i could be wrong
In order to receive guildJoin/guildLeave events your bot needs the guild members intent enabled. Go to your bot's application page and enable it
oh ๐
you mean guildMemberAdd lol?
can someone please help me code my bot
Depends, what do u need help with
ik but im at school alot and i dont hVE ALOT OF FREE TIME
i dont need the entire i just need little things like commands
ik how
i just dont have time
Then pay someone to code for u
then hire a dev on fiverr
sweet
how much
Bru
while checking my code, I found this, should I be concerned?
k
no
I wouldnt worry about it unless it causes issues.
TS btw
You could use the import syntax to make your code more consistent
be patient
who cares if it wakes multiple weeks maybe even months
the process is more fun than the finished product for me
but:
I still need to understand how import works
Oh it's a json file, yeah using require for json files is fine
If I remove the comma I get, error: column "daily" does not exist. "daily" is the due variable
I'm pretty sure "allowJS" just allows the compilation of javascript files
or that
i can use require without "allowJS"
so for every module I had for JS, I now have to install their types for TS
cant you import() in ts?
You can, but it returns a promise
oh right
how u make text like that
triple `
code blocks
so i know this is probably the worst and laziest implementation but i have the following code in a command
client.tools.checkPerms(message, client);
``` and then in the checkPerms util i have
```js
const GuildConfig = require('../models/guildConfig');
GuildConfig.findOne({guildID: message.guild.id}, function(err, doc) {
if (err) throw new Error(err);
if (!doc.djOnly) return;
if (Boolean(message.member.roles.cache.find((r) => r.name.toLowerCase() === 'dj'))) {
return;
} else {
return message.channel.send({embed: {
title: 'You are not the DJ, you can\'t use this command',
author: {name: 'Music Boat', icon_url: client.config.embed_author_img},
color: client.config.embed_color,
}});
}
});
then it works it just does this though
so, how do I import functions?
if(cmd == 'ping') {
message.channel.send('pong');
}```
is this the way?
import removeVIP from './src/functions/removeVIP';
import giveVIP from './src/functions/giveVIP';
how u make colors and text like that
markdown
?
3 back ticks with the language
The function sends the message, but the flow of the program continues. You should probably just return true/false and handle error messages outside
K
how i send the language
makes sense, ill try that
didn't work!
then it isn't the way
How do you export the functions
do i send js then the msg @honest perch
wow
@tiny dune you are sure you defined cmd properly?
ask dumb questions get dumb answers, why are you acting surprised
does anyone here know how to make headless chrome/firefox do stuff? i can see its visiting the page but idk where the ss is going
yes...
ok
function convert(value: number) {
let valueString: string;
if (value >= 1000000) {
valueString = (value / 1000000) + 'M';
}
else if (value >= 1000) {
valueString = (value / 1000) + 'k';
}
return valueString;
}
module.exports = convert;
module.exports
Use export
๐ฎ
or export default in this case
when i put
yeah, if you're only exporting one thing you can use export default
But I recommend either doing one or the other for consistency reasons
it is still grey
@tiny dune you need to learn basic stuff for sure
the language goes in the same line as the first set of backticks
ur confused
the cmd works im trying to send the stuff in chat with colors
console.log("sry for being confused")```
how u sent that
"you are confused?"```
"sex"
diffrent lines
it isnt colors
holy fucking shit
--
the way you did it before was right
the language was just in a new line
when it isn't supposed to be
it's supposed to be in the same line as the backticks
so now im not 100% sure what im doing wrong but i have this in the util
module.exports = (message, client) => {
const GuildConfig = require('../models/guildConfig');
GuildConfig.findOne({guildID: message.guild.id}, function(err, doc) {
if (err) throw new Error(err);
if (!doc.djOnly) return true;
if (Boolean(message.member.roles.cache.find((r) => r.name.toLowerCase() === 'dj'))) {
return true;
} else {
return false;
}
});
};
shift enter
ffs
hey
if (!client.tools.checkPerms(message, client)) {
return message.channel.send({embed: {
title: 'You are not the DJ, you can\'t use this command',
author: {name: 'Music Boat', icon_url: client.config.embed_author_img},
color: client.config.embed_color,
}});
}
``` and this in the command but it will return the message either way
how do i keep my bot online 24/7 bc i have vsc and it is only online when i type node .
but i need t online 24/7
lol
its not
i have a mac
but what ever
and
just buy a vps
it turns off
rent a vps
ok how much it cost
make a batch script that is as follows bat :loop node . goto loop and keep your pc on 24/7
5 euros per months 1GB
ok
args is undefined on purpose so if(!args) or if(args !== undefined)?
you can definitely find cheaper than 5eur/mo
you just have to find the right providers
where do i place
he told you to make batch script
where do i place
const Discord = require('discord.js')
const bot = new Discord.Client();
bot.on('ready', () => {
console.log('Bot online')
})
bot.on('message', (message) => {
if(message.author.bot) return;
let prefix = `!`;
// hello there ['hello' 'there']
let MessageArray = message.content.split(` `);
let cmd = MessageArray[0].slice(prefix.length)
let args = MessageArray.slice(1)
if(!message.content.startsWith(prefix)) return;
if(cmd == 'ping') {
message.channel.send('pong');
}
})
that's not a batch script xD
o
ah let me tell you a way @tiny dune
I use this one, it's free
id recommend repl over heroku
what i do
and has a better upgrade path if you dont want to transfer to a vps down the line
what i do @outer perch
I uploaded my code to GitHub, privately
ask woo..repl is the answer and in your script add the client.login(token) function
Don't use any of that, heroku, repl or even Glitch is not made for hosting bots
and then I created an account on Heroku
use if you have no money
yes but good for beginners vx
No, they're only there for testing, not actually hosting it all the time, and no they're not 24/7
i have no money and need the bot on 24/7
you can ping your bot on a port with express js
Heroku is fully 24/7
if that is still possible
if you provide your debit card
heroku actually only provides 500 hours a month on their free plan
which is 24 days ish
Repl restarts your application every 10 minutes
Heroku has dyno hours which if it ends, your application is fucked
Glitch can host it but it'll require payment soon enough
750 if you have a credit card
and I did
which he does not
that's the only exception
which, if you have a credit card, i would suggest not using heroku still, and would suggest a google f1 micro
I NEED MY BOT ONLINE 24/7 AND I HAVE NO MONEY WHAT DO I DO
follow @solemn latch

just read what they said
HAHA
You don't actually return anything in the function - you return true/false in your database callback
im confused
Opera suggests localhost, the best 'website' if you have trust issues




i will always adore you