#development
1 messages · Page 971 of 1
Obviously you'll need to store your list of blocked guilds - likely in a DB
And then query that list when it joins a guild.
well it's just one server
so what should I do for just one?
like I don't need an entire db for one
disallowedguilds im guessing you would set as a db
would this work?
if( guild.includes( "theid" ) )
guild.leave();
}```
@paper phoenix
function guildCreate( guild ) {
if( guild.id === '123456789012345678' )
guild.leave( );
}
ty
what error?
Promise.resolve(message).then(function(value) {
value.delete()
})
``` try this
msg.delete()?
wait do
await msg.delete();
await msg.react("715383579059945512");
await msg.react("715383579059683349");
});```
@earnest phoenix
scltxn but this will delete the embed
than the but just have sended
he want to delete the trigger message
on bottom of the msg.react
so the bot will react the embed message and delete the trigger message
i hoped i helped a little
quick question
how do you ban someone for a reason
i had my bot look at docs and it shows nothing
in which lib
I made a pay command and there is no errors but when I try to pay someone it doesnt respond the only time it says anything is when i do c!pay but not when mentioning or saying a users name
Anyone have any idea how to fix?
This is the code: https://sourceb.in/58b834a696
Do you use a custom library or a public pre-made one
Is there any way to profile my bot's (python) process running in a docker container?
how can I check message count per second/minute 
@ me pls
@summer torrent message sent or received?
If sent, count how many times you send
If received, count the number of times you got MESSAGE_CREATE
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online, activity=discord.Streaming(name=f"{prefix} help",
url="https://www.twitch.tv/streaming_on_discord"))
print(f'{bot.user} has connected to Discord!')
import requests
url = "https://discordbots.org/api/bots/" + str(bot.user.id) + "/stats"
headers = {"Authorization": stableTOKEN}
payload = {"server_count": len(bot.guilds)}
requests.post(url, data=payload, headers=headers)
Help! Why isn't it working?
The server count
ah
If you're wondering why
#topgg-api topic has link to docs from where you can find the url to POST to
ok thx
import aiohttp
dbltoken = "token"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken}
async def on_ready():
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_join(server):
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_remove(server):
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
should i use this instead?
oh wait
thats the same url
From where did you copy it?
oh oops
Look in #topgg-api topic for links to docs
Also that's the more appropriate channel for help with top.gg api
oh ok thx
Code:
await guild.leave()```
**Error:** ``Unknown Guild``
why this dont work?
if (command === 'refresh') {
if (!["507367752391196682"].includes(message.author.id)) {
message.channel.send('No puedes usar el comando!')
}
exec('git pull master')
}
const { exec } = require('child_process');
What about it does not work? Also are you forgetting your return keyword above?
really?
is return exec?
why when i put git pull master
dont work?
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights```
it isn't a git repo
like the error says
so?, how i fix it
use git clone to clone your repo and then you can run git pull in it
you probably meant to git pull origin
as master is normally a branch name
https://oliy.is-just-a.dev/5hynwi_4353.png also, you'll want a return right here or anyone will be able to use it
I'm surprised exec even works on glitch
Yes it hosts
update your node
who?
HOw do I override channel permissions?
like add someone to the channel
by changing perms
ping me if u know
how?
node, the runtime enviornment
idk how you would on that, it looks like glitch
or heroku
ok
You can't cd it to desktop
actually..
nvm
didnt work
ping me if u know
@torn tiger cd to your user folder lol
desktop doesn't exist in the folder you created

@earnest phoenix if you were using python i could've helped 
😦

https://discordapp.com/channels/264445053596991498/272764566411149314/721207018299457567 plz help
ping me if u know
@earnest phoenix You could bind the client to the event and attach the map to the client
Or module.exports the map and require the bot file in the event
But I think the former is the better option
Modules and exports are not specific to command handlers. You should learn to use node a little bit better
Uhm how can I delete channel overwrites? I used the alternative way but it's not working
working on cell phone (it's horrible)
those packages
are horrible
just use few packages as possible, normally i have like 1-3 packages per project
When pc not applicable I mean I don't have pc, but I programmed mine
hi
im really dumb
const Discord = require('discord.js');
module.exports = {
name: "dice",
description: 'rolls a dice',
execute: (message, args) => {
let dice_no = args[0]
if (!args[0]){
message.reply("Bruh enter the no of sides lol")
}
else {
let ndice = parseInt(args[0]);
let roll = Math.floor(Math.random() * parseInt)
let diceEmbed = new Discord.MessageEmbed();
diceEmbed.setColor("#00ff00");;
diceEmbed.setTitle("The number rolled is..");
diceEmbed.setDescription(roll);
diceEmbed.setFooter("Requested by " + message.author.username);
diceEmbed.setTimestamp();
message.reply(diceEmbed);
}
}
}
pls someone tell me whats wrong with this
i am getting this
no errors
NaN means not a number
let roll = Math.floor(Math.random() * parseInt)
you're multiplying a number with a function lol
not true
it is true
no, its not
uhhhh
parseInt(" 02 "); // 2
i think i have an idea
thats a number
the whole point of parse int

parseInt(args)
stop being a wiseguy
you know I meant a string with a number
like
args.length
[0, 1, 2] = args;
theres something like that right
yeah its args.length @vale garden
parseInt(num)
sup
oh
const num = 1 + 2 * 3
const three = [1, 2, 3].length;
uhh no
im confused
its length
i did ndice.length and its wrong
length = how many arguments lol
no...
ok if u want dice command here u go
args.length not ndice.length
wha
const num = Math.floor(Math.random() * 6);
// then send num to chan or use it embed or what ever```
but i want to lol
or what you want
@freestyle#0001
const num = parseInt(args[0])
lol
that should work
const Discord = require('discord.js');
module.exports = {
name: "dice",
description: 'rolls a dice',
execute: (message, args) => {
let dice_no = args[0]
if (!args[0]){
message.reply("Bruh enter the no of sides lol")
}
else {
let ndice = parseInt(args[0]);
let roll = Math.floor(Math.random() * ndice)
let diceEmbed = new Discord.MessageEmbed();
diceEmbed.setColor("#00ff00");;
diceEmbed.setTitle("The number rolled is..");
diceEmbed.setDescription(roll);
diceEmbed.setFooter("Requested by " + message.author.username);
diceEmbed.setTimestamp();
message.reply(diceEmbed);
}
}
}
this is my code
and it doesnt work
it shows NaN
lol idk
try console.log(args[0]) after message.reply
send logs
kk then make ndice to parseInt(args[1])
Hi people, I am trying to play two songs using connection.play(path.join(music_dir, music_list[0])); connection.play(path.join(music_dir, music_list[1])); but it is only playing the second song and skipping the first one. Any idea?
u can now remove the console.log in end of it tho
yea ik
Hi people, I am trying to play two songs using
connection.play(path.join(music_dir, music_list[0])); connection.play(path.join(music_dir, music_list[1]));but it is only playing the second song and skipping the first one. Any idea?
@harsh hull you mean like queue or what?
yeah something like that
that wont work, y gonna need to make collection of songs and then yeah
Well make a queue and put songs in it
I see thanks!
if(message.content.startsWith('@teal latch')) {
message.reply(`My prefix is **${prefix}**!`)
}```
bot works
but doesn’t do command
send command handler/message handler and example of command... and possibly errors..
could you read the whole message...
the editor reads it
@earnest phoenix
message.mentions.members.has(Bot.user.id)
what??? "the editor reads it"? wdym by that
A month or something ago, people recommended me to create, use and end a mysql connection for each query. Now I read that's not useful at all, as it will wait for the previous query to finish until it can end that connection and open a new one. Now I saw a pool is the best way, but people here said I could better do it like I described in the first sentence.
What should I do?
i usually just cache everything, and when program closes then put them back into db
hmm yeah I heard about that but I haven't found a way to 100% sure detect the program closure
G
signint signterm those are what i know (ctrl + c and pressing "x")
can i have help with https://api.alexflipnote.dev/
not sure how to set something like this up to use in my bot
other than install superfetch
@balmy knoll lol I just wanted to react
Resolved
I can resolve that the discord bot leaves all servers?
.setDescription("**Pong!**\nLatency Is "+Math.round(Date.now() - message.createdTimestamp)+"ms. API Latency Is "+client.ws.ping+"ms")```
is it correct? im first time making ping command
Hhhh
https://corynth.is-inside.me/aUUeeyn9.png Getting this with eris
is there any way to stop user from using a command when another command is in progress. Like if !story is in progress user shouln't be able to use !story while its in progress. if he does it should show an error
anyone can help pls?
on discord.py?
can someone help me properly interact with alexflipnote api (using node superfetch)
sure
thankyou
@plucky harness on command usage, bot.cmdinprog = True
on another command usage: if bot.cmdinprog:
@golden condor alright its installed and i did
fetch('https://api.alexflipnote.dev/')
@slender thistle it would allow only one user to access ?
Following the logic, it should
i want a single user to not access command two or more times
for if you wanted to grab stuff from homepage
others can access
fetch("https://api.alexflipnote.dev/").then(res => res.json().then(data => {
res.support_server
}))
ah
just do this
Well use a dictionary where you store user IDs
I have made a Discord Music bot with node.js, but whenever I use the play command, it leaves the channel. Why does this happen?
buthowdoigetmytextontotheimage?
It joins then leaves
I have made a Discord Music bot with node.js, but whenever I use the play command, it leaves the channel. Why does this happen?
need more info
send codes
however you can
I've got an index.js file
send the music code
first of all did you copy and paste the code
that too
here:
no opus/ytdl/ffmpeg?
No
how are you gonna play the music
buthowdoigetmytextontotheimage?
@pure lion use args
like
`https://api.alexflipnote.dev/pornhub?text=${text}&text2=${secondtext}`
👍
Hiya
sup
never mind
how could you return me only the guilds where you have admin permissions
Get current user guilds and filter
Yeah, that's a bit set
You can look at the official docs to see which bit means what
A small calculator that generates Discord OAuth invite links
All permissions except Admin
But i have manage guild
mmh
u using a library in ur dashboard?
You can check this with bitwise and
0x00000008
@devout wagon But if you have only have admin
u using a library in ur dashboard?
@digital ibex passport
@devout wagon But if you have only have admin
@real helm wdym
i meant a discord library
If you have more permissions, the admin isn't 8
permissions & 0x8 == 0x8
mmh
Then you have admin
an api wrapper for discord?
Regardless of other perms
Wrong server reeee
How do I install ytdl and opus with npm?
npm i ytdl opus?
How do I install ytdl and opus with npm?
@leaden rover npm i ytdl- core
npm i discord.js/opus
ok
also can someone help me with args.toString because its being stupid
@pure lion opus can't install
i cant remember the name of the package
but its something along the lines of discord.js-opus
in discord.py how do i make it delete or ignore default help command
i have my custom one
any idea? i tried everything.. everything is defined
at Object.module.exports.run (/home/Nana/Witch/Witch/commands/userinfo.js:21:4)
at Client.module.exports (/home/Nana/Witch/Witch/events/message.js:36:11)
at emitOne (events.js:121:20)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/Nana/Witch/Witch/node_modules/ws/lib/event-target.js:120:16)
at emitOne (events.js:116:13)
(node:66113) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 14)
at embed
at Object.module.exports.run (/home/Nana/Witch/Witch/commands/userinfo.js:20:4)
at Client.module.exports (/home/Nana/Witch/Witch/events/message.js:36:11)
at emitOne (events.js:121:20)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/Nana/Witch/Witch/node_modules/ws/lib/event-target.js:120:16)
at emitOne (events.js:116:13)
(node:66113) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 15)
in discord.py how do i make it delete or ignore default help command
@plucky harness
client = commands.Bot(command_prefix="?", help_command=None)
Me is on mobile
at Object.module.exports.run (/home/Nana/Witch/Witch/commands/userinfo.js:27:51)
at Client.module.exports (/home/Nana/Witch/Witch/events/message.js:36:11)
at emitOne (events.js:121:20)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/Nana/Witch/Witch/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/Nana/Witch/Witch/node_modules/ws/lib/event-target.js:120:16)
at emitOne (events.js:116:13)
(node:66113) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 21)
any idea?
Could you show the relevant code too?
const Discord = require("discord.js");
const db = require("quick.db");
const moment = require("moment")
module.exports.run = async (bot, message, args) => {
const user = message.mentions.users.first() || message.author
const member = message.mentions.members.first() || message.guild.members.get(args[0]) || message.member || message.author;
if(member.user.bot) return message.channel.send(` | **${message.author.username}**, bots don't have a profile`)
const status = {
"dnd": ":red_circle:",
"online": ":green_circle:",
"idle": ":yellow_circle:",
"offline": ""
}
const embed = new Discord.RichEmbed()
.setColor("#ad91ff")
.setThumbnail(`${member.user.avatarURL}`)
.addField(`${status[member.user.presence.status]} ${member.user.tag}#${member.user.discriminator} (\`\`\`${member.user.id}\`\`\`)`)
.addField(`Nickname`, `${member.nickname !== null ? `${member.nickname}` : '**No Nickame.**'}`)
.addField('Created at', `{moment.utc(user.createdAt).format('dddd, MMMM Do YYYY, HH:mm:ss')}`)
.addField(`Robot`, `${user.bot.toString().toUpperCase()}`)
.addField('Activity', `${member.user.presence.game === null ? "**No Activity**" : member.user.presence.game.name}`)
.addField(`**Member**`)
.addField('Joined At', `${moment.utc(member.joinedAt).format('dddd, MMMM Do YYYY, HH:mm:ss')}`)
.addField('Member Roles:', `${member.user.roles.array()}`)
.setFooter(`© Witch Bot by ${customisation.ownername}`);
message.channel.send({embed});
}
exports.conf = {
enabled: true,
guildOnly: false,
aliases: ["userstats"],
permLevel: 0
};
..
Users don't have a roles property
It should just be member.roles
Assuming member is a member
hi why am i getting this error
const Discord = require('discord.js')
module.exports = {
name: 'poem',
description: "sends you a poem",
execute(message, args) {
const poemEmbed = new Discord.MessageEmbed()
poemEmbed.setColor("#ffa500")
.setAuthor('Author')
.setTitle("Title")
.setDescription("Poem")
.setFooter(`Requested by ${message.author.username}`)
.setTimestamp()
message.reply(poemEmbed)
}
}
i think there is nothing wrong with the command
and message.author.username is correct right
i have never defined it in any previous commands where i used it
and it goes perfectly
could it be
because the .setAuthor doesnt have an image url
i got
it
its nothing related to any author
i put a . instead of a ,
lol
hey
but
is there a way to make it so that
the main code
index.js
anyways
dude
do you know a way
yea
by which when there are like many strings and you randomly generate one
like a = [1, 2, 3]
and
let b = Math.floor(Math.random() * a.length)
yea i meant that
sorry im in a hurry
gtg soon
so like you make another array
and is it possible
that if one of the elements of an array gets generated only a specific one from the other array appears
if a = [1, 2, 3] and b = [1, 4, 9]
and 3 gets selected
is it possible to make 9 also send
ok
any idea why this undefined
appear?
.setColor("#ad91ff")
.setThumbnail(`${member.user.avatarURL}`)
.setAuthor("User Info")
.addField(`${status[member.user.presence.status]} ${member.user.tag} (\`\`\`${member.user.id}\`\`\`)`)
.addField(`Nickname`, `${member.nickname !== null ? `${member.nickname}` : '**No Nickame.**'}`)
.addField('Created at', `${moment(user.createdAt).toString().substr(0, 15)}\n(${moment(user.createdAt).fromNow()})`)
.addField(`Robot`, `${user.bot.toString().toUpperCase()}`)
.addField('Activity', `${member.user.presence.game === null ? "**No Activity**" : member.user.presence.game.name}`)
.addField('Joined At', `${moment(muser.joinedAt).toString().substr(0, 15)}\n(${moment(muser.joinedAt).fromNow()})`)
.addField('Member Roles:', `${muser.roles.array()}`)
.setFooter(`© Witch Bot by ${customisation.ownername}`);
@earnest phoenix u can help me too?
see i know that
but im talking about when there are 2 arrays
and like 2 gets selected in the first array
use a loop
so i need another element to be there
but the thing is its gonna get too ong
long
oof is there an npm for poems
anyone can help me?
u have up my problem
nevermind
i put as description
but instead of false
how can i do like this
instead of false
to say bot
or user
i made this ${user.bot.toString().toUpperCase()}
where to put that
ah
tysm @earnest phoenix
My connection to the server always time out before it can even finish the mongod command. Any solutions as to how to make it faster?
Nice bot 👌
any idea to make the bot
to ping highest role
like member ones?
filter them by their positions
example? ${member.highestRole.name}
my bad, you can just sort them
i'm not even sure at this point
@earnest phoenix theres a lot of factors for why its timing out, and wdym you can't finish the mongod command? and what do you want to be faster?
can you even sort a collection
ya lul
you can
yeah
so you can do something like <Roles>.sort((a, b) => a.position - b.position)
it could be backwards, idk lol
its b.- ye
after that you can just map them by mentions
flaze
i aleardy did that
read
also it don't ping role..
${message.guild.roles.sort((b, a) => a.position - b.position || a.id - b.id).first().name}```
Hint: .name
thats not going to mention
<@&510453675425136651> = mention
Certified Bot = name
im a little confused for why this isn't working: ```js
const button = document.getElementById('btn');
button.addEventListener('click', (event) => {
console.log('e');
});``` i have this, its not logging e
and theres no errors
anyone know why its not doing anything?
the html: ```html
<div id="btn">
<button class="button is-success is-light">Save Changes</button>
</div>
oh, idk
i changed my html to html <div class="btn"> <button class="button is-success is-light" id="btn">Save Changes</button> </div> but still nothing happens
anything can have a click event as long as you add one
ids are unique accross the entire document
is that the only button you have in the entire page?
@earnest phoenix theres a lot of factors for why its timing out, and wdym you can't finish the mongod command? and what do you want to be faster?
@digital ibex it timed out before i can even type a command again meaning the mongod command has not finished executing yet
would i have to link the html and js together? or does the document automatically get it?
yeah, thats the only button i have on that page, i have more but none with the id of btn
sunSOG, what even is mongod?
how are your files organized?
o
you have a separate html and js file?
yeah
then you need to link it
i thought the document would automatically do it, sorry 😄
end of body
kk
you can, but end of body is the preferred placement in order to defer script loading
i haven't done vanilla web dev in ages
nothing happens um
this is my full html code: html <body> <div> <div class="columns"> <div class="column"> <p class="ef">hi</p> </div> </div> </div> <div class="btn"> <button class="button is-success is-light" id="btn">Save Changes</button> </div> <script src="../../public/scripts/index.js"></script> </body> if that helps
kk
see if your index.js file loaded correctly
yeah, it loads
so
so
s o
so
how do i use args.toString for https://api.alexflipnote.dev/achievement?text= (this text here) &icon=1
e.g https://api.alexflipnote.dev/achievement?text=lolxd&icon=1 but there are spaces
@digital ibex open dev tools, go to console, and paste your script there
kk
replace spaces with +
oh
unless I'm misunderstanding it
it's easier to use encodeURIComponent()
are you sure the js file loaded correctly? does it show status 200 in network tab?
its 304
do you have the "disable cache" checkbox ticked?
'not modified'
it's easier to use encodeURIComponent()
@pale vessel e?
how do i do that?
its unchecked, do i tick it?
yes
check if it works now
it doesn't log to the console
what if you do console.log(button) in your js file
then reload the page with the console tab open
kk
do i log it in the .addEventListener?
no or
nothing logs, i added it outside it
what about your console? its showing 1 warning and 1 error
click where it says "index.js:1"
kk
oh
<p>test</p>
i was testing if res.send would work in html
like res.send('html')
lol
that will never work (using express code in client side)
or you mean doing res.send("<html here>") in your server?
that will work yes
thats coming from the 404 page btw the error
What is res in this case
does it have any redirection?
im making a basic rate command
port 3000 is already being used
Ahh ok
and i want to have things that give 0/10 and things that give 10/10
if you have an existing webserver, such as express.js, add it to dblapi instead
any idea how i could do that
error 1: GET http://localhost:3000/favicon.ico net::ERR_CONNECTION_REFUSED
error 2: Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3000/guilds/689243278666760201/stylesheets/main.css".
for example, instead of webhookPort:3000 you put webhookServer:server/listener with the server or listener of your existing webserver
any idea how i could do that?
use Math.random() + math
@digital ibex you should not be using relative paths for js and css with dynamic urls, thats too messy
o
put your js and css in a single location, define them as static in your express.js, and use absolute urls instead
they are in separate places
So I tried other ports but didn't work. I have a port in the env which is 3000, and a app.listen(4000)
@raven urchin you're using glitch right?
and i am defining them as static in express
Yeah
glitch only allows port 3000 afaik
Damn
so you have to use the same server for both, like i showed
by define them as static u mean: app.use(express.static(path.join(__dirname, 'public'))); ?
webhookServer:yourserverhere
when I do 3000 still shows an error
lemme see
its not loading, no idea why
@raven urchin i told you, use the same server for both
I did
let listener = myserverhere.listen(process.env.PORT)
let dbl = new DBL("bla",{webhookServer:listener})
Ah I'm stupid
@digital ibex what if you go to localhost:3000/public
whats your directory structure?
localhost:3000/src/public -> i'm doing & that is the directory structure
public is in my src folder, index.js is in public/js/index.js
wait im confused
so basically this?
index.js (the express server)
src
public
js
index.js
css
index.css
ok
so if you access localhost:3000/public/js/index.js it doesnt work?
also try localhost:3000/js/index.js
yes
try it
kk
localhost:3000/public/js/index.js -> nothing, just loads
localhost:3000/js/index.js -> shows the index.js file
ok good
good
client.guilds.cache.size
so in all your html/ejs files, you can simply do <script src="/js/index.js"></script>
same with your css files: <link rel="stylesheet" href="/css/main.css">
o ok
so basically loading them from root regardless of what the url is
kk
that should fix the css error, as for the favicon error, just put a favicon.ico file in your public folder
kk
@quartz kindle so it's saying server.listen isn't a function, how idea?
how did you start your server before?
I used app.listen
then do the same thing lol
Ah ok
its just loading now tf
show network tab
anyone got any idea how to make a random number between args[1] and args[2]
kk
@misty sigil javascript?
yes
Math.floor(Math.random() * maximum) + minimum``` iirc
@quartz kindle any ideas?
Lmao
how to restart bot using discord.py
ik how to close or logout
@digital ibex show your app.js file
but start ?
all of it?
yes
i dont wanna login manually
via code basically
which'll log out then logs in
i dont think so
@plucky harness to restart a bot the easiest way is to simply use a process manager
oh? how do i do that
Can anyone help me? ._.
https://kyoya.is-inside.me/w52FzXpf.png
How can i fix this?
there are many process managers out there, for example pm2 which is primarily for js, but it also works for py. not sure if there is anything better for py
Anyone?
okiedoke
@digital ibex move up the app.use(static) line to be the first "app.use". there are some posts saying that static should always be the first thing to be loaded
docker
@quartz kindle
I have this json file with monsters and every monster has a level but I want to get every monster that is the same level as the player or 1 level higher how do I do that?
okiedoke
there are many process managers out there, for example
pm2which is primarily for js, but it also works for py. not sure if there is anything better for py
@quartz kindle pm2 works for everything, not only js or py
he didn't imply it only works for those
the user was using py
that's why he mentioned python
Hello,
I'm working with discord.py
Is there a method to take Hours arguments for a function ?
I have a function that make a substraction between two hours (eg. 03h26 - 21h35), but I don't know how my bot can catch the hours from the command, anyone can help ?
I'm trying to do it with regex but I'm not understanding the process..
async def(self, ctx, hour : [00-23]h[00-59]):```
you need to convert both to a uniform value for example seconds or miliseconds, then apply the subtraction, then convert them back to hours and minutes
its just loading again
Yeaa @quartz kindle the substraction insn't the problem, but how my command can catch hours ?
Could someone help me pls ? It returns undefined. But ServerMusicQueue.songs returns all the songs in the queue.
var ServerMusicQueue = queue.get(message.guild.id);
var queuestandartminutes = 0;
var queueduration = ServerMusicQueue.songs.forEach(song => {
Math.floor(queuestandartminutes + song.duration.minutes)
});
@digital ibex send something in your .get("*") route
can be simply a 404
but all routes have to send something back
guys neeed help
@dapper compass there are many different ways to format hours, so there is no one-liner to do it all
o ok
and i cant start the .bat file
linux doesnt understand batch files
they are windows files
linux uses .sh files aka shell script
@dapper compass there are many different ways to format hours, so there is no one-liner to do it all
@quartz kindle Yea, i'm searching with regex right now, taking hours by strings and dividing them into hours / minutes
no
sad
you need to rewrite the entire file in shell script
let viablemonsters = [];
let monsters = Object.keys(monsterfile);
console.log(monsters)
console.log()
for (let i = 0; i < monsters.length; i++) {
console.log(monsters[i].level)
if(monsterfile[monsters[i]].level === 1 || 1 + 1) viablemonsters.splice(-1, 0, monsters[i])
console.log(monsters[i])
}
I can't seem to get the level integer saved in the json file: "monsterfile"
😫
what does your bat file do?
it loaded
.sh
PAUSE is not shell script
anyone knows my issue?
input
sudo ./*.sh
output
sudo: ./start_bot.sh: command not found
whats your file name?
start_bot.sh
just run ./start_bot
ok
wait uhhh, the original problem was the button not working, and uh, its not working
i think my terminal broke xD
anyone can help me?
maybe state your problem?
let viablemonsters = []; let monsters = Object.keys(monsterfile); console.log(monsters) console.log() for (let i = 0; i < monsters.length; i++) { console.log(monsters[i].level) if(monsterfile[monsters[i]].level === 1 || 1 + 1) viablemonsters.splice(-1, 0, monsters[i]) console.log(monsters[i]) }I can't seem to get the level integer saved in the json file: "monsterfile"
@tulip ledge
I need to get the level key from the json file
ok
@digital ibex so you have 2 files? btn.js and index.js?
But I tried alot of different things and none work
tim . . .
@earnest phoenix run ls
yeah, i put the button code into btn.js when when i was waiting,
do you see your start_bot file?
@tulip ledge your console.logs are wrong, they are logging monsters[i].level instead of monsterfile[monsters[i]].level
TIm it doesn't work either
Since I have 3 entries in the file a level 1, 2 and 3 but the level 3 shouldn't be put in the array I'm making but it still is
@tulip ledge your if is also wrong
oh
but not working
tim, any ideas?
@tulip ledge ```js
if(level === 1 || level === 2)
otherwise 1+1=2 which is true
sad
Anyone know how I could create a channel in a specific category?
level === userlevel || level === userlevel + 1
@earnest phoenix your lavalink.jar file is with capital L
@digital ibex any errors in the console tab?
reload the page with the console tab open
kk
do you still have that console.log(button) from before in your js files?
So now I have this problem I have no idea how to start with.
So I have the same json file and every monster has it's own chance: 25, 30, 50 (these are percentages)
Now they might not add up to 100% and I need to get a random one of them depending on the chances.
Any idea how I would do this?
wait so it does work
why do you have your console split into categories like that?
just click on
kk
anyone could tell me what the nodes : [] in config.json file looks like
for lavalink
and clicking still does nothing?
nothing, unless i do it in the console then it works otherwise it doesn't
@raven urchin bro you are the best programmer in the world. Programming a Bot in a phone
...
Anyone knows how to fix my problem?
@raven urchin you still have things trying to use the same port. look in your code all lines that have 3000 or process.env.PORT
I have that in uptime.js to keep my code up
you cannot use the same port more than once across your entire project
not only per file
all code that uses some kind of webserver and ports should be put in the same file and use the same webserver instance
hey tim, quick question
no one knows how to do it?
atm the users guilds displays one and then new line one new line one etc, how can i make it do one two new line one two new line?
like
rn^^ i want two on each column, any idea how i can do thta?
there are many ways to do it@tulip ledge for example, sum all percentages into a total percentage, generate a random number between 0 and the total, then loop over the percentages until you find one that fits the random number
alright thank you
@digital ibex are you using flexbox?
never used bulma so idk
o okie
how can I check message/second ? Is there any best way to do this?
@digital ibex Use bulma columns
yeah, thats what im using atm
this is my code: html <div class="container"> <div class="columns"> <div class="column"> <a href="guilds/<%= guild.id %>"> <img src="https://cdn.discordapp.com/icons/<%=guild.id%>/<%=guild.icon%>.png"> </a> <p class="bd-notification"><%= guild.name %></p> </div> </div>
but if i add another column its going to show the same server twice
Why would it show the same guild twice?
because im adding another column
Are you using that entire markup block when looping over the guilds?
Loop over the columns, not the container
The same way you are doing it now, just without .container and .columns
wdym
<div class="container">
<div class="columns">
<div class="column">
<a href="guilds/<%= guild.id %>">
<img src="https://cdn.discordapp.com/icons/<%=guild.id%>/<%=guild.icon%>.png">
</a>
<p class="bd-notification"><%= guild.name %></p>
</div>
<div class="column">
<a href="guilds/<%= guild.id %>">
<img src="https://cdn.discordapp.com/icons/<%=guild.id%>/<%=guild.icon%>.png">
</a>
<p class="bd-notification"><%= guild.name %></p>
</div>
</div>``` u saying like that?
Show your loop
ik its not a loop but thats all i could thknk f
kk
user.guilds.forEach((guild) => {
}
thats all it is, the whole thing actually is just js <% user.guilds.filter((e) => e).forEach((guild) => { %> <%- include('dash/guilds', { guild }) %> <% }) %>
don't mind the .filter((e) => e)
There we go
Move the container and columns divs from the dash/guilds template to the one containing that template loop
What you currently have: For each guild, add container, columns and the column
What you want: For each guild, add a column