#development
1 messages ยท Page 966 of 1
i use node.js and code
what version are you using
lts
what
LTS
k
well how do you write code in the software, im having problems right now
[REDACTED]
@knotty steeple so?
i do, i used to use node.js
json isnt exactly an object because of the N (notation)
but u dont know to get a text editor
read the stackoverflow answer please
which one?
because that question is about json formatting and syntax, not the diff between JSO and JSON
ok u didnt even look at it
...dude
thank u cyber
which is why you have to parse it
a serialized one
serialized into a string
dude
I'll just stop arguing, it's useless to talk with rocks
json is a jso but serialized
...json is a js object
i mean this doesnt even make sense
period
holy fckin shit, I know that
hi
everybody thank you for helping others
heres a gift
did somebody claim it?
here
aw thought it was nitro
selfbots claim every gift
if I use process.exit to stop the bot. how would i start it again
process manager?
bruh'
what is wrong with this
client.on('message', message => {
if (message.content === '!Embed') {
channel.send(Embed);
};
});
do you name your embeds
wdym
if i have multiple
ok
so im trying to make a lavalink music bot with discord.js commando and this is my ready.js file it should log new node connected and on the jar file should say new connection or soemthing but it just says ready and wont say new node connected this is my code for the ready.js file
let {Client} = require("discord.js-commando");
const client = new Client()
const {ErelaClient} = require('erela.js')
module.exports = function() {
console.log(`Logged in as ${client.user.tag}!`); //log when the bot is ready to be used
console.log('ready')
client.music = new ErelaClient(client, [
{
host: "localhost",
port: 7500,
password: "anotherday"
}
])
client.musicPlayers = new Map();
console.log('Ready!');
client.music.on("nodeConnect", node => console.log("new node connected"));
client.music.on("nodeError", (node, error) => console.log(`Node error: ${error.message}`));
client.music.on("trackStart", (player, track) => player.textChannel.send(`Now playing: ${track.title}`));
client.music.on("queueEnd", player => {
player.textChannel.send("Queue has ended.")
client.music.players.destroy(player.guild.id);
});
};```
how do i copy the text someone wrote after a prefix
You slice off the message content by the prefix length.
how?
what language are you using
java
i was waiting to hear english
Lmao
lmao
You can use <String>.substring
what's the string
the message content
yello
i have a button, how can i do stuff with that button? so like when the button is clicked, i want to respond with a message saying smething like u click button
in js
webhook?
Why can't Discord play videos I put in my embed.
It tries to load the video but fails miserably ๐ฆ
you cant put videos in embeds iirc
Thought it was a bug
I think you can
Guess I need to find a workaround of some type
dont send it in an embed?
no uh, my end result is a save button, i click the button and it saves the config so like
~~no laugh at my shitty design pls ~~
Well, the most elegant solution I can think of is posting the link, which generates a seperate embed
But posting it in the first embed looks much better
@honest perch does that make more sense or
Use alert(), toasts (look up how to toast in whatever framework you're using), etc
Depends on how you wanna show
@digital ibex
Show a dialog box
Or a toast
If you're going for material design, snackbar also exists
but how would i even know when someone clicks it?
On click event
Idk what framework/library you're using so can't link to any docs about the exact details
But if you're using vanilla js
https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event
oki, thanks
ye, vanilla js
wait, ejs is vanilla js with html anyways
๐ฟ
lol
i looked at that before but im confused
wait nvm
how would i like
make another text appear now? i got ```js
button.addEventListener('click', (event) => {
// what do i do here?
});
let {Client} = require("discord.js-commando");
const { ErelaClient } = require('erela.js')
const client = new Client()
module.exports = function() {
console.log(`Logged in as ${client.user.tag}!`); //log when the bot is ready to be used
console.log('ready')
client.music = new ErelaClient(client, [
{
host: "localhost",
port: 7500,
password: "anotherday"
}
])
client.musicPlayers = new Map();
console.log('Ready!');
client.music.on("nodeConnect", node => console.log("new node connected"));
client.music.on("nodeError", (node, error) => console.log(`Node error: ${error.message}`));
client.music.on("trackStart", (player, track) => player.textChannel.send(`Now playing: ${track.title}`));
client.music.on("queueEnd", player => {
player.textChannel.send("Queue has ended.")
client.music.players.destroy(player.guild.id);
});
};```
what have i done wrong? it never says "new node connected"
thats my ready.js
how do i make a command that reacts to your message
NikM is client the actual client you're using, and not just some duplicate? What file is this?
NikM is
clientthe actual client you're using, and not just some duplicate? What file is this?
@sudden geyser it's ready.js
does anything log at all?
@digital ibex it logs that the bot has been turned on
But nothing else
If this is your ready file, are you sure client points to your client instance. Would it not come from another file?
i don't know what where it logs when the bot has turned on
It logs it in the console
im a dev for NikM's bot as well
okay.
good for u
i was going to say my question after but i misclicked
oops
ok but it wont log new node connected
so
ok, does it log ready which is underneath?
u've got a few messages where it says ready, which one doesn't log?
what message event isnt an on ready event that triggers it?
yes, but it could be breaking there
you're not doing anything, why is it suddenly breaking
its most likely ur message event
ok
how would I get an id using command
im trying to implement bot-banning which basically disallows the use of a bot from a member
going to be using a db to store times and ID's
it'll look something like
if(message.author.id == "")
xd
if(message.author.id == db.user.id){ code }
depends how you save your database information
ID: <ID>
Time Initiated: <Time>
Reason: <Reason>
}
what exactly are you trying to do, I am not quite understanding you
Bot banning
ok..
not allowing users to execute commands
so a simple command to ban with a bot
no
yea NikM gets it
I'll use time initiated to determine how much time in the blacklist
I have this thing thats getting the user's balance from a mysql using but the balance is retuning as undefined
let coin
coin = args[0]
const embed = new Discord.MessageEmbed()
.setColor(color)
.setTitle(message.author.username+"'s "+pairs[coin].name+" Balance")
.addField(pairs[coin].emote+" "+pairs[coin].name, balance)
message.channel.send(embed)```
example if I was banned at 12 AM and the current time is 4 am I was banned for 5 hours
async def whois(ctx, *, user: discord.Member = None):
if user is None:
user = ctx.author
date_format = "%a, %d %b %Y, %I:%M %p"
embed = discord.Embed(color=000000)
embed.set_author(name=str(user), icon_url=user.avatar_url)
embed.add_field(name="Joined", value=user.joined_at.strftime(date_format), inline=True)
embed.add_field(name='โ ', value='โ ')
embed.add_field(name="Registered", value=user.created_at.strftime(date_format), inline=True)
if len(user.roles) > 0:
embed.add_field(name="Roles [0]", value='None', inline=False)
else:
role_string = ' '.join([r.mention for r in user.roles][1:])
embed.add_field(name="Roles [{}]".format(len(user.roles)-1), value=role_string, inline=False)
embed.set_footer(text=f'ID: {user.id}')
return await ctx.send(embed=embed)```
why does it keep saying Roles [0] even tho i have a role
use setTimeout @torn ravine
I wanna make it server specific
// ur blacklist stuff here
setTimeout(() => {
// unblacklist stuff here
}, /* time in milliseconds */);
blacklist servers?
kinda. blacklist certain members in certain servers
I want to preform a function for each document stored in my mongodb database. I'm using mongoose and discordjs and this is what I have so far, but I'm not sure where to go next. Can anyone help?
db.once('open', function() {
var serverDocument = Server({ name: 'serverDocuments'});
var filter = {};
var serverArray = serverDocument.find({filter}).lean().exec(function (err, docs) {
docs.forEach()
});
});```
db.once('open', function() {
var serverSchema = new mongoose.Schema({
name: guildID,
channel: channelID,
zones: null
});
var serverModel = mongoose.model('serverDocuments', serverSchema);
var serverDocument = Server({ name: 'serverDocuments'});
console.log(serverDocument.name);
serverDocument.save(function (err) {
if(err) return console.error(err);
});```
heyo, how can i send a gif on discord.py? i used the code with `open('fd to gif') as f:
picture = discord.File(f)
await message.channel.send(picture)` but my bot returned <discord.file.File object at 0x04A800C8> instead of the gif :(
async def whois(ctx, *, member : discord.Member = None):
if member is None:
member = ctx.author
date_format = "%a, %d %b %Y, %I:%M %p"
embed = discord.Embed(color=000000)
embed.set_author(name=str(member), icon_url=member.avatar_url)
embed.add_field(name="Joined", value=member.joined_at.strftime(date_format), inline=True)
embed.add_field(name='โ ', value='โ ')
embed.add_field(name="Registered", value=member.created_at.strftime(date_format), inline=True)
if len(member.roles) < 1:
embed.add_field(name='Roles [0]', value='None', inline=False)
else:
role_string = ' '.join([r.mention for r in member.roles][1:])
embed.add_field(name="Roles [{}]".format(len(member.roles)-1), value=role_string, inline=False)
embed.set_footer(text=f'ID: {member.id}')
await ctx.send(embed=embed)```
In embed.fields.3.value: This field is required < error
maybe you need to convert it into a string
the 3rd embed.add_field is the problem
i tried that
theres nothing wrong
just value=str(<membercreatedat>)
if i have a role it works
if i dont it doesnt
tf
right
its pissing me off
the code is right
i cannot see 1 single error
@slender thistle
what do you think about this
@earnest phoenix wanna hear what the fucking problem was
i legit just switched the if and else around and made < 1 to > 1 and it worked
Discord isn't generating me a new token for my bot that is valid. Because I go to the website generate a token copy it put it in my config for my bot and then the console says invalid token.
Is the a way to fix this or would I need to contact discord
are you sure it's the token and not the secret
Yes it is the token
then you're not reading your config correctly
can be a stupid answer, but are you sure you saved the file?
Yes I am because it was working before then it just stopped I didn't change the code and then I go to start it again it says invalid token I get a new token from discord invalid token again
im using discord.js
member.kick('Test')
}```
it doesnt work but no error
And I know the config file is working properly because it checks for the file when I start it
someone help me
@clever garnet use !== instead of !member.id
wdym
ok im tryng it
Does anyone know why my tokens just stopped working
Ok so, I use - https://top.gg/api/docs#jslib
Spice up your Discord experience with our diverse range of Discord bots
I use ```js
client.dbl = new DBL('my token here yes', { webhookPort: 5000, webhookAuth: 'password' }, client);
client.dbl.webhook.on('ready', hook => {
console.log(Webhook running at http://${hook.hostname}:${hook.port}${hook.path});
});
client.dbl.webhook.on('vote', vote => {
console.log(User with ID ${vote.user} just voted!);
});
and votes does not work
any help?
my token is corrct, I am not stupid either, i double checked
let me try the more examples part
Uhm, I have a question, so my bot showed some errors. For some reason, it couldn't find the .guild attribute of a message object. The only way this made sense to me, was that someone must have DMd my bot. Is that right? Or do you guys maybe know a different reason?
most likely, yes
well now I need a way to handle dms..... Oh god
Hey, what would be the best node.js text editor for the Raspberry Pi?
@earnest phoenix google is your friend
if (message.content.startsWith(prefix + "ss")) {
const puppeteer = require("puppeteer");
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
const page = await browser.newPage();
await page.goto("https://example.com");
let fishq = await page.screenshot({ path: "example.png" });
message.channel.send(
new Discord.MessageEmbed()
.setDescription("welcome background set to")
.setImage("example.png")
);
await browser.close();
}```
i keep getting the error invalid form body
whats the error stack
wdym?
the full error
DiscordAPIError: Invalid Form Body
embed.image.url: Not a well formed URL.```
yeah but how would i form the url well
how would i get the url when it creates the path example.png
example.png is not a url first of all
yeah its the image file name
it doesn't work like that
its like saying make https://dferav4rvefvefrgrveabgrtcw45fecwvrfebrtc.com/ exist
all of them
@pale vessel I'm sure not JSON
its a format
yp
@celest basin i personally use mariadb but its fine to use mysql or mongo
or postgres
i use mysql. planning to move to postgres one day
i am satisfied with mongo
i dont have a dbl
@steel drum Thanks for ur sug
cool
ยฏ_(ใ)_/ยฏ
sqlite is not bad
Yeah
I haven't had any issues with it so far
Don't know what would happen if the bot was added to a thousand servers, though
id say start off with mysql or smth similar from the start if you can, so you don't have to handle that later on
sqlite is more than enough for 99% of bots out there
the only reason to go from sqlite into a database server is when your bot needs to scale across multiple machines
is sqlite better than mongodb for bots?
sqlite is a tiny DB based on files
mongo is noSQL
to put it into perspective, Discord (the platform) was based on Mongo in the beginning
ye, but which one is better for bots tho?
Discord using Scylla (nosql)
sqlite and mongo arent even comparable
isnt discord using cassandra?
not even the same type of db
they migrated it in like 2016
they switched to scylla @quartz kindle
when?
oh
sqlite scaling is linked to how your process scales
since its built into your process
the only downfall of sqlite is that it cannot do concurrent writes to the same database
but it can do concurrent reads
when?
@quartz kindle https://www.reddit.com/r/discordapp/comments/ewz9rf/discords_switch_from_cassandra/
lol
thanks
with the amount of messages sent per day
โInfinitely configurableโ is just another way to say โso many ways to shoot yourself in the foot youโll never get bored!โ In this talk we briefly explore the pitfalls of common Open Source system design and see what happens when you take the less-travelled path like ScyllaDB h...
hi, with bulma, how can i split these into half the page, like instead of it showing on 3 lines, show it on 2
basically instead of hello world \n hello world \n hello world do hello world | hello world \n hello world
this might help https://bulma.io/documentation/columns/basics/
im using components/message
let role = db.fetch(`role_${member.guild.id}`);
if (!role) return;
let ffff = member.guild.roles.cache.get(role);
member.addRole(ffff);```
im trying to add role on join by role id and i keep getting the error member.addRole is not a function
member.roles.add()
thank you
@quartz kindle tim tim
@_@
hi
yeah, but how would the css look like?
im confused
ah ha!
i got it, nvm
i used height
oof
I need to know how to start my bot back when I use process.exit to start it
You cant execute any code after process.exit() unless you're listening for exit/beforeExit.
Easiest thing honestly would be to use a process manager that auto resarts on stop
heroku does automatically restart but its rate limited
I can only do it so many times before it stops automatically restarting
It tries 3 times iirc
But as long as it successfully boots up before 4th attempt it'll restart automatically
Hello, I've tried many ways of doing this command but I can't get it... Could someone please help me to solve it?
if (message.content === `mm!dm`) { if (message.member && message.member.roles.cache.has(roles[0]) || message.member.roles.cache.has(roles[1])) { let args1 = message.content.split(" "); let id = args1[1]; let content = args1.slice(2).join(" "); bot.users.cache.get(id).send(content); } }
What's the issue
It just doesn't send the content :/
There aren't errors being showed in logs
It just doesn't send it, so I don't know what's wrong
ur chekcing if the message is mm!dm nothing more, u need to check if it starts with mm!dm
or just make a proper command handler
thats not going to change anything
it will fix issues regarding making wrong code that will not run when user input is provided
unless u tell it to, in his case he isn't, it won't
generally when I see message.content.startsWith("<prefix><command>") or message.content == "<prefix><command>" I gag
ngl
when i see people use d.js i gag
eris is life
troo
ur chekcing if the message is
mm!dmnothing more, u need to check if it starts withmm!dm
@digital ibex Man, thank you, I was too blind x)
It's solved now, really thank you
๐
I'm trying to do a reset inventory command, the command is pretty much done, the only thing that isn't done it confirmation message. I kept getting this error https://pastebin.com/raw/VhejYDxu
you spelled deleted wrong
lol
we can't evaluate and run your code for you with the same factors, debug your code, it's meant to be done when you get errors and it's meant to test your code
it's such a huge asset and people choose not to do it and instead go "thiS Not WORK HELP"
literally why
async def hhelp(self, ctx):
author = ctx.message.author
with open ('prefixes.json') as f:
prefixes = json.load(f)
em = discord.Embed(title="Tickets Help", description="", color=0xC110B1)
em.add_field(name="`{prefixes[str(ctx.guild.id)]}music`", value="Music commands")
em.add_field(name="`!admin`", value="Admin commands")
em.add_field(name="`!fun`", value="Fun commands")
em.add_field(name="`!picture`", value="List of pictures")
em.add_field(name="`!utility`", value="List of utility commands")
em.add_field(name="`!botutility`", value="List of bot utility commands")
em.set_footer(text="Echo discord bot | Tipe !help_(command) for help or usage on a command")
await ctx.send(embed=em)``` So on the one line where it says `{prefixes[str(ctx.guild.id)]}` I am trying to have the prefix returned from the JSON file right there that cannot seem to figure it out
You're not formatting it
I'll add my bot back when everything's settled and I get some sweet-looking gfx for it
How would I format that
f-strings or .format
Can you use F strings in embeds though
Why not
I didn't know you could that makes life 10 times easier
You're literally formatting a string and then send it
There's no difference
Yeah for some reason my brain said you should not do that because it's inside of a embed
Is it possible so send a user a DM directly from the shard file? I am using eris sharder. Trying to implement an auto vote rewards feature.
Hey, I've gotten another problem x)
let args1 = message.content.split(" ");
let id = args1[1];
const user = args1[1];
let content = args1.slice(2).join(" ");
bot.users.cache.get(id).send(content);
message.channel.send(`Message to ${user} Successfully Sent! โ
`);
}``` How can I get `${user}`'s username + tag? I'm only getting the ID right now :/
Discord.js
well uh that makes sense
user is not even an user object
^
maybe turn it into one by using client.users.get(args[0])?
i mean args[1]
like ```js
let user = client.users.get(args[1]);
๐ you're welcome
Is it possible to fetch a user directly from the ClusterManager of eris-sharder? The documentation is confusing.
Hey! Is heroku a bad hosting?
Im using discordjs v12 how can I check if the bot has the proper permission to send embeds in a channel
A!userinfo
@fiery stream wrong channel
@dawn trout explain
I have this
getBal()
} catch (error) {
message.channel.send(message.author.username+"'s "+pairs[coin].name+" Balance\n**"+balance[0][coin]+'**')
message.channel.send("I don't have the permission to send an embed in this channel. Please notify the server administrator to toggle the 'Embed Links' permission for me")
}```
theres the discordapi error no permissions
but it isnt catching
is getBal asynchronous?
yep
use return
then await it
await catch (error)?
No, await the function call.
await getBal()?
yeah
The error is self-explanatory. You need to mark the function as async (aka the function where you have that try {...} catch (...) {...} statement).
async try?
what is this problem
Did you try hovering over the squiggly red line? You're missing a comma.
ayy
how do i check who is in what hypersquad
py thx
AttributeError: 'Member' object has no attribute 'hypesquad_houses'``` can anybody tell me how to fetch hypesquad house
thx very much
its quite annoying
can someone help me
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
ok my question is
i got a rps command
and the bots runs up
but does nothing
command doesnt work
here is the script
if (message.author.bot) return;
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === `${prefix}rps`) {
let replies = ['rock', 'paper', 'scissors'];
let result = Math.floor((Math.random() * replies.length));
let uReply = args[0];
if (!uReply) return message.channel.send(`Please play with one of these responses: \`${replies.join(', ')}\``);
if (!replies.includes(uReply)) return message.channel.send(`Only these responses are accepted: \`${replies.join(', ')}\``);
if (replies[result] === uReply) {
console.log(replies[result]);
return message.channel.send('It\'s a tie! We had the same choice.');
} else if (uReply === 'rock') {
console.log(replies[result]);
if (replies[result] === 'paper') return message.channel.send('I won!');
else return message.channel.send('You won!');
} else if (uReply === 'scissors') {
console.log(replies[result]);
if (replies[result] === 'rock') return message.channel.send('I won!');
else return message.channel.send('You won!');
} else if (uReply === 'paper') {
console.log(replies[result]);
if (replies[result] === 'scissors') return message.channel.send('I won!');
else return message.channel.send('You won!');
}
}
});```
In my serverinfo command, I can see the list of server roles via this guild.roles.cache.map(r => r).join(', '). The only problem is that they are not shown in an orderly way, how can I order them?
hello
hello
`module.exports = (client,message,args) =>{
const voiceChannel = message.member.voice;
voiceChannel.join()
.then(connection => {
connection.voice.setSelfDeaf(true);
}).catch(console.error);
}`
.
its causing an error in server.js
and idk what to do to fix that
smh my internet is so shit rn
but send the whole js file if you can to us
instead of a few lines
cause the one you sent us is valid
How do you add code block to setDescription in an embed?
const testEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Error')
.setURL('https://discord.js.org/')
.setAuthor('test name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
.setDescription(${test})
.setTimestamp()
.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');
channel.send(exampleEmbed);
In my serverinfo command, I can see the list of server roles via this guild.roles.cache.map(r => r).join(', '). The only problem is that they are not shown in an orderly way, how can I order them?
never used code block in a description
not sure if it works
but
```language
code
```
It works
lol
Didn't you asked how to order the roles?
Refer to Simo's message
oh lol
im dumb haha
@balmy knoll Discord.Util.discordSort(guild.roles.cache) will order the roles like shown in the server settings :D
ok so really stupid question, I have an API that returns a 0x color in a string, and I need to get the raw 0x of that. Is there any way in JS to do this? I tried String.raw but it still seemed to be a string...
(also i said 0x because im not sure what they are called)
How can i remove the everyone role from the guild.roles.cache collection?
~~Hi. I'm trying to get an image from a private API of a service that I use. The URL looks like that: ```
//doc1.ecoledirecte.com/PhotoEleves/01234567890123456789_123456789.jpg
By placing `https:` before the text, I've been able to see the image 1 time. But then, it disappeared and left a 404 Not Found code. I haven't found any token required. Do you have any idea why this acts that weird?~~
Since it acts pretty randomly, I guess it's just a very big ratelimit.
^
404 shouldnt be a ratelimit response
@turbid bough yes, it seems you're right, but it still doesn't explain why I've been able to see it. Moreover, on the website of the service I was talking about, the URL remains the same, and the image appears.
it might be cache
and then it got removed at the same time the cache was still active
hmm.
yea thats weird
what does the // without the protocol mean in the beginning of the url? haven't found anything on internet
is that relative to another url?
wss:// like on websocketa
ftp://
it's none of these
https:// = http-secure
404 = non-existent file/thing

Thanks, I already knew that. I also know what is a protocol, thanks for your help anyway.
EDIT: the access to the image was restricted by cookies.
node . problem with VSC
can't start host for test bot
Like a module host not found
anybody fixes that
regarding my previous question, I would have liked to know if it's possible (through a library or anything else) to store cookies like if the client was a browser.
@ornate isle guildCreate event
@ancient sand what is your main file named? if it isnt index.js, then try doing npm init, accept everything, go to the new file it created (package.json), and change the main file to whatever your main file is
actually just do npm init -y
u dont need to answer yes to everything
it just makes package.json with default values
ah
showing the error might be helpful
you managed to show everything but the error message
oh
(node:8168) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
const { MessageEmbed } = require("discord.js");
module.exports = async (oldMessage, newMessage) => {
const db = require("quick.db");
let chx = db.get(`LogChannel_${oldMessage.guild.id}`);
let logchannel = oldMessage.guild.channels.cache.get(chx);
if (!logchannel || !chx) return;
if (chx === null) {
return;
}
const p = new MessageEmbed()
.setColor("#ff9900")
.setTitle("Message Delete")
.setDescription(`๐ ๏ธ **${oldMessage.author} has edited a message in <#${oldMessage.channel.id}> `)
.setFooter("Logging System || Made by Sabin")
.addField("Old Message", oldMessage.content, true)
.addField("New Message", newMessage.content, true);
logchannel.send(p);
}
help ?
there isn't a guild property on the message if it was edited in DMs
make sure to ignore messages edited in DMs
@cinder patio it wasn't it was edited in guild, but i want to say one more thing, after i edited the message, the bot still sent the message on the channel i set
so why i got the error if everything works ?
just ask
(Use `node --trace-warnings ...` to show where the warning was created)```
how I can fix that warning?
@lofty lagoon do not create a new listener per command
b-but Luca!
but how I create a command if I dont create a new listener
you use one listener to handle all commands
:
you have an if statement inside each listener, right?
you can keep that chain going with else if statements
yes
if (a == 1) {
} else if (a == 2) {
}
oh use that
ok
why it's say
SyntaxError: Unexpected end of input
at Object.compileFunction (vm.js:344:18)
at wrapSafe (internal/modules/cjs/loader.js:1106:15)
at Module._compile (internal/modules/cjs/loader.js:1140:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
wait
this is my code https://pastebin.com/sHnFwRW6
How can I make sure someone has put a prefix and then a second argument after that prefix?
@lofty lagoon that means your brackets are wrong, either missing a } or a ) or having an extra ) or a } somewhere
hey
are there any ways to counter command spamm through the discord.py api like a special func or class? or i have to right my own spam filters
pretty sure you have to write your own
there is a cooldown deco but yeah pretty much
How do you set off a command if a message starts with something and doesn't matter what else is in the message
assuming you're using js
yes
what is wrong with this? client.on('message', message => {
if (message.content.startsWith('-poll')) {
return message.content.slice(poll_p.length);
};
});
i want to make it so if you put -poll and then something it deletes -poll at the start
Unable to change my bot name from developer portal !!
Tried like 5 times but name doesn't changed while I can change name of my other bots
Is there a big difference between creating an discord embed object as a client property and creating a new discord embed every time I need one? Performance wise
@dusky crater are you sure you are changing the bot name and not the application name? also restart the bot to see name change
@mossy vine let me try
@mossy vine hey man the bot name in discord is not getting changed whereas the application name in developer portal is already changed !
Oh yeah lol , am dumb
Thanks for help guys
@opaque seal you mean like doing client.embed = new MessageEmbed()?
and then using client.embed every time?
Wouldn't the embed need to be reset each time it's supposed to be used then?
well if he always sets the same fields every time, it should be fine
but yeah, doing it like that will always mean your embed is not clean
any way to add alternative to command name like !example and !ex do same thing
i know how in discord.py if thats what ur using
if cmd == 'example' || cmd == 'ex'
how can i fix
failed to connect to server
what if its in a cog
You're using discord.py?
ye
commands extension?
yes
@opaque seal you mean like doing client.embed = new MessageEmbed()?
@quartz kindle yes
aliases kwarg in command decorator
failed to connect to server
yes ๐ค
Cause I have a set of embeds that gets sent many times @quartz kindle
command() has a aliases kwarg @plucky harness
it uses function names as command name
and also a name kwarg
@opaque seal if you always make sure there is no leftover dirt remaining in the embed from older iterations, then sure why not
there will be some minimal performance gains
i see ty ๐
failed to connect to server
@quartz kindle how can i fix ๐ค
@opaque seal if you always make sure there is no leftover dirt remaining in the embed from older iterations, then sure why not
what do you mean by that?
the embed will never reset
oh right
it will always remember its fields and values
yeah not a huge deal seen that I need same title and footer averytime, and I just change it's description
sure
thx
how can i fix
check your url
oof
lol
whats best way to pass variables to other file? i have these const { Users, CurrencyShop } = require('./dbObjects'); const { Op } = require('sequelize'); and i would need them in other file too? i thinked just client.variable, but i am not sure is it the best way?
client.variable is a good idea
as long as you dont accidentally replace some existing client namespace lmao
okay thanks :D
I use mongoose.connect on each models
How do u use the bot
guys
const Discord = require("discord.js");
const a = require("../ayarlar.json")
module.exports.run = async (client, message, args) => {
try {
await message.channel.send(`Komutlar: \n${client.commands.map(props => `\`!${props.help.name}\``).join(" | ")}`);
} catch (e) {
throw e;
}
}
module.exports.conf = {
enabled: true,
guildOnly: false,
aliases: ["commands","yardฤฑm","help"],
permLevel: 0
};
module.exports.help = {
name: 'komutlar',
description: 'Botta bulunan tรผm komutlarฤฑ gรถsterir',
usage: 'komutlar'
};//Dcs Ekibi
this is what help command im using now
I use mongoose.connect on each models
because of that? @quartz kindle
const Discord = require("discord.js");
const a = require("../ayarlar.json")
module.exports.run = async (client, message, args) => {
try {
await message.channel.send(`Komutlar: \n${client.commands.map(props => `\`!${props.help.name}\``).join(" | ")}`);
} catch (e) {
throw e;
}
}
module.exports.conf = {
enabled: true,
guildOnly: false,
aliases: ["commands","yardฤฑm","help"],
permLevel: 0
};
module.exports.help = {
name: 'komutlar',
description: 'Botta bulunan tรผm komutlarฤฑ gรถsterir',
usage: 'komutlar'
};//Dcs Ekibi
?????
how can i make it embedded?
s
@commands.command(name ="challenge" or "ch") is this supposed to work as challenge alternative
py
english only
@plucky harness No, use the aliases argument
so
Make it a list of command aliases
yes
Yes
folder
oh
@stuck scaffold i dont use mongoose so idk, but from reading their docs, it seems you're only supposed to connect once in your main file. all your models will inherit this default connection
I have this cooldown system:
// Cooldowns
let cooldowns = client.cooldowns;
if (!cooldowns.has(command.name)) cooldowns.set(command.name, new Discord.Collection());
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
}
}
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);```
And I need to reset to 3 seconds the cooldown of a command at a certain point of the code, and I tried it like that, but it's not doing it:
```js
const removeCooldown = () => {
// Remove cooldown
if(command.cooldown) {
const cooldownAmount = command.cooldown * 1000;
let time = now -cooldownAmount + 3000;
timestamps.set(message.author.id, time);
}
}```
we know
@command.command(name="MY_COOL_COMMAND", aliases=["THE_COOLEST_COMMAND_EEE"])
async def yee(self, ctx):
DO_SOMETHING_COOL()```
pep8 ree
english only
@summer torrent i want it caluclate my commands and send it in a embed with
/n
tf is not complying with pep8 there, var names? :^)
a function being a contant ๐ค
a what
@earnest phoenix make it read your commands folder and get all file names
wdym by "calculate my commands"
did you actually code this 
yes
module.exports.run = async (client, message, args) => {
try {
await message.channel.send(`Komutlar: \n${client.commands.map(props => `\`!${props.help.name}\``).join(" | ")}`);
} catch (e) { //Dcs Ekibi
throw e;
}
}
if you are a beginner, you can use guides
thanks shivaweco. it worked
I don't understand you
oh
Tim wouldn't it have problems if users type a command that sends an embed to both and it has to modify the embed for each of them at the same time?
About my embed thing.
yeah not a huge deal seen that I need same title and footer averytime, and I just change it's description
like you want to send 2 embeds to two different people?
shouldnt be a problem
how though?
as long as there are no async functions in between
In C#, does SomeArray.Max() raise an exception if SomeArray doesn't contain any elements?
as long as there are no async functions in between
What do you mean? My message event file is an async function
js is single threaded and synchronous by default, it cannot ever process multiple things at once
if you set the embed description, then send it, there is no way it can do that as the same time for someone else. once you pass it to the send function, it gets serialized and dispatched. only then will javascript be able to process the next chunk of code
@quartz kindle
const helpembed = new Discord.RichEmbed()
.setAuthor(message.author.tag, message.author.avatarURL)
.setDescription "Help Commands."
.addField(`${client.commands.map(props => `)
.setColor('RANDOM')
message.channel.send(helpembed)
like this?
but if you set the embed description, and then use an async function, and then send, the embed can change in between
what about if the embed is IN an async fun?
doesnt matter
Ok
tim like that?
as long as the code itself is sync, it will always be executed sequentially
why
@earnest phoenix you map function is broken
you need to make a for loop and put each command in a embed field
and fields require a field title
remember that there is a max num of fields
for embeds
I wouldn't do that personally
if you have many commands
i have 18 commands
max fields are 25
will it work?
it will, but it might not look like what you'd expect
also, you need to define a field title
you have to do it like this
ToS
in every command
o
You can get banned for using 3rd party themes
no
don't post these here
its still modified
It's against discord ToS
no need to witch hunt tho
they're doing so at their own risk
@quartz kindle my commands is like this
I'm just telling them, 'cause a mod of this server could ban them from here too
We don't ban for that
@earnest phoenix as you can see, in the example you showed, that bot divides commands into categories
Follow the Discord Terms of Service
Doesn't this include it?
-upto
The FAQ clearly states that it will take UP TO 1 week or more.
This does not mean it will take a week and does not mean it will take less than a week.
There is no set time for how long bot approval will take.
There is a queue and you're not first, nor are you last.
@quartz kindle its in my
you can do so manually or you can define a category in your command files
@opaque seal We do not ban for client mods in this server
mb then, did not know it
@quartz kindle then ill download project and categoryze it
sorry if my english\ bad.
add categories to your command files
that wasnt what i meant, but it works too lol
but if you do it that way you need to change your command loader
oh my friend made the command handler
show your command loader
whats it name?
should be in your main file
dm
a block of code that starts with fs.readdir
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
fs.readdir("./komutlar/", (err, files) => {
if (err) console.error(err);
log(`${files.length} komut yรผklenecek.`);
files.forEach(f => {
let props = require(`./komutlar/${f}`);
log(`Yรผklenen komut: ${props.help.name}.`);
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
});
});
yes, this code reads all files in the komutlar folder and adds them as commands
but doesnt have anything to process folders inside folders
so it will not be able to find your commands now
how do i fix
either move your commands back to how they were before or change the code to process sub-folders as well
i'd want to change code
personally categories commands in folders arent cool ๐ค
fs.readdir("./komutlar", (err,files) => ) this line is reading the contents of the komutlar folders. files is an array of contents
so you need to use it again on each result
for example
you'd then need to readdir again to get the files of each folder
fs.readdir("./komutlar", (err,results) => {
results.forEach(result => {
fs.readdir(`./komutlar/${result}`, (err, files) => {
files.forEach(file => {
let props = require(`./komutlar/${result}/${file}`)
})
})
})
})```
that would be a very basic example of reading files from subfolders
where do i put it
Someone has an idea for this https://discordapp.com/channels/264445053596991498/272764566411149314/720231684578213928 ?
@summer torrent
?
can you look thru dm
me??
https://sourceb.in/8c35359f44 whats happening here is that when i play a song then play anither it is supposed to add it to the queue but instead it plays it and then after that song is finished it replays it
can someone help
first of all, an array length can never be smaller than 0
I need help xd.
message.author.roles.filter(r => r.name !== '#everyone').map(role => role.name).join(', ')
Discord.js v11.6.4
What is wrong ?
Ah. thx ;)
I will try it out
hello
can someone tell me
how to make your bot repeat a string of messages
with certain time intervals
like how pokecord worked
or slotbot
awaiting messages?
Could someone help me pls ?
var user2 = message.guild.members.get(args[1])
How could i get the member of args[1] to see his roles?
error?
same
show the file that requires it?
This is a different error
the line
its my settings
const name = require('./name.json')
/ then
if i remove the command wont work dude
same error
@pale vessel wouldnt ../../ exit 2 folders
yeah
const ayarlar = require("../../ayarlar.json")
since it's on the root, might as well use /
try that
damn how much problems do you have
Tรผrk var mฤฑ
english only here
-notr
ฤฐngilizceden baลka dillerde konuลmak iรงin #memes-and-media kanalฤฑnฤฑ, top.gg hakkฤฑnda destek almak iรงin #support kanalฤฑnฤฑ kullanฤฑn.
how could i map all roles except of @.everyone?
member.roles.array().filter(a => a.name != "@everyone").forEach(role => {
with a condition- spoonfeed
i have this message.member.roles.map(role => role.name).join(', ')
you are highlighting the wrong code
@earnest phoenix also private the glitch project ๐คฆโโ๏ธ
dont u see the error
๐
bruj
u don't understand
it doesn't matter
And you are leaking credentials for your bot
you have to
which could be abused
there
files.forEach(file => {
^
TypeError: Cannot read property 'forEach' of undefined
at fs.readdir (/app/bot.js:42:13)
at FSReqWrap.oncomplete (fs.js:135:15)
whats this error
console.log(err);
right before files.forEach
cause files is undefined
which means something is returning an error
๐



