#development
1 messages Β· Page 976 of 1
No helpers on.
hey
so i want a cmd to send a random pic everytime the cmd i sent
i found this link that gives a random link
but it doesn't update everytime you use the link
Do you know how to play a bot
?
If your on mobile you can add to home screen and it saves
errr.....play a bot?
Wait wh-- I'm confused
https://pastebin.com/eiLgYGLH
@timber linden try using Set()
Anyone know how to get the avatar URL
Jeremy what library
djs
Set or sent
if yourself
message.author.avatarURL
if mentioned user
message.mentions.users.first().avatarURL
<User>.avatarURL() https://discord.js.org/#/docs/main/stable/class/User?scrollTo=avatarURL
There are options to go along with it.
@timber linden I'm confused with your codes what language is that
that code is clearly copy-pasted from somewhere
My brother helped me make it is why
yeah, EXACT same code from discord-anti-spam lib example
he did
It's ok just edit it
Ye imma make a different bot
It's open-source
like, you don't need to make another bot, just don't blatantly copy example code
What is the easiest type of bot to script
you gotta learn from it, not copy-paste it
Oh
I'll just use yt
A series*
if you want to use that lib, here's its page https://www.npmjs.com/package/discord-anti-spam
mkay
just give it a read, try to understand
not u @misty sigil
you need to restart it everytime
You can't just learn just by watching @timber linden you need to read it step by step
btw, ain't js dinamically loaded?
like, you could update the command file and have it updated in realtime
yea
without shutting down the bot
In my host I do that
but i use reload for that
Bruh I was coding and 2 hours felt like 10 mins no lie
welcome to programming club
Yeah same when you like what you're doing
coffee machine is in the room to the right, stackoverflow to the left
Sleep for 3 hrs. then
Goodnight !
Kk
Mk I'll read it
I'll just use other ppl bots
Webhooks allow you to post messages with a different pfp and username, and also send multiple embeds
And I think the API limits are less strict
webhooks don't require the bot to be in a server also
and they can't listen to events, only send messages
Woah they're like notification senders
they're a thing made up by discord.js, they are objects which are guaranteed to have only an id property
Nice I think I'll create one
@cinder patio what partials can do?
Sorry too many questions I want to learn :<
that's good, don't be shy to ask
nothing really, they are used for "raw" events, where there's not enough information about an object
Nice nice I'll come here everytime I'm having a hard time thanks!
Thanks bro Google!
Thanks for the intel guys
how do i check if my bot has permission in a channel
^
i seen that, maybe i just didn't pay enough attention
wait I'll help ya
client.roles.cache.map()
Maybe
I'm not yet pro but you can try that
hhm
channel.permissionsFor(user).has(permissions)
Nice there ya goo
how would i do that for my bot?
if(channel.permissionsFor(user).has("ADMINISTRATOR") {
return message.reply("You have administrator privileges");
if (!muteRole) {
message.guild.roles.create({
data: {
name: 'Muted',
color: '#bdbdbd',
hoist: false,
position: 0,
permissions: [],
mentionable: false,
},
reason: 'No role for mutes found, hence this was created.',
}).catch(console.error);
}
message.guild.channels.cache.forEach(async (channel) => {
await channel.overwritePermissions([
{
id: muteRole.id,
deny: ['SEND_MESSAGES', 'CONNECT', 'ADD_REACTIONS'],
},
], 'Mute role permissions');
});``` Anyone know why this resets the @[everyone] perms
and allows the muted user to see channels that are privated
Idk
Cannot read property 'me' of undefined
@timber linden #memes-and-media
const Permission = message.member.permissions;
if (!message.member.hasPermission("ADMINISTRATOR", { checkOwner: true })) {
message.reply("You don\'t have enough Permission!");
}
Like that
that doesnt account for channel permission overwrites
yes I was hoping he can get a grasp
that doesnt account for channel permission overwrites
@quartz kindle https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=updateOverwrite
found my answer
your previous code was almost correct, just client.guild.me is not a thing
What is ittt??
client.guild doesnt exist, but client.guilds does, it holds all guilds the bot is in
so you either do client.guilds.cache.get(guildid) or you get the relevant guild from the message, message.guild
Thanks thanks I learn new things
I have a little problem, So I have a command which should be 'Beaver poll question' but the bot also responds to 'Please poll question'.
Is there a way I could fix this? The code:
let args = message.content.substring(PREFIX.length).split(" ");
switch(args[0]) {
//poll
case 'poll':
if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have permissions, sorry!")
const EmbedPoll = new MessageEmbed()
.setTitle("Error:")
.setColor(0xff0000)
.addField("Error:", 'Please add a yes or no question for the yes or no poll to work.');
if(!args[1]){
message.channel.send(EmbedPoll);
break;
}
let msgArgs = args.slice(1).join(" ");
message.channel.send("π " + "**" + msgArgs + "**").then(messageReaction => {
messageReaction.react("π");
messageReaction.react("π");
message.delete({ timeout: 100 }).catch(console.error);
});
break;```
anyone know why this aint catching error
message.channel.send(embed)
} catch (error) {
message.author.send(embed)
message.channel.send("I wasn't able to send the help embed in this channel, please notify a server admin. I've sent the embed to your DMs instead")
}```
it will catch them if you await them
await message.channel.send(embed)
oh wiat i need to put async function run() { message.channel.send(embed) } and then await run()
await message.channel.send
oh
@spark breach you dont have any code that checks for prefix
ohhhhhhhh
const PREFIX = 'Beaver '; that is the prefix code, do you know how I can make it check if the prefix is being used?
check if the message starts with your prefix
no
Oof how then? (sorry I am new to coding xD)
startsWith returns true or false
if you do that, then args becomes either true or false
use an if
oh oki
also
oh oki
if (message.content.startsWith(PREFIX));
switch(args[0]) {
//poll
case 'poll':
if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have permissions, sorry!")
const EmbedPoll = new MessageEmbed()
.setTitle("Error:")
.setColor(0xff0000)
.addField("Error:", 'Please add a yes or no question for the yes or no poll to work.');
if(!args[1]){
message.channel.send(EmbedPoll);
break;
}
let msgArgs = args.slice(1).join(" ");
message.channel.send(":clipboard: " + "**" + msgArgs + "**").then(messageReaction => {
messageReaction.react(":thumbsup:");
messageReaction.react(":thumbsdown:");
message.delete({ timeout: 100 }).catch(console.error);
});
break;```
I am guessing the "switch(args[0]) {" needs to go away because there is nothing with 'args'?
.length returns the length of the text, so if prefix is Beaver its length is 7, so if you do that, you're checking if the message starts with7
Ah ty
thats not how you use an if
oh ._. xD
oki ill look
I mean most of my other ifs are like if(!message.member.hasPermission("ADMINISTRATOR", explicit = true)) return message.channel.send("You don't have permissions, sorry!")Or if(!args[1]){
yes
there are two ways to use an if
if(something) do something
or
if(something) {
do something
}
oh oki
you did ```js
if(something);
ooooh i see
so would it need to be like bot.on('message', message=>{ if(message.content.startsWith(PREFIX)) { (Lines of code) }
thats one way to do it yes
i like keeo my commands in different files
another way to do it would be to return if it does not start with prefix
for example
I'm guessing you mean this with that if(!message.content.startsWith(PREFIX)) return;
yes
Ah ty π
ill try if it works then
Oof what do I need to do with the switch(args[0]) {
you deleted the line that creates the args variable
oh yeah makes sense that it wouldn't work then xD
i need help how to make a logs system for discord.js
I am guessing I do need to add something here, and I think I can't leave it like how it was before
if(!message.content.startsWith(PREFIX)) return;
let args
switch(args[0]) {
Oof
I think how many arguments there are in a sentence
I think the first word is 0 the second is 1 and so on right?
yes, then you need to define it as that
extracting the content from the message
like you were doing before
oh oki
this is what I think should be right (which is probably wrong):
bot.on('message', message=>{
if(!message.content.startsWith(PREFIX)) return;
let args = message.content.substring.split(" ")
switch(args[0]) {```
i need help how to make (!warn [member] (optional reason))
if (!message.member.hasPermission(["CREATE_INVITE"])) return message.channel.send("You dont permission to use this command");
if(!message.guild.me.hasPermission("CREATE_INVITE")) return message.channel.send("I dont have permission to create Invites. Sorry");
let age = args.slice(0);
if (!age) return age = 0;
let max_age = age[0];
max_age = parseInt(max_age);
let uses = args.slice(1);
if (!uses) return uses = 0;
let max_uses = uses[0];
max_uses = parseInt(max_uses);
message.channel.createInvite({ unique: true, maxAge: max_age, maxUses: max_uses }).then((invite) => {
message.channel.send(
"Your new invite link is: https://discord.gg/" + invite.code
);
}).catch(e => {
message.channel.send("Oops, there is a error ! Please report to the dev `/esq-report <text>` !");
return console.log(e);
});
OUTPUT :
(node:136753) UnhandledPromiseRejectionWarning: RangeError: Invalid bitfield flag or number.
Pls help me, sad :((
Ah
I don't think you need the (see command line) twice, however I think that wouldn't fix it if (!message.member.hasPermission(["CREATE_INVITE"])) return message.channel.send("You dont permission to use this command"); if(!message.guild.me.hasPermission("CREATE_INVITE")) return message.channel.send("I dont have permission to create Invites. Sorry");
@earnest phoenix the permission field is wrong it's CREATE_INSTANT_INVITE https://discord.js.org/#/docs/main/stable/class/Permissions?scrollTo=s-FLAGS
Are you SURE you didn't leak your bot's token anywhere
fuck fuck fuck
go change your token if you didd
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
click on your bot
the tab 'bot'
and regenerate the token
ok i thanks
This is what I want my args to contain:
how many arguments there are in a sentence
the first word is 0 the second is 1 and so on right?
this is what I have which doesn't work, could anyone help me and say what I need to change?
if(!message.content.startsWith(PREFIX)) return;
let args = message.content.substring.split(" ")
switch(args[0]) {```
it would help you a lot if you leaned some javascript basics
message.content is a string
strings have a substring function
its a function, not a property
something.property this is a property
something.function() this is a function
this is what the substring function does: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
Do you know what I need to change it to for it to work? xD
I uploaded my bot to glitch.com
Yeah?
what
yea
That is weird
show your package.json, also show the logs that say its installing
{
"//1": "describes your app and its dependencies",
"//2": "https://docs.npmjs.com/files/package.json",
"//3": "updating this file will download and update your packages",
"name": "Mari0",
"version": "0.0.2",
"description": "Discord bot Mari0!",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@discordjs/opus": "^0.3.2",
"discord.js": "^12.2.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"ffmpeg": "0.0.4",
"ffmpeg-static": "^4.2.2",
"fluent-ffmpeg": "^2.1.2",
"moment": "^2.26.0",
"opusscript": "0.0.7",
"random-puppy": "^1.1.0",
"ytdl-core": "^2.1.6"
},
"engines": {
"node": "12.x"
},
"repository": {
"url": "https://glitch.com/edit/#!/hello-express"
},
"license": "MIT",
"keywords": [
"node",
"glitch",
"express"
]
}
looks fine, can you show your logs?
How can I pass my glitch project to Visual studio code
looks fine
Before I make my bot
is that happening every time your uptimerobot pings? @wet iron
How can I pass my glitch project to Visual studio code
@earnest phoenix I don't want to use glitch anymore I want to move to another platform
@earnest phoenix visual studio is just a code editor, not a hosting service
@earnest phoenix visual studio is just a code editor, not a hosting service
@quartz kindle i want to host my bot with heroku
is that happening every time your uptimerobot pings? @wet iron
@quartz kindle I just see the bot offline, and then I check glitch and it says node installing, I check the uptimerobot and it says "Monitor down"
your main bot file is named index.js?
yes
@earnest phoenix never used heroku but i think they use github no? so you would need to copy all your code files to your pc, then upload them to a github account
Tim heroku does use github yes
@wet iron so the logs basically just get stuck in "total install time"
and nothing ever happens?
What's wrong with making my bot online?
Did I script it right tho?
@timber linden that looks like a package.json file
@quartz kindle heroku uses github
tim do you know what I need to change for the args it to work? I've tried a few things they didn't work tho
Oh ok
@wet iron so the bot is working?
lemme check again
let args = message.content.split(" ")- (either way this didn't work)
wait-
i didnt use a ';' aswell
It still does not show online
@timber linden package.json files are just control files, not actual code
@wet iron so the bot is working?
@quartz kindle yes but then when i close the tab and leave it for the uptime robot to do its thing it never boots and when I open the glitch again it installs node again
Ohh
@wet iron so if you close glitch, it goes offline? and if you keep glitch open it stays online?
yes
if you keep glitch open for a long time, does it stay online all that time?
Ugh
yes its still online
well, then either something is wrong with glitch, or with uptime robot. without proper logs we cant know whats going on
try keeping it open to see if it ever crashes
ok
Might as well just quit this
@timber linden are you trying to make a bot in your phone?
what tools are you using?
thats just a code editor, its not enough to run a bot
if you want to actually code a proper bot, no
but there are some "bot maker" apps
with limited functionality
I'll try repl
same as glitch and heroku
It works on phone
its all online
i mean your coding files
your code is not saved in your phone
the code you write is kept in their platform
from where it also runs
Oh.
I'll be on PC later
and websites
i need help when i try this showing me message is not defined
which app
i need help when i try this showing me message is not defined
@clever wing -botprobably contains your message.
@timber linden i dont know anything about spck, but it looks like it runs browser javascript
K
javascript bots are usually run using node.js
which is a non-browser javascript interpreter/runtime
micro-hosting services such as repl.it, glitch and heroku have node.js built in
or you can also install node.js on your pc and run it from home
When I'm on PC I can do this.
but node.js doesnt work on phones afaik
dont they literally distribute android builds
I programmed my bot using Android Phone which is not rooted via termux
last i heard, the termux method had issues with installing modules from npm
but if its fixed now, awesome
Yup yup gladly it's fixed
TIM
I managed to launch the bot without removing any .js, it was as easy as uploading it to github.com and with heroku hosting it
glitch.com is shitty for bots
I use heroku too.
@quartz kindle the bot is still online
it didnt crash
and the uptime robot says the bot is down
error code 403
Ping services are disallowed and blocked by Glitch now
well frick
Does this package work? https://www.npmjs.com/package/top.gg
"official" except not official
you're better off just manually making requests lol
it's just a fork
most of the libs are really trash, well the .net one is cause cough veld code
it's a fork of it
An outdated fork
https://www.npmjs.com/package/blapi
here is good one
people fork stuff, make some minor changes, release it on npm then proceed to abandon it
most of npm is basically that
Fork > add one line of code > ? > profit
If it sounds attractive
it gives you popularity points to have libs on npm
How would I write an eval command?
I use heroku too.
@hoary lily what to do so that the bot does not disconnect you
Ton what language.
That's not a language, but JS I can infer. Make a command like you usually would (if you have) and use JavaScript's eval() function and pass the user input. Make sure only people you trust (like yourself) can use it.
eval evaluates a string as js code
Alright
You should also take a look at the util module's inspect function. It'll help you in displaying the result.
your wrong
thanks
it needs to be an ip
it needs to be the IP of the vps right?
what is the common localhost ip?
127.0.0.1 iirc
idk, i just saw something with localhost xD
ill read up to check
127.0.0.1 iirc
Yup that's the most common one
it needs to be the IP of the vps right?
Idk, probably I might be wrong tho
do you guys think this would play nice with d.py cogs? https://github.com/PandaXcentric/game_apis/blob/master/README.md
i dont understand these docs at ALL
hello guys, can you help?
how to make a count of mentioned in the message?
for example, user1 hugs user2.
User1 hugged N times
User2 has been hugged N times
i`m new with coding, sorry for the stupid question
i use discord.js 12
how can i make count how many times the message author hugs users?
I tried to insert the count into my finished code, but it only takes into account the mentioned user.
Even if i dont mention anyone, the bot thinks i mention myself..
i tried differently, but my brain is already exploding.. 2 days i cant understand my mistakes

you'll need a database
have it
dont laugh much, i try(
const Discord = module.require("discord.js");
const fs = require("fs");
const config = require(`../config.json`)
const hugs = require('../db.json');
module.exports.run = async (bot, message, args) => {
let member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
let msg =
member === message.member
? `${message.author} hugs everyone`
: `${message.author} hugged ${member}`;
let gif = [
"IRUb7GTCaPU8E",
"u9BxQbM5bxvwY",
"3EJsCqoEiq6n6",
];
let selected = gif[Math.floor(Math.random() * gif.length)];
let id = member.id || message.author.id
let hugCount = hugs[id];
if (!hugCount) {
hugs[id] = 1;
let embed = new Discord.MessageEmbed()
.setDescription(`${msg}`)
.setColor("RANDOM")
.setFooter(`${member.user.username} hugged for the first time.`)
.setImage(`https://media.giphy.com/media/${selected}/giphy.gif`);
message.channel.send(embed);
} else {
hugCount = (hugs[id] = hugs[id] + 1);
let embed = new Discord.MessageEmbed()
.setDescription(`**${msg}**`)
.setColor("RANDOM")
.setFooter(`${config.prefix}${module.exports.help.name} | ${member.user.username} has been hugged ${hugCount} times.`)
.setImage(`https://media.giphy.com/media/${selected}/giphy.gif`);
message.channel.send(embed);
return message.delete()
}
fs.writeFileSync(
"./db.json",
JSON.stringify(hugs),
(err) => console.log(err)
);
}
module.exports.help = {
name: "hugg"
};
How do you get such nice code blocks
hello
When we are on db is it possible to use SQL?
I googled it but could not find anything useful π¦
errrr....what?
that doesnt even make sense, Database language is SQL
yes there are more than one
Use a SQL server I mean
in general i managed to get a count of user mentions but i want to simultaneously get a count of messages from the message author
i changed let member to different values but it works adequately only all at once.. -_-
there're 4 kinds of dbs (afaik): NoSQL, SQL, Non relational and JSON-based
latter is the worst possible db kind
There's no way to get a count of messages from a message author unless you save all messages in a DB
you can't fetch X user's messages separately
Guess I need to phrase my questions better rereading it I understand the confusion
I am thinking about liteSQL or a normal SQL server but not sure what is better.
i need help how to make a welcomer bot in discord.js
But SQlite is a different type of db right?
I can host a SQL server on my domain but the bot generates a SQLlite server.
i need help how to make a Server Greeting for discord.js
SQLite IS the server on its own
Everything is SQL except NoSQL
sqlite is file-based, not service-based
Everything is SQL except NoSQL
@hushed jungle nosql IS sql
nosql stands for Not Only SQL
It's partly SQL
it's SQL+
i need help how to make a Server Greeting for discord.js
that is, i dont need change anything, just add another 1 json database file?.. (i have 200 iq, yes)
I know what it stands for and understand it's SQL and then some extra
What is the IP that the vote is sent to on my VPS?
anyway, back to original question
sqlite is file-based, you'll need some database manager to deal with it
sqlite studio is a great one
some ides also have built-in database managers
Can args type be 2 different?
For example
type: "role"||"member"
??
discord.js commando
Discord.js commando
idk what d.js commando is
but you just need to check for both matches
all you need to do is read the docs https://discord.js.org/#/docs/commando/master/class/Command?scrollTo=aliases
literally found it on my first try
Hey.
U dont know about this
this isnt what i am asking
Ignore me.
if you say so...
How do I make the webhook?
just note that the docs has everything you need, and not explaining your issue despite I stating that I don't know about d.js commando won't make your help appear from thin air
i need help how to make a Server Greeting for discord.js
@north hollow put your message inside a guildmemberjoin event
@round garden webhook for top.gg votes or normal discord webhooks?
have you setup a webserver (like express.js)?
where is the bot hosted?
vps
ok thanks
the port will need to be forwarded to allow external connections
how do I do that?
and the endpoint would be where dbl should attempt to connect to (default is dblwebhook)
sudo ufw allow PORT/tcp
windows π
ok thanks
note that 80 and 8000 will mostly conflict with other stuff, so avoid those
is 42069 ok?
probably
yw
@lyric mountain wtf is guildmemberjoin event and where is that
it's guildMemberAdd actually
this will trigger whenever someone join the server
o ok
@lyric mountain so like this
client.on('guildMemberAdd', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log');
// Do nothing if the channel wasn't found on this server
if (+channel) return;
// Send the message, mentioning the member
channel.send(`Welcome to the server, ${member}`);
});
@lyric mountain hello
try it
how to restrict some commands to nsfw channels only?
check if channel is nsfw
what
most libraries should have a channel.nsfw property
Channels have a property of nsfw which is true or false
if(!message.channel.nsfw){ message.channel.send("This command can only be used in channels marked nsfw."); return; }
this is good?
how do i verify my bot?
yes
Verify for who?
my bot
if you submitted your bot to top.gg you need to wait for it to be verified by the moderators
verification can take up to 2-3 weeks
nevermind i found
if (!message.channel.nsfw) return message.channel.send('TEXT')```
literally the same thing lul
Hii, I'm currently looking for a gif like this one(https://mrsheldon.me/files/785375.gif), but without the Discord application, only with this little sparkles. Is there something like that?
- I'm pretty sure that's trademarked/copyrighted or whatever(Don't take my word for it, I haven't been to law school)
- I don't believe that has anything to do with bot development. You should be asking that in #general or #memes-and-media probably
you might find similar gifs if you google it, but that one was probably custom made for discord, so you wont find anything with those exact same sparkles
You could probably remake it with an HTML5 canvas
@lyric mountain can I use dblapi.js to make the webhook?
Hey, I'm making my first bot, just trying to check if the user passed in from a command exists in the server or channel (doesn't matter which in this case, though server is preferable - code snippet gets members from channel).
The command looks like !win @username. It's getting to the correct if statement from the !win part of course, but I'm not sure how to check if @username is in the server.
Here's a code snippet of something I've tried, though I've spent about 4 hours trying various things to get the comparison to work. The arguments[0] is the @username part, a userID# from what I can tell. I've tried using a substring to get just the ID# from it, but no combination of that and the comparison methods I've tried have worked.
I'm available to hop into VC if that'd be easier, thanks for any help!
bro stop advertising
@loud hollow you will need to fetch it as members are not guaranteed to be cached
unless you use the fetchAllMembers option
but thats a huge waste of resources and generally not recommended
also, for mentions its preferable to use message.mentions instead of parsing the id from message.content
unless you want to allow for both mention and id
Hey can anyone help me code a custom prefix thing, so people in any server can just user !prefix set (thierprefix) and it changes the prefix for their server on my bot
ping me if someone responds
can I use dblapi.js to make the webhook?
@earnest phoenix thx
@earnest phoenix please dont tell people to watch random videos to spoonfeed lmao
can i write turkish?
@lyric mountain can I use dblapi.js to make the webhook?
@round garden sorry for disappearing. No webhooks require a listening server to be setup
The farthest you can go with the lib is checking for user votes or posting server count
you can, dblapi creates a webserver for you
const server = createServer((req, res) => {
console.log(1)
})
server.listen(5000)``` How comes this isn't logging?
I'm port forwarding as well
import { createServer } from 'http'
home
you may need to port forward port 5000 in your router/modem
damn I'll try it on my vps
how do u ban everyone with eval
java or python
im doing an experiement
in a test server
Am I using .sort right?
async getTopMargins() {
let products = await apiFetch(this.apikey, "skyblock/bazaar")
let array = Object.keys(products["products"]).map(i => products["products"][i]["quick_status"])
let list = array.sort(function (a, b) {
let aMargin = a.buyPrice*0.99 - a.sellPrice
let bMargin = b.buyPrice*0.99 - a.sellPrice
return bMargin - aMargin
})
console.log(list[0].buyPrice*0.99 - list[0].sellPrice)
return list.splice(0, 5)
}```
list[3].buyPrice*0.99 - list[3].sellPrice is higher than list[2]
hes asking another question, not answering yours
i dont use java nor python
i use javascript
so i cant help you
@empty owl you're comparing a with a, then b with a again, is that intended?
def start_server():
listener = socket.socket()
listener.bind(("192.168.1.124", 65))
listener.listen()
client, address = listener.accept()
while True:
data = client.recv(6000)
print(data)
When I press the Test button on the webhook section of the page, this code doesn't receive anything. Would anyone know why?
@winged mulch you've bound to a private ip
no, 192.168.0.0/16 is private
I have to set it to my public IP?
@quartz kindle huh
Thanks @brisk surge
np π
Its saying it can't assign to the requested address.
Maybe I should try a diffrent port?
@quartz kindle okay I fixed it
async getTopMargins() {
let products = await apiFetch(this.apikey, "skyblock/bazaar")
let array = Object.keys(products["products"]).map(i => products["products"][i]["quick_status"])
let list = array.sort(function (a, b) {
let aMargin = a.buyPrice*0.99 - a.sellPrice
let bMargin = b.buyPrice*0.99 - b.sellPrice
return bMargin - aMargin
})
console.log(list[0].buyPrice*0.99 - list[0].sellPrice)
return list.splice(0, 5)
}```
is there anything wrong with this
table
@brisk surge I think I'm doing something wrong on top.gg because I can POST to it from inside my network using my external IP.
nae
your router will just route packets back in straight away
nat hairpinning
see if your port is actually open first
It is
through a site like canyouseeme
def start_server():
listener = socket.socket()
listener.bind(("0.0.0.0", 165))
listener.listen(6)
client, address = listener.accept()
while True:
data = client.recv(6000)
if data == None:
return
print(data)
What is the point of this attach thing? https://github.com/Androz2091/top.gg/blob/master/src/webhook.js#L90
An official module for interacting with the discordbots.org API - Androz2091/top.gg
is there any good reasons to upgrade from discord.js v11 to v12? i'd rather not have to change up things in my bot but if theres a good reason to do it i probably will
in a couple months v11 just wont work
What is the rate limit for changing a voice channel's name?
rate limits are dynamic
they adapt to you if you spam the endpoint
however the current know ratelimit for that is 2/10min
@slender thistle once check ur dm sir
ok hi
i need help with this thing
so basically i'm getting the playing time of the song
but it return undefined
k
Uhm I think that's
const playingTime = client.voice.dispatcher.streamTime.fetch();
Maybe but wait for the real devs haha
whats the easiest way to call a function inside another file
i was looking at another bot's code on github and it did process.directory.file.function() but it says undefined for me
from DiscordAPI.raincord import Discord
@winged mulch
Know about this
Module
@halcyon ember You want to call a function from another file?
yea
Python?
js
Oh sorry, I only know Python. I would assume you would use an import statement and treat the file like a package?
You might want to ask in one of their support servers.
@earnest phoenix You may have pinged the wrong person, I don't know anything about Javascript.
i think its enought to export the module
then call it in the file where you want to use the function
module.exports = function(owner) {
...
}
```as example
here is the stackoverflow page where i found this info https://stackoverflow.com/questions/37613507/export-a-function-with-node-js
how do i make the display role members seperate from online members true using discord.py? my code: py server = ctx.message.server perms = discord.Permissions(display_role=True, allow-mentions=True) await client.create_role(server, name='thing', permissions=perms)
@halcyon ember ive enver seen "process.directory.file.function()" but i have seen
// module.js
module.exports = {
hi() {
console.log("hi!");
}
};
// file you want to import
let { hi } = require('./module');
hi();
how do i make the display role members seperate from online members true using discord.py? my code:
py server = ctx.message.server perms = discord.Permissions(display_role=True, allow-mentions=True) await client.create_role(server, name='thing', permissions=perms)
oh ok
does anyone know the role settings
Wdym with that?
like you know in role settings
there is the display members separate from online members
i have no idea how to call that
@spark breach
Hmm, idk how to call that either sorry
ahh ok
hoisting
@earnest phoenix You may have pinged the wrong person, I don't know anything about Javascript.
@winged mulch it's an python
Dude
from DiscordAPI.raincord import Discord
These is module or library
U know this
anyone know if image manipulation is possible with dsharpplus or discord.net?
The answer to this question is the same as to "is image manipulation possible with c#"
Which yes it is
do you have an example of how i would start that i see canvas is used with discord.js but i havent seen any examples or even information on how to do so with discord.net or dsharpplus
Even though the focus is on resizing, they should all be capable of drawing and such
awesome thank you
hello, i'm learning js atm.. can anyone help me fix my mistake?
{
if (arguments.length == 0) { return receivedMessage.channel.send("Invalid")}
const name = arguments;
msc = malScraper.getInfoFromName(name)
.then((data) => console.log(data))
.catch((err) => console.log(err))
receivedMessage.channel.send(msc)
}``` i did this thing and the error i'm getting is ```Error: [Mal-Scraper]: Invalid name.
at C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:189:14
at new Promise (<anonymous>)
at Object.getInfoFromName (C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:187:10)
at anifoCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:32:26)
at processCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:26:9)
at Client.<anonymous> (C:\Users\7thghoul\Documents\Syden\sydenii.js:16:9)```
hopefully i should be able to use this along side dsharpplus im trying to place 2 member avatars ontop of a single image
it shows the data when the name is predefined
You forgot the semicolon on line: receivedMessage.channel.send haha
You forgot the semicolon on line: receivedMessage.channel.send haha
i added that and still seeing the same errorError: [Mal-Scraper]: Invalid name. at C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:189:14 at new Promise (<anonymous>) at Object.getInfoFromName (C:\Users\7thghoul\node_modules\mal-scraper\src\info.js:187:10) at anifoCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:32:26) at processCommand (C:\Users\7thghoul\Documents\Syden\sydenii.js:26:9) at Client.<anonymous> (C:\Users\7thghoul\Documents\Syden\sydenii.js:16:9)
Oh ok
when i predefine the input
it shows this
at RequestHandler.execute (C:\Users\7thghoul\node_modules\discord.js\src\rest\RequestHandler.js:170:25)```
is it because the output is too big?
Client.<anonymous>
?
Nvm that I'm thinking hha
Have you defined msc?
yes
Anyone know how to fix this with dsharpplus?
Says x doesnt exist in context in namespace
Lol?
@soft wind i dont think you can nest functions with &&
using (func) in each function may help a bit
it might solve the error
I'm not completely sure what you mean by that
i meant like this (x => ..) && (x => ..) || (x => ..) or something like that.
I tried that it gave me same error :/
ok what
x => x == y || x.includes(t) works if you meant this
I think I fixed it
Yes that's the fix like @pale vessel just pisted
Posted
Thank you
I was trying to define x each time
Now I'm off to figure out drawing with .net core gonna be fun 
Is there anyone here that can make bots in C# and you're good at it?
do you have a question or?
@pale vessel any idea on this one?
can someone help me?
I deployed my bot on heroku
and
it won't read the procfile which says worker: node bot.js
it just makes it as web
which leads to an error with port
cause there is no port
2020-06-17T09:29:29.631430+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-06-17T09:29:29.648404+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-06-17T09:29:29.730388+00:00 heroku[web.1]: Process exited with status 137
2020-06-17T09:29:29.769100+00:00 heroku[web.1]: State changed from starting to crashed
137 iirc says "not enough memory"
I searched on the internet
and they said its cause that web start
dyno
with web: npm start
so I need a procfile which says worker: node bot.js
sry for ping
any idea how to make this badge system :
.addField('Badges', `${owner}\n ${nitrosubs}\n ${botowner} : '**No Badges**'`)``` to show No badges text when there is no badge
because right now if there is no badge userinfo not wokring
im broke
ternary operator easy
Well check if they have any badges if not type no badges
you could use condition ? true : false
@earnest phoenix Can you ask a more specific and more detailed question? Like what you mean by badges?
right now if you write wi-userinfo dont work because there is no badges option set
and i dont know how to set it
i have badges but for example if you write wi-userinfo , userinfo dont show because there is "No Badges" text
any idea?
@earnest phoenix
Still no clue what you mean by badges, but
Assuming that since you're using badges plural, you're talking about an array
i mean if there is no badge on profile
to say "No badges"
if you dont have a badge to say "No badges" here
check if user has badge or not
You can do
.addField(badges.length ? `${owner}\n ${nitrosubs}\n ${botowner}` : '**No Badges**')
lol
and wtf is bot owner
You can do
.addField(badges.length ? `${owner}\n ${nitrosubs}\n ${botowner}` : '**No Badges**')
@earnest phoenix lol
but yea thats the idea
show your code
@tight plinth its a badge
show your code
@tight plinth I have no idea what they're trying to do specifically, but I have a general idea of what their problem is based on their question
.addField('Badges', `${owner}\n ${nitrosubs}\n ${botowner} : '**No Badges**'`)
let owner = await db.fetch(`owner_${user.id}`) || "";
let botowner = await db.fetch(`botowner_${user.id}`) || "";
let nitrosubs = await db.fetch(`nitrosubs_${user.id}`) || "";
let nothing = await db.fetch(`nothing_${user.id}`) || "";
if(owner) owner = `${owner}`
if(nitrosubs) nitrosubs = `${nitrosubs}`
if(botowner) botowner = `${botowner}`
They want to list the badges if there are some, and if not, then they want it to print "No badges"
yes
but if i write that is not working
man
i just said
this sucks
erm
You should see the official discord.js support channels. They're hell. People ask about typeerrors
with your current code u cant lol
Okay, so I'm not really following at all anymore. I don't think that you should be storing a user's badges in a database
According to a quick google search, there is no way to learn of a user's badges through the discord API
i see people doing if (array.length) but i usually do if (array[0]) because it's shorter lul
@pale vessel do u r have rart? that only works if the first value of an array is a truthy value
such as [0, 1, 0, 0, 1, 1, 0, 0][0] would return false
because 0 is a falsey value
It's more uniform and reliable to use array.length
@pale vessel do u r have rart? that only works if the first value of an array is a truthy value
@earnest phoenix which is what i always need
so yeah
^
that's not universally true for every person, and is not good advice to give to use a method like that to determine whether an array has elements inside it
i didn't give any advice did i
Saying "I do x because it's easier" in a channel full of impressionable young devs is tantamount to advising it in general(bad wording, i know, but I hope the point still goes across)
i'll take it
i dont always use easiest methods tho, like in loops, nowdays i use for(let i = 0...) loop.
Care to elaborate on your issue?
try Date().now() also if still wont work try (new Date(Date.now()))
@low orbit it has been 50 years since 1970
which is when Date.now() was 0
its a unix timestamp
yes because its unix
use new Date().toLocaleString()
fixed
what do you want to do?
if you want to know how much time passed from one timestamp to another timestamp, you need to subtract them
why +?
i dont get it
if you have a stored timestamp, and want to know how much time has passed, then you do Date.now() - storedTimestamp
then your stored timestamp is wrong
or is not a timestamp
yeah thats not a timestamp
how are you storing that?
https://corynth.is-inside.me/wCGa49WP.png what does this error mean (using typescript)
then you need to do this
Date.now() - (Date.now() - duration) or Date.now() + duration - Date.now()
i mean, depends what you want to use it for
the problem is
that wont work
you need a starting point
when the mute happened
it has to be a timestamp
ah
then this Date.now() - (timestamp + duration)
console log the timestamp
import Eris from "eris"
import config from "./config"
const client = new Eris(config.token)```This is my code
https://corynth.is-inside.me/wCGa49WP.png This is my error
I'm confused
isnt it import Client from eris?
@low orbit thats a timestamp as a string, not as a number
@golden condor the source code shows Eris as function
so you can use either client = new Eris.Client(opts) or client = Eris(opts)
the Eris version should work without the new keyword, because it returns an already instantiated client
@golden condor the reason new Eris works in js, is because js doesnt care if you use the new keyword on non-classes, while ts does care lmao
Does someone know a better IDE then glitch cause all my bots keep reinstalling the npmβs for no reason which means I have to start my bot manually which means itβs never online anymore
i heard that glitch blocked uptimerobot
@low orbit now do the math from before, and it should give you the time difference correctly
Any other websites like uptimerobot that work for glitch?
@low orbit then you're still doing something wrong
console.log all values
so it should work
unless your modlogs are still being saved as strings
wait
you're doing modlogs.time in one, and modlogs.timestamp in the other?
Any other websites like uptimerobot that work for glitch?
@mental furnace status cake
ikr don't they recommended it
Idk but this didnβt make my bot go down immediately so thatβs good
How to make my bot wait for user input?
Like the person does C!test and the bot asks Type your name bro
They made a thread for it
@earnest phoenix which library
here`s more info about the pinging block from glitch:
One of our big challenges is dealing with third-party services that ping Glitch to keep apps awake. Not all of these services are as reliable as weβd like, and sometimes when there are problems they can cause as much load on our systems as a malicious attack would. Weβre not banning the use of pinging (or βuptimeβ) services on Glitch right now, and weβd like to not have to. So, if you use these services, disable or turn off any pinging services you donβt need or that arenβt absolutely necessary. (You definitely donβt need to ping more than once every 5 minutes or so β more than that just adds load to the system but doesn't make any difference for your app.)
hi, i have ```js
const eris = require('eris');
class Client extends eris.Client {
constructor(token, options) {
super(token, options);
}
test() {
console.log('e');
}
}
``` when i do client.test() is says its not a function, how can i fix this? im trying to learn classes again idk if this is wrong
what's client? an instance of your Client class?
just the normal eris client
That's why you get the error
how to make my bots status be PLaying SOMETHING
You need to instantiate the Client class you declared, not the eris class
The Client class you declared above has all the functionality of the eris.Client, plus the test function. Instead of doing client = new eris.Client() you would do client = new Client()
let prefix;
con.query(`SELECT * FROM data WHERE guildID = '${msg.guild.id}'`, (err, rows) => {
if (err) throw err;
if (rows.length < 1) prefix = bot.PREFIX;
else prefix = rows[0].prefix;
});
console.log(prefix)
return;
Problem: prefix returns undefined.
oh right, ok
just to let you know, you can do client.user.setActivity("sometext"); to make your bot show up as Playing sometext
The callback function doesn't execute immediately, that's why it's called callback
You will have to put any code that uses the prefix variable inside the callback
can't i put the prefix into a variable and use that prefix in the rest of the code ?
so this is what i have as my client now, const client = new eris.Client(require('./config/passwords').token); and i need to change that to const client = new Client(require('./config/passwords').token); ?
no, because the rest of your code executes before the callback function
what do i define Client as? this is my index.js file btw
how can i make sure this happens first ?
Lost, you defined it in the code you gave above
class Something {}
const smth = new Something()
wolfy, put the code inside the callback function
okee, thanks π
they're in different files
Then export the class, then import it (Like any other object)
class A {}
module.exports = A;
// Then import it in another file
const TheAClass = require("..path to A class");
const a = new TheAClass()
oh right
i done js // class file module.exports = Client; and then in my index.js file i done js const Client = require('./classes/Client'); const client = new Client(); and in my eval command i done client.test() and it errors, same error
@cinder patio any ideas?
Do you use the client variable and not the eris one?
You need to provide a token as the first parameter as well
i use the client variable
oh yeah, i done that
const Client = require('./classes/Client');
const client = new Client(require('./config/passwords').token);
How do you access the client in the eval command?
parameters
even in the index.js file when i do client.test() right underneath where i define client
oh wait nvm, i fixed it
thanks for the help
hmm, why am i getting this error? Error: ENOENT: no such file or directory, scandir '../commands/'
you do not have a folder named commands
double check the spelling of folder
or maybe u wrote the path wrong
i do, the path is correct
all i did was add an extra . onto it
didn't change the spelling or anything
your code is inside a folder?
like, for example if your bot's file is inside a folder named bot :-
bot/folder1/test.js
is it something like this?
there is
wym
try __dirname + "/../commands"
oki
lower cased, sorry
same error
oh wait, its Error: Cannot find module './commands/admin/eval.js'
where u wanna see?
didn't you put ../, not ./
um
sigh
sigh
if I use this i get an error let user = message.mentions.users.frst()
Let user = message.mentions.users.frst() || message.author;
^
TypeError: message.mentions.users.frst is not a function
Wait-
I spelled it wrong TvT
There is no users mentions, only roles/channels/members


