#development
1 messages · Page 908 of 1
@opaque seal what do you mean instantly goes away?
It like sets the limit and then after a split second it removes it
and set the channel to unlimited userLimit
I can't understand why
either you have some other code overwriting this one, or this one is overwriting itself
you are executing multiple requests concurrently, which is never a good idea anyway
you should await each request
either you have some other code overwriting this one, or this one is overwriting itself
Yeah that's what I thought, but I'm 99.9999% sure it isn't
I've checked
you should await each request
ok
Yeah I was about to say something about the async function not having any awaits
Hey,
My Code has an Error:
ReferenceError: Cannot access 'voiceConnection' before initialization ReferenceError: Cannot access 'voiceConnection' before initialization /rbd/pnpm-volume/433a83ca-f352-490e-9316-c380057bb4b2/node_modules/.registry.npmjs.org/opusscript/0.0.7/node_modules/opusscript/build/opusscript_native_wasm.js:8 var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow){throw toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMEN abort(ReferenceError: Cannot access 'voiceConnection' before initialization). Build with -s ASSERTIONS=1 for more info.
Does anyone know whats wrong with it?
since i have v12
My Code:
var outofrange = new Discord.MessageEmbed()
.setTitle("Out of range")
.setAuthor(message.author.username)
.setColor("RED");
var nomu = new Discord.MessageEmbed()
.setTitle("❌ | No Music is being Played")
.setColor("RED")
.setAuthor(message.author.username);
var nomy = new Discord.MessageEmbed()
.setTitle("❌ | You're not in my Channel")
.setColor("RED")
.setAuthor(message.author.username);
var nonu = new Discord.MessageEmbed()
.setTitle("❌ | This is not a Valid Number")
.setColor("RED")
.setAuthor(message.author.username);
let vol = args.join(" ");
if (!Number(vol)) return message.reply(nonu);
const voiceConnection = voiceConnection.find(
val => val.channel.guild.id == message.guild.id
);
if (voiceConnection === null) return message.channel.send(nomu);
if (!message.member.voice.channel) return message.channel.send(nomy);
const dispatcher = voiceConnection.player.dispatcher;
const currentvol = dispatcher.volume * 100;
if (!vol) {
let embed = new Discord.MessageEmbed()
.setDescription(`**Current Volume:** ${currentvol}%`)
.setColor("ORANGE")
.setAuthor(message.author.username);
return message.channel.send(embed);
}
if (vol > 200 || vol < 0)
return message.channel.send(outofrange).then(response => {
response.delete(5000);
});
let embed = new Discord.MessageEmbed()
.setDescription("Volume set to " + vol)
.setColor("GREEN")
.setAuthor(message.author.username);
dispatcher.setVolume(vol / 100);
message.channel.send(embed);
}
what do i have to set there?
i dont know what you want to do
but you're trying to access something from the very thing you're defining
which is invalid
find the Voice Connection on the Server that the message camer from
i did
well something is wrong
you mean the voice connection that the bot has in that server?
And they say sth with voice connection. yes
Tim I'm trying to send the code with hastebin but it seems to not work
what doesn't work? tell us
hastebin
oh my goodness
How can I send you my code guys?
i'm scared of my own code
Any methods other than hastebin?
there are a bunch of different bins
you probably tried hastebin.com, try hasteb.in
pastebin
you probably tried hastebin.com, try hasteb.in
yeah
Indentation got messed up at the end
embarrassing that a cert's asking it but does anybody here want to share how they handle custom prefixes
hello my bot 79 commad
embarrassing that a cert's asking it but does anybody here want to share how they handle custom prefixes
I store it in my database
well duh lol
quick.json 😎
https://hasteb.in/zotadaje.js
btw this worked a couple days ago, then I've made some changes, not to the limit part, and now it isn't workin properly
@quartz kindle ty works now
@sick cloud ```js
// message event
let prefix = message.guild ? client.app.getPrefix(message.guild.id) : client.defaultPrefix;
// app class
getPrefix(id) {
if(!this.client.guilds.cache.get(id).AppData) {
let guild = this.db.prepare("SELECT * FROM guilds WHERE id = ?").get(id);
if(guild) {
this.client.guilds.cache.get(id).AppData = JSON.parse(guild.data);
} else {
this.client.guilds.cache.get(id).AppData = {};
}
}
return this.client.guilds.cache.get(id).AppData.prefix || this.client.defaultPrefix;
}
i use better-sqlite3
@lofty grove Don't ask to ask, just ask
@opaque seal ```const http = require('http');
const express = require('express');
const app = express();
app.get("/", (request, response) => {
console.log("7/24 online");
response.sendStatus(200);
});
app.listen(8000);
setInterval(() => {
http.get(http://trexdash.glitch.me/);//Enter your glitch link correctly!
}, 280000)
should i add this to bot.js?
7/24 online lol
great english
@opaque seal what is halls?
better-sqlite3 best
uhm it's an object variable that I define earlier in the code
i'm making an oss bot and using enmap which is better-sqlite3 behind it so /s
console.log("7/24 online"); Could there be a typo?
24/7
maybe
i just always make it check on message event
@sick cloud not at the moment. i will add a single hardcoded mention command to obtain the current prefix
because right now, if people forget the prefix, there is no way to get it lmao
cool
lul what
i make it defaults to the prefix command if it detects a mention (without content/command)
yeah, my bot mention used to have a function on its own, where it would talk to people and ask random questions
but i removed it in my latest update
i just made it send the current prefix on mention
ye same
and the mention prefix would also work
yeah thats what im gonna do probably
it's the most simple way
but not the mention itself, it has to be with a command
i always add mention prefixes anyway
because i had a stupid problem once
where a guild got raided
by accounts spamming mentions
omegalul
and my bot started queuing responses due to rate limits
do you have a cooldown system?
and after the raid ended, my bot kept spamming them with responses
i do now lmao
for a while there was a rumor that my bot had been hacked and aided in the raid lmao
wow effort
and its based on something i made for a cli
my cooldown system is weird af
so i copied that
my bot's got a very very simple handler/cooldowns because it's an open source bot i'm publishing, so i'm not putting anything fancy in it
my actual bot has an auto blacklist system and all
i dont have per user nor per command cooldowns, i just have a global cooldown per channel
good idea
that's a decent idea
but also multiple users cant use at the same time
this oss bot just has per cmd/per channel non-persistent
if they send more than 5 commands per 5 seconds, they get a "too many commands" response and ignore future commands for 5 seconds
if(ratelimit[message.channel.id] === undefined) { ratelimit[message.channel.id] = 0; }
ratelimit[message.channel.id]++;
if(ratelimit[message.channel.id] > 5) { ratelimit[message.channel.id]--; return; }
if(ratelimit[message.channel.id] === 5) {
ratelimit[message.channel.id] += 99;
setTimeout(() => { ratelimit[message.channel.id] -= 100; }, 6000);
return message.reply("Too many commands").catch(console.log);
}
setTimeout(() => { ratelimit[message.channel.id]--; }, 5000);
``` lmao
because it can be 0
wew
Just copied it from the guide xD
bad
why?
Copying without knowing what it does is a bad idea
oh yeah
not persistent though
had to focus more on other stuff
a set isnt persistent of course
tim, mine is crap compared to yours:
each command has some type of cooldown (usually 60s for api cmds, 120s for high use api cmds)
you can use it with 3-5 second gaps while on cooldown
if you spam the command 5 times while on cooldown you get blacklisted for 1 hour (all cmds/msgs ignored)
after that, if you repeat again and keep spamming, you'll get permanently blacklisted
Guys when I use this code I can see the voice channel get's a user limit but then it instantly goes away:
guy.guild.channels.create(roomName, { type: 'voice' }) .then(async nChannel =>{ let limit = newState.channel.userLimit; let br = newState.channel.bitrate; guy.voice.setChannel(nChannel); nChannel.overwritePermissions([ { id: every, deny: ['CONNECT'], }, ]); if(limit !== 0){ nChannel.setUserLimit(limit) } nChannel.setBitrate(br); ```Do you know why?
Anyway, can someone figure out why this happens?
desktop
thanks mobile
works for me?
@sick cloud it does?
smh
sry for the ping
i'm talking about the codeblock showing
oh
your code is a little confusing because you're using functions instead of just providing it all on creation
@opaque seal the reason i asked about halls before is that you're executing everything in a for loop, looping over halls
so if for any reason two items of halls lead up to the same channel, it could be overwriting it
i mean via webhook
yeah guess so lol
so if for any reason two items of halls lead up to the same channel, it could be overwriting it
good point but this shouldn't at 99.9% happen
let me check thought
Also it would create 2 channels and not just one
Omg
I found out why
I'm stupid
No nvm
yes this is what im getting lol (node:25) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
another thought would be reordering the functions
what do you mean with that? Like put everything in the 'create'?
first check for the category channel, if it doesnt exist create it, then create the channel and specify the category in the channel creation options, so you dont need to make another call to set the category, as the channel will already be created inside the category
Yeah I should do that
tim should i make a caching system or just fetch the data live from the server every time a command is executed?
also, cant bit rate and user limit also be defined in the channel creation options?
and after all that, move the user
@pale vessel depends
if its on a command, you should be safe fetching it
for example, prefixes
if its on every single message, cache
and after all that, move the user
Yeah thanks, anyway something really weird is happening inside my code
because it's hard to manage, i have to delete the cache and stuff
yes, if the prefix changes, you have to update both cache and db
yep
or delete cache to force refresh
let prefix = message.guild ? client.config.ensure(message.guild.id, defaultConfig).prefix : defaultPrefixes;
let prefixArray = [`<@${client.user.id}>`, `<@!${client.user.id}>`, prefix];
if (!prefixArray.find((i) => message.content.toLowerCase().startsWith(i))) return;
this is what i come up with
think it should work?
i do the latter
i keep geting this lol
raw: '{"error":"Unauthorized"}', body: { error: 'Unauthorized' }, status: 401,
sure should work
read the error
sweet
yeah i know what its saying
maybe instead of .find, you can use .some not sure if it has any performance benefit tho
i just dont know why its saying im not authorised lol
your talking to me right lol
no
lol
oh lol
yes hes talking to you
my bad
thanks tim
do you know where the error is coming from?
stop messing with my head hahahah
what are you doing when the error shows up?
like, are you making a request to top.gg?
sounds cliche
i just start my bot up
ive checked webhook details with my bot files etc and everything is good
yes
show the relevant code
oh no worry i didnt make any changes all i did was upgrade my vps
which shouldnt effect it
will .some return a boolean?
raw: '{"error":"Unauthorized"}', body: { error: 'Unauthorized' }, status: 401, headers: { date: 'Mon, 04 May 2020 22:16:06 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '24', connection: 'close',
yes, .some returns a boolean
some and every
@earnest phoenix does the error not show any url? it doesnt really help if we dont know what code is generating that error
does it not have a stack trace
cool
'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'strict-transport-security': 'max-age=15552000; includeSubDomains; preload', 'x-content-type-options': 'nosniff',
might help
cloudflare lmao
why would cloudflare deny me access tho hahaha
if (member.hasPermission('KICK_MEMBERS')) {
TypeError: member.hasPermission is not a function
cann someone help
it changed to permissions.has
Ok thank you Tim, idk how, but just by reordering my functions and putting everything into the create one, it works fine now
like this?if (member.permissions.has('KICK_MEMBERS')) {
d.js?
yes
then hasPermission shoudl work
maybe member is wrong?
yeah
theres an error
that
i defined member
where did you get member from?
as?
Share the code
it's message.member
message.author is not a member
that's not a member
author is a user
thats not how it works

message.member
yikes
message.member works
you can delete it
If the message is sent in a guild
why
im working on a redesign for my bots battle system. would here be an appropriate place to ask for feedback on the layout i've chosen?
well
oh yeah
unless u want a webhook token sniped
ok
would i just add whatever i need to into my /home/user folder?
ill setup a const
okokok
const webhook = webhookid
const reason = message.content.split(" ").slice(2).join(" ");
const member = message.author
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'kick':
if (member.permissions.has('KICK_MEMBERS')) {
if(!args[1]) message.channel.send('Please put a members username.')
const user = message.mentions.users.first();
if(user){
const memberr = message.guild.member(user)
const embed = new Discord.MessageEmbed().setColor('#099ff').setTitle('Kick command').setDescription(`Looks like someone made a bad choice!\n\n${message.author} kicked ${memberr} from the server!`)
if(memberr){
memberr.send(`You have been kicked from the server.\n\n**Reason:**\n${reason}`)
memberr.kick(`Kicked from the server for reason: ${reason}`).then(() =>{
message.channel.send(embed)
webhook.send(`${user} was kicked by ${message.author.tag}\n\n**Reason:**\n${reason}`)
})
}
if(!memberr){
message.channel.send(`That isn\'t a member!`)
}
}
break;
}
}
})```
there
ok stop
ok, you got your contabo vps noob?
yeah
now what do i do
accidentally got a german vps but eh
member.permissions?
what linux distro
is that a thing in djs
thats what i was told
ubuntu
i just use 'putty' on windows to ssl into the host, then i have a custom 'bot' folder in the root folder
same as last vps
you can also use filezilla
member.permissions?
yeah
dont use root
to just mass transfer files
ok its a vps who cares
lol
but i still wouldnt use root
root is default folder it puts you in when ssl, which is why i chose there
it would be best to have a different directory, but for my ease in testing...
what do i do
u know u can just login to a different user
make a new user
yea after you make one 😄
yeah
which tbf, is best practice
what do i do
chill
a user with sudo > root
yea for sure
im being ignored
yes
and we know too lol
i wasnt in root but i made my own folder, /Starboard 
whats your issue mr quick?
they sent a code
const webhook = webhookid
const reason = message.content.split(" ").slice(2).join(" ");
const member = message.author
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'kick':
if (member.permissions.has('KICK_MEMBERS')) {
if(!args[1]) message.channel.send('Please put a members username.')
const user = message.mentions.users.first();
if(user){
const memberr = message.guild.member(user)
const embed = new Discord.MessageEmbed().setColor('#099ff').setTitle('Kick command').setDescription(`Looks like someone made a bad choice!\n\n${message.author} kicked ${memberr} from the server!`)
if(memberr){
memberr.send(`You have been kicked from the server.\n\n**Reason:**\n${reason}`)
memberr.kick(`Kicked from the server for reason: ${reason}`).then(() =>{
message.channel.send(embed)
webhook.send(`${user} was kicked by ${message.author.tag}\n\n**Reason:**\n${reason}`)
})
}
if(!memberr){
message.channel.send(`That isn\'t a member!`)
}
}
break;
}
}
})```
```TypeError: Cannot read property 'has' of undefined```
permissions probably
what user are u on then @grizzled raven
Just look up the doc you'll find all your answers on there https://discord.js.org/#/docs/main/stable/general/welcome
i need help
The doc is there for you
thats some sample code i use for permissions
@clever garnet users don't have perms, members do
what do i do
read docs
where
whatdoidowhatdoido
read docs
yeah man, someone could code that for you but you wouldn't learn anything
poor developers generated a well-designed docs but no one uses it
yea, tbf, i had coded it, bbut they are right, you should read over the docs
because pepega
you have to
same
because i use better sqlite the process is 600x longer/harder
i use nginx, and docker containers
tmux over screen
lol
yea, do updates and install any tools you might use
ik its something to do with python and gyp but like
sudo apt-get install build-essential
tim to the rescue again lol
command spoonfeed
is it "you are a kind man, thank you"?
or something
both works
nah its not spoonfeed im writing it word for word so im not copying
lmao
fair enough
best logic
lmao
kind good
anyone have any idea how one would implement sharding into a bot that runs within a docker container? is it possible to have my shards run in different containers? and on different servers entirely?
thats called clustering and yes it is possible, but you can find Libraries to help you do so
you can configure each shard with a specific shard id or array of shard ids
and set them all to the same total shard count
oh, i can? i thought discord js forced the shard id with its manager thing.
but you need to manually control their connections, because they cannot connect concurrently
so im guessing then i wouldnt use the default manager and would have to implement my own?
yes
big brain code time
my bot will die in 18 mins i need to setup this vps fast
so for example you would have to do (for simplest solution)
Cluster 1:
- Shard 1
- Shard 2
- Send ready to spawn to cluster 2
Cluster 2: - Shard 3
- Shard 4
you'd need a centralized process that the shards connect to, in order to coordinate logins
^
yea, thats no issue really
or keep hitting discord's identify rate limits until it lets you connect lmao
my intent was them to connect to website to pass data on user count etc to website anyway
i can easily have some website api endpoint that handles some extra stuff
sure
sweet, as long as possible i'll figure it out when that time comes 😄
another thing is that rest rate limits are global
how tf are u missin make
so your shards wont be aware of how much the other shards are using the rest api
also do u have base-devel installed
but that would only be a problem if you use cross-shard rest requests
like requesting data for guilds that are in other shards
at most it'd be sending a report embed to my own server
but can easily change that to send to website and save in file or some junk
let me check
14mb in the main file, 4mb in the wal file
possibly more in memory, the file size doesnt necessarily reflect the true database size while its running
what kind of db do you use? sql?
sqlite
i dont like sql query syntax 😄
i kinda do lmao
i like it that its consistent across a multitude of sql libraries, drivers, databases and implementations
tbf its not that bad, and is pretty explicit, but i like how mongoose gives me better readabilities
i find mongoose schemas confusing lmao
but i never really tried learning them anyway
xD
gotta love mongoose
^
Ok so how would I fix discord-giveaway/src/master.js cuz my bot decided to pack in and “Master.js is not formatted properly”
step 1 - find issue
step 2 - fix
I uninstalled and reinstalled it hoping it’d fix
But nothing I could be on an outdated npm ¯_(ツ)_/¯
might help us to know what master.js is or does?
I’ll grab it ina sec just need to reboot laptop
i cant even find that repo
i found discord-giveaways and discord-giveawaybot but not discord-giveaway
mongoose confused
It’s the giveaways one
there is no file called 'master' within the src directory of discord-givaways
there is a 'manager'
Ya that I got it confused with another file
so what is the actual error and the actual file?
Now loading into discord on my browser to post error
and stack trace if possible
at GiveawaysManager._initStorage (C:\Users\name\Desktop\Giveawaybot\giveaways-bot-master\node_modules\discord-giveaways\src\Manager.js:325:27)
(node:10156) 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: 1)
(node:10156) [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.
Logged in as Giveaway Bot#5363!
Ready to serve in 75 channels on 3 servers, for a total of 44 users.
(node:10156) UnhandledPromiseRejectionWarning: The manager is not ready yet.
(node:10156) 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: 2)```
i dunno as im new to compexed bots ¯_(ツ)_/¯
complexed*
when did you download the code for this bot?
about 3 days ago
_initStorage is not a function within the current version uploaded
and 2 days ago a fix for storage was uploaded
i'd redownload it and see how you get on 🙂
How Can I Record Data on My Bots
oh i got an older then
lol yea yours is out of date 😄
that means the file is either corrupted or wrongly formatted
if you have an existing file, delete it and let the package remake it
the default file is giveaways.json
How Can I Record Data on My Bots
thats a very vague question. what kind of data?
i mean, i could answer 'in a database', but im guessing you want more info than that?
db would probably be most flexible
I updated the files but still get the same error 😫
if (member.permissions.has('KICK_MEMBERS')) {
TypeError: Cannot read property 'has' of undefined
im using discord.js
how do i fix dat
discord.js has two different things: User and Member
so what do i do
User has things like username, profile picture, etc
Member has things like nickname, roles and permissions
message.author = User
message.member = Member
alright
testing it rq
alright it works now imma quickly make it say that u dont have permission
thanks
So, I've solved my issue
🥳
For those reading: The expected payload for the oAuth2 token endpoint IS NOT A JSON, but an url encoded string
This could be useful if someone else faces this issue (oAuth2 call returning invalid_grant)
'a url' is grammatically correct as 'url' when said has a 'y' sound as the first sound which is not a vowel sound. ~ at least, thats the logic i got taught with
'you-are-ell'
I still correct myself whenever I write a word with a vowel as the first letter
he correct a to an 😛
i also say an url
english is wack
lol, maybe im the wrong one 😄
doesnt written grammar have priority over spoken sound?
what self respecting programmer prioritizes spoken over typed? 😄
The way I was taught was "don't let A stay near other vowels, they'll fight one another"
lmao
So put a N between them to make them friends
lmao
Little things like this really help memoing things, just like bodmas
woot, english level +1
'an hour' is a great example
//Check If User Was Kicked!
const fetchedLogs = await member.guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_KICK',
});
const kickLog = fetchedLogs.entries.first();
if (!kickLog) return;
const { executor, reason, target } = kickLog;
var embed = new discord.RichEmbed()
embed.setAuthor(`Member Kicked | ${member.user.tag}`, member.user.displayAvatarURL);
embed.setColor(`#ffff00`);
embed.setDescription(`**Member ${member.user} Kicked by ${executor}**`);
embed.addField('User', `${member.user.tag} \`[${member.user.id}]\``, true);
embed.addField('Moderator', `${executor.tag} \`[${executor.id}]\``, true);
embed.addField('Reason', reason || `No reason given`);
embed.setThumbnail(member.user.displayAvatarURL);
embed.setTimestamp();
embed.setFooter(`Member ID: ${member.user.id}`);
member.guild.channels.get(`707008340126859314`).send(embed);
I am trying to get the audit logs to see if a user is kicked.
But even if the user is not kicked it goes as the user is kicked. How can I fix this?
Using discord.js (v 11.4.2)
👀
//Check If User Was Kicked!
const fetchedLogs = await member.guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_KICK',
});
const kickLog = fetchedLogs.entries.first();
if (!kickLog) return;
const { executor, reason, target } = kickLog;
if (target.id === member.id) {
var embed = new discord.RichEmbed()
embed.setAuthor(`Member Kicked | ${member.user.tag}`, member.user.displayAvatarURL);
embed.setColor(`#ffff00`);
embed.setDescription(`**Member ${member.user} Kicked by ${executor}**`);
embed.addField('User', `${member.user.tag} \`[${member.user.id}]\``, true);
embed.addField('Moderator', `${executor.tag} \`[${executor.id}]\``, true);
embed.addField('Reason', reason || `No reason given`);
embed.setThumbnail(member.user.displayAvatarURL);
embed.setTimestamp();
embed.setFooter(`Member ID: ${member.user.id}`);
member.guild.channels.get(`707008340126859314`).send(embed);
} else {
return;
}
Like this?
what a mess
you could just do
if (target.id != member.id) return;
OOh ok
tbf for this occasion either would be fine
String->Number<->
but it wont give false positives
turning the string into the number would break it
node can't handle bigints
ahhh fair
bot.on('guildBanAdd', async (guild, user) => {
const fetchedLogs = await guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_BAN_ADD',
});
const banLog = fetchedLogs.entries.first();
if (!banLog) return;
const { executor, reason, target } = banLog;
if (target.id !== user.id) return;
var embed = new discord.RichEmbed()
embed.setAuthor(`Member Banned | ${user.tag}`, user.displayAvatarURL);
embed.setColor(`#ff7e5f`);
embed.setDescription(`**Member ${user} Banned by ${executor}**`);
embed.addField('User', `${user.tag} \`[${user.id}]\``, true);
embed.addField('Moderator', `${executor.tag} \`[${executor.id}]\``, true);
embed.addField('Reason', reason || `No reason given`);
embed.setThumbnail(user.displayAvatarURL);
embed.setTimestamp();
embed.setFooter(`Member ID: ${user.id}`);
bot.channels.get(`707008340126859314`).send(embed);
});
i'd still do the !== 😄
So this will also be correct right?
ye
if both are strings, it doesnt matter which one you use
please read the docs if you're unsure
you're making yourself look silly by asking simple things jere
jere
gj
i had one job
gj*
gj?
good job
good job
^
how long would lavalink setup take
because I need to get the play feature working
10 seconds
how long would coding the play command take
just play? probably 8 minutes
do you know the pros vs the cons of using lavalink over ytdl-core
wanna know how much I'm sacraficing
They're completely different things
it's performance vs availability
want good performance? use your own audio streaming
want easy setup and code that can be written in 3 minutes? use lavalink
I'll give lavalink a shot, I'm hosting this in the clouds anyway
im so confused, whats the difference between .position and .rawPosition in djs, I just evaled a role in my server but they came out with the same number
and which one is better to use for role position?
position is the position of the role in the cache
rawPosition is what's returned by discord
would there ever be a difference in the two? like when using them for role position?
well, obviously there would
but like, I dont know which one to use lol
no idea, i don't use d.js
well they both exist for a reason
channels it responds in for sure, at least i would recommend that
yea, the rooms its allowed to play music in, and be controlled in
blacklisted/whitelisted channels?
vote skip
dj if you havent yet
maybe saving playlists? 😄
when you want maximum customization
>play mycustomplaylist
this is the current config
the dj can bypass that
yeah kinda
>play guildthememusic
what
let guilds set a specific music as theme
😄
pointless i know, but lets face it, most commands are...
wait i got an easy question that people probably find me retarded for asking, but if you mention someone like !hi @astral yoke how would you make it so it sends it back as the id like what message.author.id does
discord.js 11
ty
yw :)
Congrats on Moderation!
ty :)
❤️
My bot hasn't been booting for a day now, i have no idea why, its not giving me the ready event
It worked all before
I restarted my pc, reinstalled d.js, re-ran console, reset the db
I've tried everything 
Welp
my internet speeds and everything are okay too
No errors?
Im so confused
no errors
just not loading ready lol
or any events
in that case
no sharding or anything
Ill reinstall node
see if it works
lol
reinstalled node
no progress
smh
wow
now none of my dms are working
thats great
I was fukin right
lol
they're having connection issues
bad discord
did you try refreshing your bot token?
i had an issue before where i was rebooting my bot too fast (thanks nodemon) and discord invalidated my bot token, had to renew
What error does the console throw?
What am I doing wrong here, I'm trying to return the error that the Missing permissions is mentioning in console.
msg.channel.send(new Discord.MessageEmbed()
.setTitle('Respect Found')
.setDescription(`<@${msg.author.id}> has paid their respects. :pray: :regional_indicator_f:`)
.setColor('#003cff')
.setTimestamp()
//.setFooter(msg.author.tag)
.addField('Server Respects', `\`${fcount}\``, true)
.addField('Total Respects', `\`${total}\``, true)
//msg.reply(`has paid their Respects. :regional_indicator_f: :pray:\nTotal Respects: \`${total}\`\nRespects Paid on this guild: \`${fcount}\``)
).catch(console.error + "tadjklfaklsdjhfklajsdhfjklhfd")```
.catch() does nothing
try .catch(e => console.error(e + "ysissgsish"))
mk
Yeah, that catch is not a valid callback
ah i see
what are the conditions to make a say cmd
Errrr...make the bot say?
I don't think so
Bots get denied for anonymous PM messenger
Not for say commands
Is it possible to get the hex color of a role? If so how? Djs
hmm ok
@undone carbon transform the integer to rgb values, then convert to hex
I'm newly coding, no idea about that sorry
@undone carbon <Role>.hexColor
Yeah, there's always a pre-made function
lol
But byte shifting is fun
you're a masochist then
But it feels soooo good to directly manipulate bytes or have chained conditionals to the fifth level
member.displayHexColor gets you the color the member has in the member list
i use it in my embeds
^
Excuse me messieur, are you by chance using iexplorer?
ew
whats iexplorer
A miserable little pile of timeouts
trash
ie is removed everywhere but our memory 😄
except US government and US healthcare computers
It's actually still present in windows 10, just write iexplorer in the search bar
They keep it together with edge
lol yea, its still there, its so ingrained into windows microsoft literally cant get rid of it without breaking things
MS went ahead and upgraded edge (or is currently doing that) on Win10 machines to be chromium based
at least it's better
edge is already chromium based
but idk why they wont just remove IE tbh. or have IE actually launch edge chromium
it is now
it wasnt prior
they did it cause google slowed down youtube on browsers that werent chromium
which made edge seem slower, even though it was faster by a long while
to like, a few weeks ago tbh. it only went into stable this year I believe
quite a political affair tbh
Edge is a bit better, but I still can't believe it's not butter
bleh at work I am supposed to do my web dev with IE11 in mind, to make sure that handful of users can still use the application. but I totally dont. fuck em
nice
tbf, yea, anyone whos trying to run ie over edge, chrome, firefox, opera even, doesnt deserve compatibility
unless they're forced to
boomers gonna boom
what's something that can use a lot of disk, but almost no ram. or does disk usage = ram usage
reading/writing to a harddrive(disk)
ram usage = running application or something stored in memory. disk usage (im assuming you mean something like high % usage from windows task manager) could be something reading or writing from/to disk
I need a git master, can someone assist me with this damn repo, I need to remove a branch and it might be easier to explain in Voice.
Hey...
Is there a way I can make this allowed to myself or a certain role?
Code: ```const db = require('quick.db')
const discord = require('discord.js')
exports.run = async (client, message, args, config) => {
if (!message.member.hasPermission('MANAGE_GUILD')) { // if message.author / member does not have the permission MANAGE_GUILD, return.
return message.channels.send('You\'re missing the permission `MANAGE_GUILD` to use this command.').then(msg => {
setTimeout(() => {
msg.delete()
}, 2500); // delete after 2.5 seconds.
})
}
let user = message.mentions.members.first() || message.author
if (isNaN(args[0])) return message.channel.send(`${message.author}, you need to input a valid number to remove.`) // if args[0] (first input) is not a number, return.
db.add(`money_${user.id}`, args[0])
let bal = await db.fetch(`money_${user.id}`)
let embed = new discord.MessageEmbed()
.setAuthor(`Added Money!`, message.author.displayAvatarURL)
.addField(`Amount`, `${args[0]}$`)
.addField(`Balance Updated`, `${bal}$`)
.setColor("GREEN")
.setTimestamp()
message.channel.send(embed)
}```
Check the first arg to see if it's your user ID, or if the member has a role (<GuildMember>.roles), or your final check of if the member has MANAGE_SERVER. By the way, I think it's MANAGE_GUILD.
You also don't need to do setTimeout(() => msg.delete(), 2500), as there's an option to delete a message with a timer.
or even author.displayAvatarURL as it's a function in v12.
You'd check the if condition and have it check if the message author has the same ID as you.
if (!message.member.hasUserID('userid'))
hasUserID is not a function.
oh
im gonna use Andesite for my music funtion
How do we fetch all presences of a guild in d.js v12?
these are just cached ;-;
discord.gg/serverlink shows different
but thanks for trying to help ^_^
Would it make sense to say, "Joined At", or, "Joined On"?
Depends on if its a time like 7pm or just the date
i'd say if its both, do "joined on 2/2/2022 at 2:22PM"
i wen't the extra step and just even make a custom timestamp resolver because i'm stupid 
Hey everyone
using discord.py
@client.command()
async def start(ctx):
await ctx.send('Hi! How can I help you? choice 1 choice 2')
async def check(m):
return m.content == 'choice 1'
msg = await client.wait_for('message', check=check)
await ctx.send('dc info test')
When you do .start
it doesnt matter what your response is after it says Hi! How can I help you? choice 1 choice 2
but I want it to respond with: 'please specify a valid option' if you dont put in an actual choice
help pls
Hope, I have it as a field title like this:
Joined At
January 6th, 2020
It really doesn't mean anything but I'm interested if it's "At" or "On". I already have the "Joined Discord" in the footer timestamp and "Joined Server" would be weird imo (Dekita).
Kiss your self man
https://hastebin.com/dehoyudara.js this return
please help
how do i turn this string to an epoch miliseconds since 1 jan 1970?
Tue May 05 2020 01:24:44 GMT-0500
@earnest phoenix have you tried https://www.epochconverter.com/?
epochtimestamp * 1000
So I am trying to make a function that gets exported into other commands so I dont have to rewrite the same code over and over, and it involves dbl.hasVoted() which isnt the problem at all, that works fine. I'm just having a problem getting the function to actually return the right values. If the user has voted, return true, if they havent, return false. If I console log INSIDE of the function, the correct values are being recorded, but if I console log the function itself in a command, it returns undefined.
Here is the code for the vote function thing
voted: function(dbl, message) {
dbl.hasVoted(message.author.id).then(v => {
if (v) return true;
if (!v) return false;
})
}
again, I am having a problem with the function returning the correct values, not the dbl api
and this is how I am calling the function.
const voted = require('../../functions').voted;
console.log(voted(client.dbl, message))
hey so im getting
-----economy-----
Error: coins.js => TypeError: cmd is not a constructor
And this is my code, ive looked on stack and found nothing can anyone help?
const {Command} = require("../../lib");
const {MessageAttachment} = require("discord.js");
const fetch = require("node-fetch");
const randomPuppy = require("random-puppy");
const Money = require("./models/money.js")
module.exports = class Money extends Command {
constructor() {
super("coins", {
description: "coins system",
usage: "!coins",
aliases: ["coins"],
cooldown: 5000
});
}
async run(message, args) {
let coinstoadd = Math.ceil(Math.random() * 50);
console.log(coinstoadd + "coins");
Money.findOne({userID: message.author.id, serverID: message.guild.id}, (err, money) => {
if(err) console.log(err);
if(!money){
const newMoney = new Money({
userID: message.author.id,
serverID: message.guild.id,
money: coinstoadd,
})
newMoney.save().catch(err => console.log(err));
}else{
money.money = money.money + coinstoadd;
money.save().catch(err => console.log(err));
}
})
}
};
You aren't returning anything in the function, you can do return dbl... @icy crane
uh well, I figured out my problem, the way i solved it didnt make a lot of sense, but thanks for reading
There is a better way of doing this but ok
Google, any advice mate?
wait
fuck my life ik
it should be in events folder not cmd folder
oof
disregard that
How have you setup your webhook to use on_dbl_vote? I tried portforwarding, but now the port doesn't open. Is there a way to do it online?
if (message.content.startsWith(prefix + "nick")) {
if(!args[0]) return message.reply("Please include a nick name")
client.user
.setNickname(args)[0]
.then(user => message.reply(`My new nickname is ${user.nickname}!`))
.catch(console.error);
}```
why doesn't my nick name command work
You are passing an array of args instead of the first argument to .setNickname
oh
And also you are trying to access a property with the name 0 on a promise
it doesnt work
well do you get any errors?
client.user.setNickname is not a function
client.useris a User object, and users are not related to guilds
To change your bot's nickname you can do message.guild.me.setNickname(...
guild.me returns the bot as a GuildMember of the guild
is there a way i could make it change my nickname not the bots?
specifically yours, or the person who is doing the command?
the person doing the command
message.member returns the GuildMember who does the command (It will be undefined if the command is done in DMs, so make sure to check for that)
oh
a new statement was found but no delimiter was found between it and the previous one How to solve this MySQL error? It's really annoying. We are just using
UPDATE settings SET desc = '${desc}' WHERE guildid = ${msg.guild.id}```
nvm, never call a column desc 😂
how could i create a command with canvas like a triggered command
so it takes their profile picture and puts it on a image of the triggered gif
why everyone uses 1 cmd per file, even on js i have made succesfull command handler what supports even 50 cmds per one file
Because it's easier to manage when it's done correctly
yeah
Like for me, I have command folder -> category folders -> commands in relative categories
And it's all automated etc
for me i have index.js
why everyone uses 1 cmd per file, even on js i have made succesfull command handler what supports even 50 cmds per one file
I don't
I have a cogs directory with each cog in a separate file loaded as dpy extention
Cogs are based on category so it makes it easier to categorize the help command
How many commands?
i have about 45
im using glitch for it because im a disappointment and the way glitch works idk how to switch to a command handler
Syntax error, show us the file
line 1 char 1
const { app, BrowserWindow } = require('electron')
thats the first line
well afaik that only shows up when you run it with double clicking on it
thats just the example from their docs though
well their start script is probably electron file.js, while yours may be the default node index.js
People's of top.gg are checking my bot now already 2 days
Do u guys love scripting
It's a little bit hard but it's cool!
wait 1 weeks, and yeah coding is nice 
@earnest phoenix
@wide ruin you're trying to use electron?
thats not how it works
you code the js file, then you make it your main file in your package.json, then you double-click the electron.exe to run it
you have to download the electron prebuilt demo package for your system
or you can run it with npm start, after you configured your package.json to use electron instead of node
so im trying to apply this in flask but just some pointers for a general implementation would be nice too
how could i return 2 pieces of data, png and text with 1 http response from a (flask) webserver? just return the png data as regular and text in header?
How to fix in python
Why my bot doesn’t write in testing and it isn’t off because on my server it work
what prefix?
!
ok i need help, my bot when i mute someone adds / removes the role fine. however they can still talk and shit
thats why
! is common prefix
And
mulzy that means the role has perms
K
https://hastebin.com/ugokaqemoh.js @honest perch
hiii I’m new hereee how do I make a bot .w. 
How can I remove the gap between div tags in html?
@modest maple i have no idea, how should i? 
I tried margin but nothing
Could be padding
@mossy vine i mean you could a byte array, or just serve the static file as url with the text both in the data
ok wait so i have a python package that will generate me an svg, but i need to send that as png
and along with that png i also need to send some text data
btye array ig then
oop can anyone answer my question-
@pure totem #502193464054644737
Padding still nothing
Inspect element and find out what's causing the spacing
Ohk
But my HTML editor doesn't allow me to inspect the built in browser in my HTML Editor
someone pls help me
Then stop using the built-in browser and use a proper one
my computer broke
yeah
What do I use then :(
a pc

or atleast something better than a phone
xD
or laptop
you would even be able to code on a raspberry pi
I only have a phone and currently broke asf
i have no other choice but to code in phone
Maybe you meant return
Let me try
"Incorrect string value: '\xF0\x9F\x91\xAF\xE2\x80...' for column s3389_database.settings.description at row 6", sqlState: '22007',
im getting this
i know its to do with the Collation
ive set it to utf8mb4_unicode_ci
is that not correct?
how do i add my bot to DBL?
np
I’m trying to await any message and then use that message content later. I have looked at some docs but can’t seem to get it to work
Does anyone know how I can do this?
how did you try to do it
message.channel.awaitMessages(filter, {max: 1, time: 5000}).then(collected => {
console.log(message.content)
}).catch(err =>{
console.log("err")
})```
After 5 seconds it logs the message
And there is never an error
you aren't logging the collected message
Ik
I haven’t worked on that bit yet
It’s just actually getting it to log anything when it receives a message
Instead it just waits until the time is up and then logs
something should get logged when you send another message after the command one
well show your filter function
Wdum
What's filter
yeah.. that's probably not right
filter must be a function that either returns true or false
I have no clue what require('filter') is but it's definitely a module for doing something completely different
Yup
If you don't want a filter, put () => true as the first parameter for the awaitMessages function
(maybe putting null/undefined also works, not sure)
I tried just removing mention of filter and now I got a different error
and that error is...
^
TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function```
yes
many bots are getting denied due to say cmd
i just checked the docs
