#development
1 messages ยท Page 1796 of 1
it is
How can i limit the click of a slash command button to only the executor of the slash command?
try changing the font format
how do i use a foreach function with mongoose, to get everything inside a collection
convert it to ttf
same issue
did you convert it?
yup,
where is your bot hosted?
and the font files are there in the fonts folder?
yes
Is there really no way to get the window size with Rust's turtle? ๐
same error
i tested your font here and works fine
i hate vsc sometimes i put .setTitle() and it changed it to SVGTextPositioningElement() -_-
const Canvas = require("canvas");
Canvas.registerFont(`${process.cwd()}/TTNorms-Regular.otf`, { family: "ttnorms" });
const canvas3 = Canvas.createCanvas(200, 100);
const ctx3 = canvas3.getContext("2d");
ctx3.font = "50px ttnorms";
ctx3.fillText("test", 10, 50);
m.channel.send({
files: [{
name: "test.png",
attachment: canvas3.createPNGStream()
}]
});
``` this is what i did
which ctx are you using?
2d
you're not creating a ctx in your code
i need to go il see it later thanks
Listen for a window resize?
Is it called when the window is created?
hmmm what "this is the last version to support user bots." mean exactly?
anyone knows?
Meaning you can log in as a user only in this version and any versions below that
And by that it means sorta
Its possible but so much is outdated now and is depreciated
Yup
oh i see, thanks guys ๐
Why???
Oh nice the crate's latest version doesn't even work
I have to use the master branch from GH
https://github.com/sunjay/turtle/issues/213 having this issue
Trying to run turtle
Out of curiosity what are you trying to make?
Just whatever that involves shapes and colors on a board
Oh
const Canvas = require("canvas");
Canvas.registerFont("./fonts/TTNorms-BlackItalic.otf", { family: "ttnorms" });
async function img() {
const canvas = Canvas.createCanvas(1772, 763);
const ctx = canvas.getContext('2d');
ctx.font = "115px ttnorms";
ctx.fillText("test", 700, canvas.height / 2 - 150);
const buffer = canvas.toBuffer('image/png')
fs.writeFileSync('./image.png', buffer)
}```full code, still giving me error
still not understand why
Why is that function async?
the rest of the code is in comments, it uses await for some images
try with other fonts
also which version of canvas are you using?
try other versions
you just need the file
did you get any errors when installing canvas?
it seems to be a windows problem
there are issues about it saying it works on ubuntu but not on windows
try installing the font on windows first
bet it didn't work
lemme se
You did register those fonts, right?
ye
check this
really weird issues on windows
hell no its still not working
ok im reading that
im desesperated
let's say i have alot of buttons with the same id, would this work on only 1 of them?
<button class="get-btn" onclick="document.getElementById('confirm').style.display = 'block'">BUY <span style="font-size: 20px;">⇨</span></button>
Yes
ids are unique
IDs are meant to be unique
classes are not
oh ok so a class should do it
ok i see the problem with canvas
You still have to loop through the elements and set them to block
i think i got the problem
also, would probably be better to define styles in css rather than in js
I get the stupid "NaN" when trying to get the latency....
My code for that is:
{ name: "Latence", value: "``" + m.createdTimestamp - message.createdTimestamp + "``", inline: false},
My ping command uses the same thing for the latency, and it works.. Also m is the quick message the bot sends before the stats command, and it messures the time difference.
Code:
const m = await message.channel.send("Ping");
m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(message.client.ws.ping)}ms`);
you're not supposed to edit the font data
you're supposed to change your code to match it
you can change your code lol
{family: "TT Norms"}
ctx.font = "100px TT Norms Regular"
at least thats what i understood from the guys "solution"
If the fonts internal name has more that 3 words, canvas cant read it, a lot of issues are opened saying that
thats the problem
if you want to change the font just google any font editor
there are even online font editors that you can do in the browser
YES
JAJA
just changued the internal name of the font to one with only one word and workeds
lmao
Hello,
Please tell me where this code is wrong that the button below the embed is not shown
Please Help Me
Helpppp : (
did you read the docs for discord buttons?
they show how to do it
Yes
So can you tell me what I did wrong?
Awww THANKS
Testing...
what do I do ?
how did you create disbut?
const button = new disbut.MessageButton()
const disbut = require('discord-buttons')
did you initialize it in your index.js?
No โน๏ธ
then read the docs again and do it
ok Thanks
Is it enough to read these documents?
https://discord-buttons.js.org/
yeah, those docs cover everything you need
I read and did but the buttons are still not shown
hmm, im not sure then. i am using that library and it seems straight forward with the docs.
it even gives copy pasteable examples
I sent my sample code, you saw it was not a problem
c
where are you setting the id?
oh nvm its a url doesnt need an id iirc
try their support server i guess
It shows all the code in the image, I just do not know what the problem is, I do not receive any error
still, try their support server.
they would know best
oh thats ALL code related to buttons?
your missing some stuff then
read this page in its entirety.
https://discord-buttons.js.org/3.0.0/setup-and-install
Embed and button code
I did all this
client.on('guildMemberAdd', member => {}
This event isnt triggered any more. It isnt triggered for my friend using v12 and for me v13 not, too
What intents do you have set?
Error: listen EADDRINUSE: address already in use :::8000
@blissful pulsar Something probably went wrong when closing the script causing the script not to exit properly. Try to find the proces in your task manager and close it that way, then try to run it again.
how ?
i tryed lots ports
@blissful pulsar When you are using something that utilizes network ports, you have to make sure you close the script properly everytime you close it. It will otherwise keep using that port and you won't be able to restart the script. So make sure you close the process (via taskmanager if using windows) and try to start it again.
Okay, so try this
netstat -ano | findstr :8000
and then check the process id (pid).
then do
taskkill /PID <PROCESS_ID> /F
Such commandline pro
๐
in cmd ?

nothing appears
Maybe you are then trying to utilize port 8000 twice in your script?
Hmm, anyone got any ideas on how to make a button with no characters the same width as a char with 1 character on mobile?
Buttons with zero width chars are thinner than one with a character and it looks bad.
no ?
yes but port 8000 is not in
pretty awkward
k
okay I think I got an answer
try
killall -9 node
extra reference https://stackoverflow.com/questions/39322089/node-js-port-3000-already-in-use-but-it-actually-isnt
I know the Sherlock Holmes of this server will be slamming away at their keyboards to tell me to ask my question in the discord developers server, but I am not going to. Basically, I wanna know what are the repercussions of sending one unsolicited message to every server containing my bot. Is this just API abuse, or is it something that actually incurs consequences other than a ratelimit?
I have this line:
const client = require("detritus-client")
And apparently there is a syntax error in the detritus code because I get this error? ```/home/evan/node_modules/detritus-client-rest/lib/client.js:38
buckets;
^
SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/evan/node_modules/detritus-client-rest/lib/index.js:20:14)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
so basically you want to send a message to all servers. It's not api abuse, no. You can actually do it
const guildList = <Client>.guilds.cache.map(guild=>{
const channel = guild.channels.cache.first() //the first guild cached
channel.send("Message");
})
})
I know I can, I'm asking if I should
api abuse always has the chance of getting your bot deleted. so "just api abuse" is realistically the highest thing.
so basically if you send a message every second
that's api aboose
Discord.js tries to decrease it by using "cache" as you can see the in example^
so basically you can do it
anyone know any good ways to filter profanity
does anyone know how to do mimu embeds
this is not the mimu support server
discord.gg/mimu is tho
I'm kinda stuck because my bot was in 3000 servers when discord introduced their verification requirement but I didn't have any valid ID so I abandoned the project. I have now been trying since January to get it verified, and I just got a response saying I they won't verify me if my bot isn't online. But I can't really bring it online because the core feature relies on a privileged intent which I don't have permission to use because I'm in more than 75 servers. My two options are either to make my bot leave most of its servers, bring it online and wait for verification, or create a new bot and then use the original bot to advertise the new one once, then delete it
(sorry for the novel)
remove the core feature ๐ง
But then it's just a ping bot lmao
check the message, with regex?
so you can check like , F$#k
The proper option is to just start over and not spam messages on the old bot.
you can still start the bot with priveleged intents
you'll just be invite-locked
I know I can start it, it just won't do anything because the main feature needs the intent
(if you had them on in dashboard)
are the intents turned on?
like, in the dashboard?
No because I need to apply for them
if you had it previously enabled you could still use them, but now you're kinda locked off
(sorry woo I'm not ignoring you)
Oh np. Not much to say in reply to what I said
So is there a way to make my bot leave every server aside from a simple loop?
yea i assumed that but i'd need to find a regex or make one
Delete the application in the Discord developers dashboard and make a new one? But that would break any topgg pages etc
Then a loop is your solution I guess
Oh alrighty
If you delete the application you'll have to resubmit to topgg etc
Yeah ideally I don't wanna do that
And if your bot is verified by Discord it's the same issue. You'll have to re-apply.
Thanks for your advice everyone
There's a js lib that can do that. Can't remember what it's called. I used it for a project 3 years ago. Just Google it.
How it named ?
I guess do inspect element on that webpage if you can and see what JS they're using
I said I don't know
I have not pc
Just Google "javascript typing text" or something like that
Typed.js
Thank you i have found
ahhh, i just want buttons to all be the same size and discord just doesnt want it 
How do you fix this error? I cant find any sollution for it..
29.06 12:11:34 [Bot] (node:218) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
29.06 12:11:34 [Bot] (node:262) UnhandledPromiseRejectionWarning: #<Response>
29.06 12:11:34 [Bot] (node:262) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
29.06 12:11:34 [Bot] (node:262) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
uhh
I dont know from where its coming
did you write an async function in your bot code without a .catch()?
that's basically what it's saying
it's banshee screaming that because then it can't handle the promise
o..
you have to have a catch state if it rejects
and you don't
so it's throwing its hands up
you need it??
ok
client.on('message', message => {
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
const args = message.content.slice(config.prefix.length).split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
// If command exist
if (!command) return message.channel.send(`Sorry, I didn\'t find the command. \n Please use **${prefix}help** to see all the commands.`)
// Check if command can be executed in DM
// Check if user is in cooldown
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) {
// If user is in cooldown
const timeLeft = (expirationTime - now) / 1000;
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
}
} else {
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
// Execute command
try {
command.execute(client, message, args, Discord);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
}
});
client.login(process.env.TOKEN)```
What Intent do I need for this event: messageReactionAdd
GUILD_MESSAGE_REACTIONS for guilds and DIRECT_MESSAGE_REACTIONS for DMs
thx
Then why isnt this event triggered anymore: client.on('messageReactionAdd', (reaction, user) => {}
I already added the Intent: GUILD_MESSAGE_REACTIONS
I am using v13
Make sure you provided the intents property in ClientOptions, it's outside ws on v13
\node_modules\youtube-sr\build\Util.js:262
const author = playlistDetails[1]?.playlistSidebarSecondaryInfoRenderer.videoOwner;
^
SyntaxError: Unexpected token '.'```
Remove the ? lmao
The optional chaining operator (?.) is only available in Node.js v14 and higher, you're probably using an older version; update your Node.js version
I saw a benchmark test that compares mongoose and mongodb (https://bugwheels94.medium.com/performance-difference-in-mongoose-vs-mongodb-60be831c69ad)
in this case, why should I use mongoose instead of mongodb
I am going to start a new project in which I will use schemaless database and when I was doing freecodecamp, I used Mongoose because I wasโฆ
performance is not everything
So you may want to search around for what mongoose does that mongodb doesn't
Good day.
How long is it possible to add a game if it is not in the TYPE list?
Confused. Please provide more context.
how would i add a slash command to my bot
When you enter the command sb!config type, there is no game in the list. Can I add a game?
Is this a bot you made or someone else's bot
This is your bot. Which I added to my discord.
were can i download it from?
This is not my bot.
But it's someone's bot.
This isn't the right place to look for bot support.
ask in the support server of where u added that bot from
wheres the image
You should see if the bot has a support server on its page.
What you guys think about it?
i personally dislike it
Are you writing a Discord clone?
I like the look of the threads branching from a text channel, but I feel it may take up too much space.
Especially since threads are (probably) dynamic and fluctuate.
I am trying to create a muted role setting but when I run it it doesnt reply at all, and gives no error.
muteRole = await message.guild.roles.create({
data: {
name: "Muted",
color: "RED",
permissions:["SEND_MESSAGES"]
}
});
message.guild.channels.cache.forEach(async (channel, id) => {
await channel.createOverwrite(muteRole, {
SEND_MESSAGES: false,
MANAGE_MESSAGES: false,
ADD_REACTIONS: false
});
});
const created = new MessageEmbed()
.setTitle("Role Created")
.setDescription("The muted role has ben setted up.")
.setColor("RANDOM")
message.channel.send(created)
unrelated to that, but PLEASE lint ur code

lint?
Is the role being created?
ya?
Nevermind, the linting got me
...
can you have the slash command and prefix
ah great now I can't connect to the database no matter how I try.
How do I make my bot send these type of messages? (Bottom message AKA the one that is only visible to me.)
all good, what u got so far?
erwin adversiting detritus for everyone 
https://img.botz.fun/yPO (ofc i will have to read docs but tried and 0 sense was made)
Meru is my client...
this is why ts helps you
it tells you what events it has
you probably intiated a commandClient
so you need to do commandClient.client
ahhh..
which can be either a cluster or just a single client
so its Meru.client.client i need
o
so yeah, Meru.client.on('messageCreate')
thank.
no problomo
idk what kind of intellisense u have with js
just remember in almost ALL events emitted by detritus, tis called CONTEXT
so messageCreate doesnt output a message object
its basically payload.message instead
or you can destructure it directly into message
like ctx.user/ctx.msg (py)
kind of yeah
i get this (node:21918) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voice' of undefined
const Discord = require('discord.js');
module.exports = {
name: 'play',
aliases: ['p'],
description: 'plays a song/nasheed',
async execute (client, message, args) {
if(!message.membe.voice.channel) return message.reply('Pleases be in a vc to use this command.');
const music = args.join(" "); //&play song name
if(!music) return message.reply("Invalid song/nasheed name.");
await client.distube.play(message, music);
}
}
ok
(node:22029) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voice' of undefined
i still get this
const fs = require('fs');
const Discord = require("discord.js");
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.commands = new Discord.Collection();
client.cooldowns = new Discord.Collection();
const commandFolders = fs.readdirSync('./src/commands');
for (const folder of commandFolders) {
const commandFiles = fs.readdirSync(`./src/commands/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./src/commands/${folder}/${file}`);
client.commands.set(command.name, command);
}
}
client.once('ready', () => {
console.log('bot is online');
client.user.setPresence({
status: 'available',
activity: {
name: 'Answering &help',
type: 'WATCHING',
url: 'https://www.youtube.com/channel/UC1RUkzjpWtp4w3OoMKh7pGg'
}
});
});
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
if (command.guildOnly && message.channel.type === 'dm') {
return message.reply('I can\'t execute that command inside DMs!');
}
if (command.permissions) {
const authorPerms = message.channel.permissionsFor(message.author);
if (!authorPerms || !authorPerms.has(command.permissions)) {
return message.reply('You can not do this!');
}
}
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
});
const distube = require('distube');
client.distube = new distube(client, { searchSongs: false, emitNewSongOnly: true });
client.distube
.on('playSong', (message, queue, song) => message.channel.send(
`Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`,
))
.on('addSong', (message, queue, song) => message.channel.send(
`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`,
))
.on('error', (message, e) => {
//console.error(e)
message.channel.send(`An error encountered: ${e}`)
})
client.login(token);
@earnest phoenix doing good so far?
My bot doesn't send the image manipulation, it doesn't send errors, and it doesn't send the image, I'm My bot doesn't send the image manipulation, it doesn't send errors, and it doesn't send the image, I'm hours looking for the error, but I can't find it, can someone help me?
:emoji:
code
yeah, just trying to setActivity and seeing how to do it
<shard>.gateway.setPresence
in ur case, Mura.client.gateway....
I tried putting try {} catch(e) {} to see if it catches the error and sends it to the console, but it doesn't work.
and gives no error.
maybe the code block doesn't even execute
okeh
(assuming u use VSC)
No error, no image probably means an error in the image code which canโt be shown if the content type still is an image
help
let cofresFiltrados = datosCofre.cofres.filter(x => {
if(Date.now() > x.cooldown) {
x.nombre = `โ
${require("ms")(x.cooldown)}`
} else {
x.nombre = `โฑ ${require("ms")(x.cooldown)}`
}
})
console.log(cofresFiltrados) //[]
you know why an empty array prints me
||if there are objects in cofresFiltrados||
๐คฆโโ๏ธ
damn why is stackoverflow so agressive with its reputation points
can't downvote the question
why
I assume you're having issues with the error message. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property
Once you know what causes it, you'd know that you're trying to access .voice on an undefined value.
The image is working
That does not mean by feedback is not useful.
Did you check the manipulated image for example in a browser?
โฆTried to open it?
I did it myself, and it's in my files.
so I have this line of code that begins a trivia game in which the bot initially notifies the user who triggers the command that the game has started. However I have two seperate initial messages the bot sends and I'd like them to be delayed by 2 or 3 seconds, how would I do this?
async def trivia(ctx, client):
await ctx.send("My trivia game has 10 questions that you will get to answer.")
await ctx.send("The game will start in 5 seconds. Get ready!")
Does Discord need to fetch the image from your domain or do you attach the image to an embed?
You can use asyncio's sleep function.
I sent the code above...
I will send again
Just copy the message ID

lol
canโt open that on mobile
I said wrong, sorry
okeh
const Discord = require('discord.js')
//const gif = require('@jimp/gif');
module.exports = {
name: "profile",
aliases: ["perfil"],
type: "profile",
execute(client,message,args) {
client.db.user.findOne({_id: message.author.id}, async function(e,d) {
//images
const background = await(client.jimp.read("./profileTemp.png"));
const avatar = await(client.jimp.read(message.author.avatarURL({size:4096, format: "png"})));
const back = await(client.jimp.read("https://media.discordapp.net/attachments/847097535410733056/859427425182810142/20210622_191823.jpg"));
const verified = await(client.jimp.read("./verified.png"));
const mask = await(client.jimp.read("./mask.png"));
//fonts
const font = await(client.jimp.loadFont(client.jimp.FONT_SANS_32_WHITE));
const lilita = await(client.jimp.loadFont("./font.fnt"));
avatar.resize(128,128);
mask.resize(128,128);
back.resize(1080,720);
avatar.mask(mask);
verified.resize(36,36);
background.composite(avatar,35,11);
if(verified) return background.composite(verified, 675, 647);
background.print(lilita,197,58, message.author.username);
/*background.print(lilita, 786,75, coins);
background.print(lilita, 931,76, gems);
*/
if(d.config.about) {
background.print(lilita, 45, 652, d.config.about);
} else {
background.print(lilita, 45,652, "Use #about e conte mais sobre vocรช!");
}
back.composite(background,0,0);
var image = new Discord.MessageAttachment(await back.getBufferAsync(client.jimp.MIME_PNG));
client.jimp.write("./assets/profile.png");
message.reply(image);
});
}
};```
@boreal iron 
The essence of sharing code is preserving code that is relevant to the context and leaving out code that is irrelevant in that context.
wat
You may try to save the image on the disk to see if itโs a valid PNG image
(after the manipulation is done)
I'll see
i am still getting the error\
thanks, that worked
what's your question?
Oh dear
I'm trying to make a trivia game, but I've run into a problem. Here's my code:
async def trivia(ctx, client):
point_count = 0
question_count = 0
question_limit = 10
await ctx.send("My trivia game has 10 questions that you will get to answer.")
await asyncio.sleep(3)
await ctx.send("You will have 10 seconds to answer each question.")
await asyncio.sleep(3)
await ctx.send("The game will start in 5 seconds. Get ready!")
await asyncio.sleep(5)
trivia_questions = [
"What is the rarest M&M color? - Brown",
"What is the common name for dried plums? - Prunes",
"What was the first soft drink in space? - Coca Cola",
"What is the most consumed manufactured drink in the world? - Tea",
"Which is the only edible food that never goes bad? - Honey",
"Which country invented ice cream? - China",
"What was the first toy to be advertised on television? - Mr. Potato Head",
"Which member of the Beatles married Yoko Ono? - John Lennon",
"What sport is dubbed the 'king of sports'? - Soccer",
"On the farm, what is a kid? - Baby Goat"
]
question = random.choice(trivia_questions)
while question_count < question_limit:
try:
await ctx.send(question)
input1 = await client.wait_for('message', timeout=10)
answer1 = input1.content
question_count += 1
if answer1 == "bark":
point_count += 1
print(point_count)
print(question_count)
except TimeoutError:
await ctx.send("Your time is up! Please wait for the next question.")
asyncio.sleep(5)
My problem is that if there is TimeoutError, the program ends and does not continue asking questions, while I would like the program to continue asking questions in it's initial randomized fashion, how would I do this?
And bark is just a placeholder, for anyone wondering that reads the code above
will replace with some sort of answer that I also have to figure out soon
not gonna work
also, I find brown M&Ms pretty common
theres no way to return to asking questions?
not that, the concept isn't going to work
do you mean the concept of a trivia game? may I why?
well, first of all you're only accepting 1 right answer
"What sport is dubbed the 'king of sports", if you're british it's called football
yeah I guess some of the questions are a bit subjective
ah yeah
well couldn't I just make multiple answers right?
also, coca-cola, coca cola and coke
all are right
you need to have a list of right answers for every question
yeah I plan on doing that eventually
[
"question": ["answer", "answer", "answer", "answer"],
"question": ["answer", "answer", "answer", "answer"],
"question": ["answer", "answer", "answer", "answer"]
]
like this
right
You'd probably want to fuzzy search your answers anyway.
whats fuzzy search
Approximate string search.
If your answer is set to coca cola,
Fuzzy search would consider coca-cola or even coke cola as an answer even though you didn't set them as a specific answer.
Deals with a lot of the issues mentioned.
Not the football/soccer one though.
research about levenshtein distance, it's probably the easier way to implement fuzzy search
yuck
I don't understand this error.
I don't like most of the alternatives to SQL
And Elasticsearch sounds overkill for this job
It means your bot can't send a DM to a user.
There are a lot of reasons: no mutual server, blocked, privacy settings, etc.
How can I fix this?
By catching the error ahead of time
And handling it
The stacktrace isn't very useful so it's not easy to diagnose where it's coming from specifically
other than you're making the api request
Add .catch after message.member.send()?
It returns a promise, so yes.
How do I use catch again?
<Promise>.catch(...)
So like context but my own variant
May I ask how much experience you have with JavaScript?
6/10
Hmm, let's bump that up to 8/10
Undefined variable errors are quite common, so you may want to spend more time learning the language.
Fixed it. Lol.
good job
Well, now it either doesn't send the check dms even when you do get dmed, or it sends the check dm even when the user blocks the bot/disallow messages from members.
Fixed.
the bot cannot dm the user as they arent in one or more servers together or it could be the user has dms off
I already got that. ๐
ok
JS question;
I'm try to leverage Streams and Transformers to offer a feature where the user can limit how many lines a log file can occupy as I write to stdout/stderr where they've been replaced by a fs write stream. However, my issue is that in order to remove lines from the top of the Stream, I figured I'd need to make two passes. 1 would be a dry run where it's purely meant to stat based on the config and then a second time would be to actually transform the file. Is there a more efficient way/a way to work from the bottom up?
Save lines to array, reverse it, delete last N lines, reverse again and overwrite the file
Albeit longer, it's really efficient since it's all basic instructions
That would require me saving all of the chunks in memory which destroys the purpose of streaming the file.
What purpose would that serve if I meant to transform them later
What exactly do you mean by transform
me when
If you know the chunks you need to transform, store an int and add that to the array (you're using stdout so I'm assuming you have C operator access as well, otherwise there should be a similar method in js) and it'll have the array which you can modify?
Well. I don't know how long the Stream is in terms of chunks and I don't know how many chunks I'll be storing in memory. Assume a user allows for 1000 lines to be in the log file then changes their config to 30 for example. I'd have no way to know the previous max value, the current line count without loading the entire file into memory eventually and stat the current state of the log.
and this is the place where people talk in paragraphs
Loading the entire file into memory is something you should do, but save the values only, and free the stream. Then working through the config you can apply the variables individually
The max log size could easily exceed the max memory capacity. The goal is to be lightweight at any point in time
Then you'd have to read a specific address in the file at a time
That's the only way to not have to load the entire thing, I think
I would assume there's no way to start from a specific index based on new lines
Redundant Method: Use readline and read the amount of lines in the log file and restrict.
No, you'd have to look for newlines or ^
Though from what I have read they don't want a file stream
That was what I was gonna go for. Just ended up asking if there was a way to work from bottom up by chance
that would make things easier
You could use readline-async to make stuff easier
idk if that's possible is my issue
Is it an array or a string
Lemme look at this.
It's a ReadableStream
uhhhh
loads chunks of the file into memory every tick
Loop over the chunks and add it to an inverted writable stream
ie
it = 12;
Offset = stream.size - it;
I don't know how js works I'm trying my best

That's fine. I appreciate the help I have gotten so far. I'm looking into the suggestions
Apologies if I'm not doing a great job at explaining my situation to allow general concepts
then
wstream.chunk[it] = stream.chunk[Offset]
which would invert the array after the loop is completed(?)
import fs from 'fs';
import readline from 'readline'
const fileStream = fs.createReadStream('logger.txt');
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
const linenumber = 0;
for await(const line of rl){
linenumber ++;
// get line information
if(linenumber === 1000){
//break out from your code, or do whatever you want
}
}```
what's the crlfDelay property control?
it should be infinity most of the time
also, CRLF Means Carriage Return, Line Feed if you're confused with that
I do not know much low level terminology, so I appreciate the clarification. I think I understand what the script you wrote does now. I'll try to implement
You could read this
https://nodejs.org/api/readline.html#readline_readline_createinterface_options
"crlfDelay <number> If the delay between \r and \n exceeds crlfDelay milliseconds, both \r and \n will be treated as separate end-of-line input. crlfDelay will be coerced to a number no less than 100. It can be set to Infinity, in which case \r followed by \n will always be considered a single newline (which may be reasonable for reading files with \r\n line delimiter). Default: 100."
Was just looking at node docs. Thank you

So I have this code for a trivia game:
async def trivia(ctx, client):
point_count = 0
question_count = 0
question_limit = 10
await ctx.send("My trivia game has 10 questions that you will get to answer.")
await asyncio.sleep(3)
await ctx.send("You will have 10 seconds to answer each question.")
await asyncio.sleep(3)
await ctx.send("The game will start in 5 seconds. Get ready!")
await asyncio.sleep(5)
trivia_questions = [
"How many legs does a spider have?",
"What is the common name for dried plums?",
"What is the name of the toy cowboy in Toy Story?",
"Whose nose grew longer every time he lied?",
"How many planets are in our solar system?",
"Which state is famous for Hollywood?",
"How many pairs of wings do bees have?",
"What kind of cat is considered bad luck?",
"What is the name of the pirate in Peter Pan?",
"What is the largest mammal in the world?"
]
questions_answers = {
"How many legs does a spider have?" : "8",
"What is the common name for dried plums?" : "prunes",
"What is the name of the toy cowboy in Toy Story?" : "woody",
"Whose nose grew longer every time he lied?" : "pinocchio",
"How many planets are in our solar system?" : ["eight", "8"],
"Which state is famous for Hollywood?" : "california",
"How many pairs of wings do bees have?" : ["two", "2"],
"What kind of cat is considered bad luck?" : ["black", "black cat", "black cats"],
"What is the name of the pirate in Peter Pan?" : "captain hook",
"What is the largest mammal in the world?" : ["whales, a whale, the whales, whale, the whale"],
}
# some stuff in a while loop below
However for some reason my answers for the non integer or word phrases of the integers seem to be right when I answer to my bot but questions like How many planets are in our solar system? and How many legs does a spider have? come out as wrong according to the bot
I even printed out the answers to the questions in console to make sure they 100% match the one I say on the discord channel
not sure why this is happening
const client = require('../index');
client.on('ready', () => {
const ch = client.channels.cache.find(channel => channel.id === "821972674380038166")
const user = client.users.cache.find(u => u.id === "796279185080582185")
if (client.user.presence.status === 'offline') {
ch.send(`**<@${user.id}> is offline**`)
}
})```
it is not sending the message
no errs
Can't you use a dictionary for this instead of a dict and a list?
For questions you'd just rely on dict.keys()
How do you process the answers sent by users?
you are checking your own presence status
no i am not
i am using a diffrent bot to check another bots status
const client = require('../index');
client.on('ready', () => {
//const ch = client.channels.cache.find(channel => channel.id === "821972674380038166")
let channel = client.channels.cache.get("821972674380038166")
const user = client.users.cache.get("796279185080582185")
if (client.user.presence.status === 'offline') {
channel.send(`**<@${user.id}> is offline**`)
}
})```
client.user is literally your client instance user i.e., your bot
}
while question_count < question_limit:
try:
question = random.choice(trivia_questions)
answer = questions_answers.get(question)
print(answer)
await ctx.send(question)
input1 = await client.wait_for('message', check=lambda message: message.author == ctx.author, timeout=10)
answer1 = input1.content
question_count += 1
if answer1.lower() == answer:
point_count += 1
await ctx.send("You got it right!")
await asyncio.sleep(2)
await ctx.send("Please wait for the next question.")
await asyncio.sleep(5)
else:
await ctx.send("Sorry, you missed the answer! Please wait for the next question")
await asyncio.sleep(5)
except asyncio.TimeoutError:
await ctx.send("Your time is up! Please wait for the next question.")
await asyncio.sleep(5)
someone suggested I use tuples instead of a dictionary, is that a better idea?
also sorry for late reply, was busy
hello any one know
how deploy node js bot in aws
cn you pls dm me
async def trivia(ctx, client):
point_count = 0
question_count = 0
question_limit = 10
await ctx.send("My trivia game has 10 questions that you will get to answer.")
await asyncio.sleep(3)
await ctx.send("You will have 10 seconds to answer each question.")
await asyncio.sleep(3)
await ctx.send("The game will start in 5 seconds. Get ready!")
await asyncio.sleep(5)
questions = [
("How many legs does a spider have?", "8"),
("What is the common name for dried plums?", "prunes"),
("What is the name of the toy cowboy in Toy Story?", "woody"),
("Whose nose grew longer every time he lied?", "pinocchio"),
("How many planets are in our solar system?", ["eight", "8"]),
("Which state is famous for Hollywood?", "california"),
("How many pairs of wings do bees have?", ["two", "2"]),
("What kind of cat is considered bad luck?", ["black", "black cat", "black cats"]),
("What is the name of the pirate in Peter Pan?", "captain Hook"),
("What is the largest mammal in the world?", ["whales, a whale, the whales, whale, the whale"]),
]
while question_count < question_limit:
a_tuple = random.choice(questions)
question, answer = a_tuple
question = a_tuple[0]
answer = a_tuple[1]
try:
await ctx.send(question)
input1 = await client.wait_for('message', check=lambda message: message.author == ctx.author, timeout=10)
answer1 = input1.content
question_count += 1
if answer1.lower() == answer:
point_count += 1
await ctx.send("You got it right!")
await asyncio.sleep(2)
await ctx.send("Please wait for the next question.")
await asyncio.sleep(5)
else:
await ctx.send("Sorry, you missed the answer! Please wait for the next question")
await asyncio.sleep(5)
except asyncio.TimeoutError:
await ctx.send("Your time is up! Please wait for the next question.")
await asyncio.sleep(5)
Well I made it less repetitive by using tuples
however the original problem still persists
integers and word versions of them don't seem to be accepted but the other ones are
Can someone tell me what "require.main.filename" means here?
path.join(path.dirname(require.main.filename), directory)
Did you create a machine on aws
you know
i just pay for 12 month trial
i cant know how deploy
so i need help
Well, then create a server first.
Why?
Howe to upload image to description?
Using htmlโ img tag
Can u do for me?

pls come vc
Canโt talk rn
Are you going to use ssh key or a simple root password?
i cnt know any thing sir
Idk about html
i just use microsoft asuz for hosting

The process is identical to azure and aws
hmm
Do you have a ssh client?
itโs <img src="IMAGE LINK HERE">
an additional alt Attribute can be added
To replace the image if it doesnโt load
Hello how can I make my website link embed like this https://top.gg/
Spice up your Discord experience with our diverse range of Discord bots
@stable eagle Can you tell me?
Thereโs a html tag for that, named <embed>
Oh ok ty
Do I need the members intent to see all guild members possessing a certain role? I have seen advaiths guide but I couldn't see anything relating to this
I can't get it. Can you explain me
What are you trying to achieve? You want to make it so a title and description appears when you link your website in a Discord chat or are you trying to do something else?
Better just turn on all intents
You're not handling lists as answers here
And str == list will never be True
Never say never :P
I ain't fucking around with operator overloading for this ty
But ctypes 
is it bad that I don't know what operator overloading is
also i got it to work so its fine
question, answer = random.choice(questions)
After making questions and answers into a tuple and then into a list, I just assigned like this and it worked out
Huh
When I send link in chat. It will show title and description.
async def trivia(ctx, client):
point_count = 0
question_count = 0
question_limit = 10
await ctx.send("My trivia game has 10 questions that you will get to answer.")
await asyncio.sleep(3)
await ctx.send("You will have 10 seconds to answer each question.")
await asyncio.sleep(3)
await ctx.send("The game will start in 5 seconds. Get ready!")
await asyncio.sleep(5)
questions = [
("How many legs does a spider have?", "8"),
("What is the common name for dried plums?", "prunes"),
("What is the name of the toy cowboy in Toy Story?", "woody"),
("Whose nose grew longer every time he lied?", "pinocchio"),
("How many planets are in our solar system?", ["eight", "8"]),
("Which state is famous for Hollywood?", "california"),
("How many pairs of wings do bees have?", ["two", "2"]),
("What kind of cat is considered bad luck?", ["black", "black cat", "black cats"]),
("What is the name of the pirate in Peter Pan?", "captain hook"),
("What is the largest mammal in the world?", ["whales", "a whale", "the whales", "whale", "the whale"]),
]
while question_count < question_limit:
question, answer = random.choice(questions)
print(question)
print(answer)
try:
await ctx.send(question)
input1 = await client.wait_for('message', check=lambda message: message.author == ctx.author, timeout=10)
answer1 = input1.content
question_count += 1
print(question_count)
print(point_count)
if answer1.lower() in answer:
point_count += 1
await ctx.send(f"You got it right! Point Count: {point_count}")
await asyncio.sleep(2)
await ctx.send("Please wait for the next question.")
await asyncio.sleep(5)
else:
await ctx.send("Sorry, you missed the answer! Please wait for the next question")
await asyncio.sleep(5)
except asyncio.TimeoutError:
await ctx.send("Your time is up! Please wait for the next question.")
await asyncio.sleep(5)
await ctx.send(f"The game is over! Thank you for playing. Your final score was {point_count} points. Good job!")
^ this
it executes as I want it to, now I just have to figure out how to make it so the last msg doesn't say "Please wait for the next question" again
but like
its 3 Am for me rn so I'll probably do it tomorow
Yeah that makes sense with the in operator
yeah turns out I needed that
Pls come there
Actually, not exactly
Try replying with e when the answer is eight
or o for woody
oh 
well this is awkward 
That's incredibly unhelpful but thanks anyway

Yes since that involves fetching the whole member list which requires the intent
if isinstance(answer, str): # One answer
condition = answer == input1
else: # Iterable as answer, aka tuple or list
condition = input1 in answer
But can't you do GuildRole.members in djs? Or is that basically doing the same thing
I've always worked with the safety of a lib do idk what some of these methods actually do
hey anyone knows any good image gen api something like what owo does
ive never seen that code before but what does the condition = answer == input1 mean? Is it saying the condition is equal to the answer which is equal to the input?
and I'm not familiar with isinstance but i looked it up on the documentation and think I kind of get it
In case that an answer is of type str, meaning there's only one accepted answer for it, it will compare the user input directly to the answer, hence the == and not the in
Because if you used in, specific letters from the string could be considered an answer
What you use condition for is to confirm that the user entered the correct answer
It will be of type bool, so you can just do if condition: to do something if answer was correct
thank you
You can set whatever you want
keep in mind
You have 1000 servers
every server has one rainbow role
you're changing the color every 10 seconds
1000 api requests every 10 seconds
100 api request every second
That's api abuse
what is djs-threads is all about?
oh I understand now
thanks for the elaboration
yeah it works correctly now, I can't type in a single letter for a right answer anymore 
๐คฃ
I'm using node-canvas's Image class and I want to generate a solid colour image. How can I do that?
for slash commands. Should I register the commands on client ready or before it gets ready??
before ready as you register them with http and not through the gateway
actually why would you register commands on every run
so then how will I register a command for a specific guild?
as the guild is not available in the cache. client.guilds.cache
in that case do it in the ready event
global commands too?
npm ERR! code 127
npm ERR! path /root/KiroBot/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! sh: 1: node-pre-gyp: Permission denied
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-06-30T08_56_00_087Z-debug.log```
im getting this when trying to install canvas and discordjs/opus
Rust, egui
Is there any way to take up ALL of possible window width in a Widget? Ui::available_size() returns a Vec2 which has a small margin from the corners of the window.
ctx.fillStyle = "...";
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
Not sure what the Image class has to do with anything tho
it's for loading images
does someone know about this? Im using ubuntu lastest
@cinder patio i wanted a literal image because i was going to use it in ctx.drawImage
Anywas I figured it out
Just set image.src to canvas.toDataURL()
you said you wanted to generate a solid colour image though 
also why not just draw the color yourself
i just made a 1px ร 1px canvas and colored it
then drew the image to whatever size i want
Why not just directly draw it?
yeah why
Why does my bot dont get any role in its name when its added to any server?
I never got the proper answer to this question
And pls ping me when answering to my question
what is a. staged channel. and whether a bot can join it or not?
hmm ok. So I guess bots can join it, right?
TypeError: serverQueue.connection.dispatcher.seek is not a function
Wasn't there such a function in discord.js?
connection.dispatcher.seek(ms)
you need to use the webhook
Just normal discord webhook ?
no
discord webhook isn't a webhook
it's just a "remote messenger"
webhooks are reverse-apis
Can you tell me more about it how can I make one for my bot ?
Like any docs
Something
what language?
js or py okay
which one is the one you made your bot in?
Js
Thanks
Ooh this tell about my server count, and etc as well thanks ๐
Ty
How can I send a message into a channel when I invoke the event 'on GuildCreate' with hte object 'guild'?
you need to get a channel from the guild object by some criteria
Does somebody knows how can i do v12 this code ?
It works on v11 but not on v12
did you just use รง on code?
I want to delete a certain number of messages from a certain user.
So I need to fetch a certain number of messages from a user. How can I do this
keep fetching messages in batches
filter the fetched messages
repeat if the count doesn't match the n elements desired
you should probably put a limit on that though
i.e. 10 fetches of 100 messages
i didnt mean to send that ok ๐ ๐ป
and i cant delete it
perfect
r/AwfulEverything
!client.setups.get(message.guild.id, 'aichatsystem.enabled')
^
TypeError: Cannot read property 'get' of undefined
at AiCommand.run (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\src\commands\fun\AiCommand.js:26:24)
at MessageEvent.run (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\src\events\message\MessageEvent.js:21:17)
at Client.emit (node:events:394:28)
at MessageCreateAction.handle (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (node:events:394:28)
at Receiver.receiverOnMessage (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\ws\lib\websocket.js:833:20)
at Receiver.emit (node:events:394:28)
at Receiver.dataMessage (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\ws\lib\receiver.js:517:14)
at Receiver.getData (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\ws\lib\receiver.js:435:17)
at Receiver.startLoop (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\ws\lib\receiver.js:143:22)
at Receiver._write (C:\Users\TAHIR ISLAM\Desktop\venomous\Venomous\node_modules\ws\lib\receiver.js:78:10)
[nodemon] app crashed - waiting for file changes before starting...
how to solve
Loop over all channels, check if bot has perms to send message et voila u got ur channel
Thx I got it already
ok lemme see
guys
my bot is running on 1gb RAM and 1 core cpu (only 50% usable)
what should i increase ?
well, are you hitting any limits?
is it possible to get user banners on discord.js yet?
No
rip
Hey, I am trying to delete messages buy a certain user. But the bot doesnt filter the messages. Here is the code:
userToDelete = await msg.mentions.users.first() || await client.users.fetch(args[1]).catch(() => { })
let numberMessages = args[0];
await msg.channel.messages.fetch({ limit: numberMessages }).then(messages => {
const messagesToDelete = messages.filter(msg => msg.author.id === userToDelete.id)
messagesToDelete.forEach(msg => {
console.log(msg.content)
});
})
userToDelete is the user I mention (works fine)
numberMessages is fine, too (if (isNaN(numberMessages)) return)
console.log(msg.content) returns the latest <number> messages (by all users)
So I dont know what the problem is. Can anyone help me?
This is a Date.now() output : 1625066662626
How can I input a date for 00:00:00?
Because I want to set a cooldown until 00:00:00 and after the command set it again at 00:00:00
use cron jobs for that
or use redis TTLs
that'd work too, but if u dont use redis, go for cron's
packages?
(like a 24 hour cooldown)
look one up
but these are packages?
what does mean look it up?
you could make it yourself, but if you have to ask if its a package you probably wont manage to do so
thank you
np
https://crontab.guru/ use this to make ur cron jobs
An easy to use editor for crontab schedules.
cuz i 100% know you coming back to ask how to do it
I was sure more than u
0 0 * * *
should be this
correct
40 packages are looking for funding
run npm fund for details
4 high severity vulnerabilities
What is this?
should be able to do audit fix or just ignore it
if u installed a big package, that is
wouldnt trust small packages with those
I have another question, help about installing ffmpeg on a vps (Centos 8.3 x64), guides on internet doesnt work, idk why
How I know how to name my timezone?
In europe timezones are kinda trash
lol how are they trash? like you get some relatively easy to calculate ones
@command(name="addrole", help="Add a new server role, with optional color and hoist.")
@has_permissions(manage_roles=True)
async def add_role(self, ctx, name: str, color: Optional, hoist: Optional[bool]):
try:
role = await ctx.guild.create_role(name=name, color=int(color, 0), hoist=hoist)
await ctx.send(embed=Embed(description=f":white_check_mark: Created a role {role.name}"))
except (Forbidden, HTTPException):
await ctx.send("It seems I don't have permission to create roles")
Everytime i wanna create some function with optional parameters more than one
i stuck at it
do.. you know exactly what you're even doing?
no, i mean, with the optional arguments
do you know how you're supposed to be writing them?
an ideal formal would be something like this
!addrole role_name 7890 true
but i wanna make the other two params optional
that color and hoist
where as hoist is bool
so if I type cmd something like this
!addrole role_name true
it should ignore color parameter
GT + 2, I dont know wich towns I should write, Rome, Berlin, Bruxelles
or should i just make a group cmd?
Date.getTimezoneOffset
I'm hosting my bot on a American VPS
just one of them, i would use the one that is in your country (just for persistance idk)
read it first
so it isnt my timezone
I can get the vps timezone in a console log and then add at gmt?
UTC*
('August 19, 1975 23:15:30 UTC + difference between console.log and my actual hour');
right?
480/8 is like 60, so if I have +2 is +120, right?
what?
The getTimezoneOffset() method returns the difference, in minutes, between a date as evaluated in the UTC time zone, and the same date as evaluated in the local time zone.
in minutes, between a date as evaluated in the UTC time zone, and the same date as evaluated in the local time zone.
in minutes
why u dividing 480/8?
480 is the amount of minutes between a timezone in UTC-8 to UTC-0
so its foward 480
if u have 2 timezones
you need to know hwo many minutes/hours are between eachother
if one is at UTC-5, and your target in UTC-8, you'd get a difference of 3h(60*3)
Ho dear
this image triggers me a bit, and im trying to figure out why
I donโt know too much about python but I donโt think it looks like that
what would i add for the slash command https://github.com/RealYusufIsmail/Moderationbot-with-other-features/blob/master/bot.js
the keyboard color, macbook, tiny screen, having an externcal keybaord when the point of a laptop is being compact
i've spotted a few things already, but idk, they suddenly jumped at me the moment i looked at it, but i couldnt figure out why i disliked it
slash commands use an entirely different endpoit
so what would i change
read that
CSS sticker
Clearly never touched that shot before
no need to use client.api
you can just reply to the interaction itself
interaction.reply(options)
tell that to them, not me
i use detritus, not that shit

you are the one who shared the link man
not the one who wrote it tho. make a github issue if u want to PR it
it should work as is
bro just donโt share that document in the first place
https://deploy-preview-638--discordjs-guide.netlify.app/interactions/registering-slash-commands.html
i couldnt care less
literally the first result
and by one of the most active guys in ddevs
and with 110 stars
itโs old
pretty sure it was before v13 dev came out
oh yours is for v12
did u bother reading it?
the one i sent is the proper way of doing it on v13
yes so send something that doesnโt use that then???????????
,
FUCKING READ IT?
just shush fam honestly
your weird man
If you are using client.api you should switch over to official support. The following legacy information is not recommended or supported for use.
learn how to read brother
https://deploy-preview-638--discordjs-guide.netlify.app/interactions/registering-slash-commands.html
,
,
Suddenly remembers why I avoid this channel
Hey, I am trying to delete messages buy a certain user. But the bot doesnt filter the messages. Here is the code:
userToDelete = await msg.mentions.users.first() || await client.users.fetch(args[1]).catch(() => { })
let numberMessages = args[0];
await msg.channel.messages.fetch({ limit: numberMessages }).then(messages => {
const messagesToDelete = messages.filter(msg => msg.author.id === userToDelete.id)
messagesToDelete.forEach(msg => {
console.log(msg.content)
});
})
userToDelete is the user I mention (works fine)
numberMessages is fine, too (if (isNaN(numberMessages)) return)
console.log(msg.content) returns the latest <number> messages (by all users)
So I dont know what the problem is. Can anyone help me?
why are you awaiting a collection?
for fetching
first() doesnt return a promise
no need to await it
one thing that you should absolutely do is use await OR then
preferably await, dont mix them
await msg.channel.messages.fetch({ limit: numberMessages }).then( => bad
let messages = await msg.channels.....fetch(); => good
also usertodelete might be undefined
the problem is it works but the messages wont be filtered
exactly what i said
you have a catch() block in the end
and its not returning anything
if u dont mention anyone, and the fetch() fails, the userToDelete is undefined
hence ur filter functions searches for message with user.id = undefined
oh yes it returns something
then use this
I just got it. I had to loop over both messages:
messages.forEach(msg => {
console.log(msg.content)
const messagesToDelete = messages.filter(msg => msg.author.id === userToDelete.id)
messagesToDelete.forEach(msg =>{
console.log(msg.content)
})
});
Works now
No that's the fun part
because you will pretty much always run into the two event loop same thread issue
@modest maple why would it run into 2 event loops if it only makes one when there's no running event loop?
because asyncio.run is being pushed as becoming the standard and that always makes a new event loop
so get_event_loop makes a new loop if one isnt running
so if you have say the current client setup
bot = discord.Client()
doing asyncio.run() will break your expected behaviour because bot.loop no longer becomes the current running loop.
so in your traditional:
client = discord.Client()
topgeegee = topgg.ClientThing(client)
@client.event
async def foo():
...
async def main():
await client.start()
asyncio.run(main())
would run into the two event loops issue as it currently stands
hence why discord.py in v2 is planning to move away from the tradition client.run and will likely need to adjust how the client.loop behaves or just remove it entirely / make it a property for getting get_running_loop
and this is where it would require either re-designing the top.gg py sdk for supporting v2 and v1 together or require another setup for v2 entirely
Ah, so it should be "get" only?
eh?
How should it behave when there's no running event loop?
As opposed to "get or make"
TL;DR of how asyncio is moving: get_event_loop going, get_running_loop should be used everywhere (which is correct but people always abuse get_event_loop hence why it's not used as much as it should be)
the old asyncio.get_event_loo().run_until_complete() should be replaced by asyncio.run() which handles cleanup as well
I see, so it's just gonna be a crash if the user hasn't started a loop?
basically trying to remove the things that people always hang themselves on
well crash if it's not in a async context
which is better than the current; fail with undefined behaviour by just not working how you expect vs explicitly
take asyncio.Event for example
if you dont do that in a async context
it wont work correctly at all because it uses get_event_loop internally (which is being moved to get_running_loop in future versions)
I see, that makes sense. But I don't see why it's bad to get a running loop or make one inside the run method, considering it's a high-level method so that users don't need to clean up the ws connection
its just a ecosystem thing
in the same way you generally expect code to be formatted according to PEP8 or web frameworks to follow something like PEP333(3)
the idea is the developer controls starting and initiate the main function
this arguably make the code more explicit about what you're doing
if you think about how many people come in here using repl.it or some web framework and wondering why their code under client.run doesnt run

Could anyone point me to any 'model' (i.e the kind of thing people should copy) open source projects on github so I can try and pick up some best practices?
if you're copying it's already a bad practice
basically keep 5 things in mind:
1 - If you're repeating something too much, it's time to use a variable/function
2 - You write for humans to read, not for computers
3 - Use proper casing for the situation
4 - If you open, you close
5 - Always prefer while/for or switch over repeated ifs
also, many "rules" of programming are language specific and learned over time.
just giving a code base to look at really isnt helpful in most cases.
Just an advanced question about RewriteRules
https://api.domain.com/3646119?api-key=test
My current RewriteRules don't accept query arguments starting with a ? (instead of a &)
RewriteEngine On
RewriteRule ^/?(.*) /index.php?lookup=$1 [PT,L]
As you can see the requests will be redirected (as passthrough) to /index.php?lookup=3646119
I wanna provide the api key as "first" query argument which doesn't work at the moment.
Any other query argument starting with a ? will be cut off of course.
How should the RewriteCond be like to transform the request example (mentioned above) to:
https://api.domain.com/index.php?lookup=3646119&api-key=test
How can i add the in-built minigames in discord to my bot?
yes, in Discord.js
Like chess, YouTube, etc...
Those aren't built in to Discord, unless I'm confusing something
I saw a bot that sends you an invite ,and you can play it in any vc
yeah, dont think discordjs supports that yet
what supports it then?
i can add other language modules if need them
well, you can make something custom to add that support to djs. detritus might support it
mhmmmm...
you mean Discord activities .there is a Libary for it
I really wouldn't call them rules
they're merely practices
bad practices will eventually lead to underperforming code
whats the name of it?
@opal plank cm here, sell your bread
yeah




