refer to the docs: https://discord.js.org/#/docs/main/stable/class/Permissions?scrollTo=has
#development
1 messages · Page 746 of 1
:3
if (spoonfeed) return
dont spoonfeed
.includes doesnt exist on permissions anyways
hasPermission
deprecated
on 11.5.1 it's not deprecated
you have to check if the user is inside the blacklist
well
this way you're comparing two entirely different objects
wat
you mean... negation?
ye...
message.author.id ! black.list?
i already told you
learn js...
you can't compare that
they're not the same object
you have to check if the user's id is inside of the blacklist
as it's an array
so: js if(message.author.id === black.list[message.author.id]) { return; }
eek
it's javascript
i thought this was to help if something went wrong but its just a server
yee its not with bots its with putting my server up but it wont let me
if that made sense

if you wanna help add a issue onto the github and I'll add it
since I dont understand how the other stuff workk
for blacklist use this? ```js
const arrayOfUsersIds = ['id, id, id'];
for (let i = 0; i < arrayOfUsersIds.length; i++) {
if (message.author.id === arrayOfUsersIds[i]) return message.reply('You are on the blacklist!');
};```
you should stop help vampiring and do what you're told to do
nvm then
2
yeah const ids = ['id', 'id']
this would also be easier if you learnt basic js before jumping into creating a discord bot
^
learn js while your at it

stfu
we're being honest
learn js or your coding life will be hell
@surreal sage You should learn the language before you start on a discord bot. Little smol tip, but it seems to help

^
i know some basic js ok
i mean i myself learned js by making a discord bot
That's fine
bUT
but things such as what you are trying you should try out in a basic file first
Before it goes into your bot
y ik
the amount of times we've told you this is ridiculous. the next time you ask a question here without knowing basic js and wanting the answer to your code i will ask the mods to mute you
keep being nice
it's hard when the end user doesn't listen
at least it's not a whitename that doesnt understand english
that's a plus, alright? Heh
yeah lol
Ok so, Quick question, I use guild.owner to get the owner, but I don’t want to tag it
Whenever I try to use guild.owner.username or guild.owner.tag it returns nothing
Just a TypeError, cannot read propriety of null
Do I have to put it in a variable?
Ok, thanks
So, does anyone else here use a separate private server that just has you and your bot on it to store public emojis your bot uses?
If you don't do that where do you put your bots emojis?
If I used emotes in my bot I'd use a private server probably
Or do you not have any for your bot e.g. logos, throbbers...
So this would be a good legitimate approach?
if you have a lot of emojis ye
or if u just want to have it in another server
totally your choice
It's not that I would have a lot it's just I can't spare slots on my official server
yeah
Although my official server does have all animated slots free
well i think of it as kinda like i want the emojis for my bot to be used mainly by my bot, and i want my discord server emojis to be used mainly by my discord server
if that makes any sense
they can under 10 guilds
Hmm, it's way too late for that now then lol
Can I transfer ownership of a guild to a bot?
Probably not
Basically I don't want that emoji server cluttering up my list. The only other approch is to make a separate discord account for it
But the bot can
Hmm, sporks dev is only in 3 guilds, it could create the emoji guild
But then how can the live bot be invited to it
Inviting has to pass captcha
join the server it created and invite it yourself and then leave perhaps
I think I'm best just creating a second discord for the emoji server and inviting the bot to it
Yeah if I had administrator I could do that
Or I can just make the server myself and transfer ownership to the bot
Are you sure you can transfer ownership to a bot? I know the bot can, but not sure about normal user accounts (or without using a selfbot).
You cant transfer an application, you can put it on a team then give someone ownership of the team tho
~~anybody have a solution to this? https://canary.discordapp.com/channels/264445053596991498/272764566411149314/655155714406219776~~ nvm issue fixed
If I put my bot's website, but it's still work in progress and only have a navbar, will I still be able to put it, or will my bot get deleted or the website will be denied??
What's the most performance efficient way to do this in Mongoose? ```js
await Settings.findByIdAndDelete(guild.id).catch(console.error)
await bot.redis.del(settings-${guild.id})
await Leveling.deleteMany({ guildID: guild.id }).catch(console.error)
await CaseModel.deleteMany({ guildID: guild.id }).catch(console.error)
const customCommands = await CustomCommands.find({ guildID: guild.id })
if (customCommands) {
for (const customCommand of customCommands) {
await bot.redis.del(`customCommands-${guild.id}-${customCommand.name}`)
}
await CustomCommands.deleteMany({ guildID: guild.id })
}```
I think they mean what are you doing exactly
I'm blind; Sorry lol
I have this error very often, and it makes the bot stop
TypeError: Cannot read property 'addRole' of null
Code
role = message.guild.roles.find(r => r.name === "•-Vicioso-•");
message.member.addRole(role);
const user = await Leveling.findOne({
guildID: message.channel.guild.id,
userID: message.author.id
}).lean()
const [rank, top10] = await Promise.all([
Leveling.find({
guildID: message.channel.guild.id,
xp: { $gt: user.xp }
}).countDocuments(),
Leveling.find({
guildID: message.channel.guild.id
}).sort('-level -xp').limit(10)
])```
```js
const levels = await Leveling.find({
guildID: message.channel.guild.id
}).sort('-level -xp').lean()
const rank= levels.findIndex(data => data.userID === message.member.id)
levels.slice(0, 10)
``` What one is the best to find a users rank and the top 10 people in the server? (Mongoose)
Which ever system orders the data on total xp and just selects the top 10
You want in reality to go with the system that takes the least time / reasorces
@round garden I recommend using a for loop
by recursiving the Model by an array, making another array for the top 10 people, then add data from the model array to the array you want
until you reached 10
you could get all of them then just filterone sec
didn't mean filter
Sort is hella weird
@vital lark why in god's name would you use a for loop going through the entire DB just to get top 10!?
looping the entire DB
I'm saying looping the model
models and dbs are different in mongoose
also there is Math#min so... 
@empty owl wym
I don't rlly know how mongoose works so fairs
It works as intended
anybody that uses serenity: is it possible to show subcommands in additional help messages? i have a set subcommand.. ```rs
#[command]
#[sub_commands(set)]
fn prefix(ctx: &mut Context, msg: &Message) -> CommandResult {
let guild_id = msg.guild_id.unwrap().0 as i64;
let pf = crate::db::get_guild(guild_id).prefix;
msg.channel_id.send_message(&ctx.http, |m| {
m.content(format!("The current prefix is {}\nTo set a prefix run prefix set <prefix>", pf))
})?;
Ok(())
}
#[command]
fn set(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
let guild_id = msg.guild_id.unwrap().0 as i64;
let new_prefix = match args.current() {
Some(p) => p.to_string(),
None => {
msg.reply(&ctx, "Please input a prefix to set")?;
return Err(CommandError::from("no prefix given"))
}
};
crate::db::update_prefix(guild_id, new_prefix.to_string());
Ok(())
}``` and im not really sure how to show it in the help command
it currently only shows: prefix Group: settings Available: In DM and guilds
(this is the default help command, i havent bothered making a custom one)
@sudden geyser I mean all I'd think you'd need is { "hub.callback": "http://xxx.xx.xxx.xxx:xxxx/x", "hub.topic": "https://www.youtube.com/xml/feeds/videos.xml?channel_id=x", "hub.verify": "async", "hub.mode": "subscribe", "hub.verify_token": token, "hub.secret": secret, "hub.lease_seconds": 864000 }
the callback works because it sends the request that tells me the mode is invalid
just dont know what the problem with the mode is
hmm I don't see an issue
a SO post im looking at right now has subscribe as the mode also
that's really weird hmm
does it not want it as application/json?
Yeah
im not sure actually
https://oliy.is-just-a.dev/t71jav_2372.png this is the thing that I had to rip through for stuff
it's not well documented
so every other key-value prop works except for hub.mode?
what im looking at is application/x-www-form-urlencoded? https://stackoverflow.com/questions/29611459/youtube-api-subscribing-to-push-notifications
Stack Overflow
My final goal is to set up a Webhook whenever a YouTube user uploads a video. After some research I got to this article.
But when I get to the part https://www.youtube.com/xml/feeds/videos.xml?
for guildMemberAdd
Can I do
if (member.id === -&:$!;&3) return member.kick() for auto kick
r/ihadastroke
it's probably a place holder
You can do that, but you could also make an array of user IDs. It's your choice as long as it gets the job done efficiently.
membersToKick.includes(member.user.id)
https://oliy.is-just-a.dev/nfu4ps_2373.png well now instead of just saying it once, it's spamming
lmao
It's in js
I think I know why it's spamming tho
Hooray no more spam, still invalid mode though
Lol
I'm terrible at asking questions, but I don't know what other info I could give
Well I'll figure it out sooner or later
it looks like application/x-www-form-urlencoded is the correct content type tho
I would just use their form thing, but it unsubscribes after a set amount of time so I just wanted to do it programmatically
time to see what the creators have
Well I'm just broken then
I have a small function in a module, which gets a random number, but the problem is that every time the flame gives me the same number,
What I can do?
//index.js
const vars = require(`./vars/vars.js`);
let workwin = vars.workwin
//vars.js
exports.workwin = Math.round(Math.random() * (150 - 50) + 50)
You're exporting a variable that is already declared
Try exporting a function that returns the random number and use that instead
Do I change the variable in vars.js for a function? @dusky marsh
export a function that returns Math.round(Math.random() * (150 - 50) + 50)
something like that?
exports.workwin = function(){
return Math.round(Math.random() * (150 - 50) + 50)
}
@west raptor
I would use an arrow function instead
=> ?
exports.workwin = (...) => {
// ...
}```
exports.workwin = () => {
return Math.round(Math.random() * (150 - 50) + 50)
}
Error: Client network socket disconnected before secure TLS connection was established
``` how to fix this?
So I have function where I execute a SQL query with https://npmjs.com/mysql but I can't return a value from a row
because it's returning the .query function, not my function
Does anyone know how I can do it?
whut
str is undefined
how can fix it?
Console.log commandNames
the code;
`const Discord = require('discord.js');
const ayarlar = require('../ayarlar.json');
var prefix = ayarlar.prefix;
exports.run = (client, message, params) => {
if (!params[0]) {
const commandNames = Array.from(client.commands.keys());
const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);
message.author.sendCode('asciidoc', = Komut Listesi =\n\n[Komut hakkında bilgi için ${ayarlar.prefix}yardım <komut adı>]\n\n${client.commands.map(c => ${ayarlar.prefix}${c.help.name}${' '.repeat(longest - c.help.name.length)} :: ${c.help.description}).join('\n')});
if (message.channel.type !== 'dm') {
const ozelmesajkontrol = new Discord.RichEmbed()
.setColor(0x00AE86)
.setTimestamp()
.setAuthor(message.author.username, message.author.avatarURL)
.setDescription('Özel mesajlarını kontrol et. 📮');
message.channel.sendEmbed(ozelmesajkontrol) }
} else {
let command = params[0];
if (client.commands.has(command)) {
command = client.commands.get(command);
message.author.sendCode('asciidoc', = ${command.help.name} = \n${command.help.description}\nDoğru kullanım: + prefix + ${command.help.usage});
}
}
};
exports.conf = {
enabled: true,
guildOnly: false,
aliases: ['h', 'halp', 'help', 'y'],
permLevel: 0
};
exports.help = {
name: 'yardım',
description: 'Tüm komutları gösterir.',
usage: 'yardım [komut]'
};`
hello
i'm getting issue on split
let args = message.content.substring(10).split(`<@${mn.id}>`);
this is not split mensions
@quartz kindle I threw the code. can you take a look?
Mention can be !@id if member has a nickname
@royal herald commandNames has a non-string value, console.log it so you can see what is it
the error at ;const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0); @quartz kindle
dm look like
077738170725xxxx> test 1
this
@compact raft btw u dont need to censor ids cuz everyone can see them
i want ot hide mension
and
need showing only message
@restive furnace const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0); help pls
@compact raft its same as id... but justw ith <@(!)id>
What is (!)
nickname
Does someone know how I can return a function from another https://npmjs.com/mysql query function?
i'm having problems with a fetch from a website
it returns this
i'm using node fetch
it's saying that the url your making a request doesn't exist anymo4e
but when i try to manually access the webiste it works
for manually i mean by myself, from my pc
help?
read the error
i didn't say it you said it
This is the 4th time you've been told this altho for different errors
Actually more than that but we'll ignore it
console.log('Ta race')
});
client.on('message', message => {
if (message.content === prefix + 'count') {
guild.createChannel(`${message.guild.member.count}`,{type: 'text'})
.then(console.log)
.catch(console.error);
}
})```
guild is not defined
Yeah gif doesen't work in embed I believe
if you dont know what you're talking about, don't help
Guild.createChannel
iirc animated emojis are in a <a:name:id> format @earnest phoenix
Message.guild.createChannel
@lunar crystal
i how to change status in my discord.js bot? help please guys
what is this error
@toxic jolt did your bot get kicked
It's config.json,not confige.json
nope
can you send your config file @lofty lagoon
without token if you have the token in it
(the content of ur config file)
{
"token": "token",
"prefix": "G/"
}
dont directly show him how
oh ok
yes so thats what u need to do
its the only way you can help a copypaste dev
but where is the spoon
WZIT
5% OF BATTERY
@lofty lagoon it means he gives you all so solutions
DAFUK
I know what is a spoon feeder
oh
I need help too
I want to make a "Clyde" command. You send text, clyde "say" it. How to do dat
Image
so you can use canvas
thats why i asked if they wanted to make it with an image or something
to make it look like that

guys, this is the right token but why is it erroring out?
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\http.py", line 258, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\http.py", line 222, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 UNAUTHORIZED (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\||ur not getting my name||\Desktop\programming\Qubic Discord Bot\run to run bot.py", line 11, in <module>
client.run('||no ur not getting my token||')
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\client.py", line 598, in run
return future.result()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\client.py", line 579, in runner
await self.start(*args, **kwargs)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\client.py", line 542, in start
await self.login(*args, bot=bot)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\client.py", line 400, in login
await self.http.static_login(token, bot=bot)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\http.py", line 262, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.```
@wispy vine can I see ur bot code? (hide the token plz)
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as {0}!'.format(self.user))
async def on_message(self, message):
print('Message from {0.author}: {0.content}'.format(message))
client = MyClient()
client.run('||not getting my token||')```
if you get a 401 you don't have the right token
if you say you do have the right one, you still don't
Bot token ≠ client token
wheres the client token?
this?
Np
Woow
lol MEE6 just greeted Qubic xD
thanks @earnest phoenix for giving solution everytime.
i know, it's just weird that Qubic is a bot
mee6 is dumb
not rly
Mee6 is dumb yes
this is #development not #memes-and-media but mee6 is not really dumb (except the level up message "gG u LeVeLd UPPP")
how to let a bot join a voice channel? js voiceChannel.join() i know this but what more?
well, did it join the voice channel?
no
im thinking about this: js message.author.voiceChannel.join()
but that does not work
The user instance does not have a property named voiceChannel
how can i fix? do i have to make it with const/let? as value the id?
The channel needs to be a voice channel; it's in the docs
what do you have defined as voiceChannel
^
im there lol
If you're trying to voice the user's voice channel, you'll need to find the property to get the user's voice channel, which is also in the docs: https://discord.js.org/#/docs/main/stable/class/GuildMember
this? message.author.voiceConnections?
user =/= member
In order to get a guild member instance/object, you can get the property from the Message object.
so: js const guildMember = message.author const voiceChannel =guildMember.voiceConnections() voiceChannel.join()?
"not a function"
on GuildMember
A user instance is the Discord user. A guild member instance is the Discord user and data from that guild.
message.member.voicechannel?
voiceChannel should be capital
ik
my eval cmd has max text so i got to make a simple eval commands that just executes
ok
are you in a voice channel
y but i uploaded the wrong file :)
SyntaxError: Unexpected identifier
nvm
typo
does not work...
the code
then nvm
@compact raft np
I'm trying to do this ```js
client.user.setStatus('idle')
.then(console.log)
.catch(console.error);
(no error message in log)
(js)
I'm basically forced to use js client.user.setPresence({ game: { name: 'MY DEV IS WORKING ON ME' }, status: 'dnd' }) .then(console.log) .catch(console.error);
might be due to this:
This can however happen if you change your status too quickly (Maybe due to you testing around with statuses or setting an update on too short of an interval).
In that case the API starts to rate limit your bots and subsequently the library does not send the request until the specified limit is over.
Edit: You can try and log the rateLimit event for debugging purposes to find out if this is actually the cause.
https://github.com/discordjs/discord.js/issues/3352#issuecomment-504220719
how would i delete a message (in discord.py)? i have it stored in a variable called message. would i do like message.delete() or something? (no linking http://tryitands.ee/)
try it out and see (I'm sorry)
tbh check the docs lol, always read up things before blindly asking
OK WHY?
its a good way to fuck so many things up
how so
because you'll overwrite the message object
what
but that's only in that scope, correct?
no, its in onMessage():
not if you dont define the message object as message
if "discord.py" in chillfish8.content:
chillfish8.channel.send("why hello there")```
print('Message from {0.author}: {0.content}'.format(message))
if message.author == client.user: #if it is the bot who wrote it, then don't reply, or it will turn the shard into a crappy piece of glass, then smash it with a shotgun (yes im weirD)
return
if message.content == '~command_here':
response = "response here"
await message.channel.send(response)
#i can haz delete message plzzz```
wut
@wispy vine wholy moly slow down there boy
# read the docs, they're useful and tells you how to delete
k
what the fuck is with the 0.author xD
and the 0.content
xD
why that version of formatting
not to mention
tryitandsee
i hav bad habit
im making a serverinfo conmand but you can also provide a id and then it tells you info about the guild. is that even allowed?
ik shitty gramma
uh no
If you mean provide the ID of a different guild, no unless that guild opts in OR it's locked to devs only for getting other guilds
ik but i asked if thats allowed
Ok
let guild = this.client.guilds.get(args[0]) || message.guild
when i provide an id it falls back to message.guild!?
Yes.
You can also ask an online mod for a reliable answer
Ok uh anyone can help me?
with what
uh ok
help
cannot read property 'id' of undefined
yes
yes
how :))
it's defined. The property before .id is undefined
ok
C:\Users\Vrasilla\Desktop\Projects Discord\ResorceBot Pro\commands\moderation\unban.js:11:37
Just as a quick note for you
i would consider going back to basics
after this is the 18th time you have asked us to explain an error to you
and how fix
this is #development and not #debugging-and-bug-fixing XD
it fallsback to message.guild if i provide an id.
https://hastebin.com/jijaqubake.js
I did not understand
when copy and pasters cant solve errors...
basically
await can only be put in front of async fuctions. (mostly discord fuctions)
ur using await but you arent in an async function
just remove await from the line
i removed await
@earnest phoenix whatcha on about?
dont remove await If its required
well duh
right dude
u gotta learn
u gotta give the full error
not just the last set of lines
that "unhandled error" is cuz your not handling your errors right so its crashing
but its not the actual error
It's the same, I showed you that I rested await
I put an imgur link in an embed but the image doesn't appear, why ?
have you tried reading the error
if ( (message.mentions.members != undefined ) && (message.author.id != client.user.id)) {
var k = message.mentions.users.array();
console.log("mentioned : " + k.length)
}
i tried to check if the bot is mentioned or not ,but when i mention the bot ,i don't get it in the array
like if i mention 2 people + the bot itself in console it show array length is 2
ITS THE SAME ERROR AS LAST TIME OMFG DUDE
sorry for the salt but dude
not u sehrik btw
Oh no that guy is back with the same error
@mossy vine
:)) why do you think me so stupid?
BECAUSE 6 of your 21 requests to have a basic error explained to you is the same freaking error
youre just ignoring what people tell you
if (
(message.mentions.members ) && (message.author.id != client.user.id)) {
var k = message.mentions.members.array();
console.log("mentioned : " + k.length)
// cmd.reply("Hello")
if (is_mentioned(k)) {
// cmd.reply("u mentioned me")
// cmd.channel.send("mentioned by " + cmd.author)
message.reply(cm_message(1));
}
}
@west raptor same result
the wired things is ,the bot is currently on 2 server
its working on one server but not working on another server 😐
Hey @charred loom, this is just a polite warning. We are here to help you with certain problems, but the one you keep having trouble with can be solved with simple knowledge of the actuall programming language you are in. Please take the time to read the following message: https://discordapp.com/channels/264445053596991498/272764566411149314/504585329869586432
as well as this website: http://slash7.com/2006/12/22/vampires/
If you continue to ask questions that could easily be solved by learning the language, then you will be punished.
Just another WordPress weblog
-ask2ask @earnest phoenix
@earnest phoenix
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
@earnest phoenix done bb 
it fallsback to message.guild if i provide an id.
https://hastebin.com/jijaqubake.js
what should i put here?
Your Description of your Bot of cause @lapis merlin
Detailed description as it says
commands, how to use it, documentation, etc
frick spider
Anyone can help me now please
lol nerd @west raptor
wow ok
wait no
fuck
Anyone can help me now please
what was your issue? the bot not appearing in user mentions?
it fallsback to message.guild if i provide an id.
https://hastebin.com/jijaqubake.js
what is "it" and where
you keep posting the same thing
How to properly ask technical questions, and demonstrate that you've done your research and are willing to learn on your own.
how to get last word of a message in discord.js
split the content by space and take the last item out of the array
@earnest phoenix let guild = ...
isnt .endswith() a thing
ah yeah
i missed that one
lol
but
that just checks if it ends with
it doesn't get the last string
@knotty steeple man my bot why kicked?
@earnest phoenix content.split(' ').pop()
i how to add in server
not too complex
ask a mod to add it back
oh
ok thx
since ur a bot dev and thats ur only bot i assume it got kicked
@toxic jolt englis
also be sure to know why it got kicked, you can check that in #mod-logs and make sure you fixed it
its not gonna come back unless u disable that for this server
if not history will repeat itself
https://prnt.sc/qarsua i need to remove the userid from the message now
i'm making a dm command(owner-only)
const args = message.content.split(" ").slice(2);
const dm = args.join(" ");
const userid = message.content.split(' ').pop()
const user = client.users.get(`${userid}`);
if(!user) return;
if(message.author.id !== ownerID) return;
user.send(dm)
message.reply('Sent!')```
this is discord.js
whats le bug
just want to remove the userid at the end of dm
why not just accept the id first and then not care about the rest
and then pop it
yeah thats an easier alternative
but similar logic applies
just a matter of shifting or popping
this way it's more intensive on the cpu
accepting the id first is basically just "hey get me the first item out of the array k bye"
micro optimization ™️
how can i check if channels are locked for @everyone?
i use v12-dev
get the channel overwrites (<Channel>.permissionOverwrites) for the everyone role and use the has method to see if the everyone role has SEND_MESSAGES
hi
i know you can put routes in other files instead of the main file
for expressjs
but how do you do that because i forgot
client.fetchUser(message.guild.ownerID,false).then(user => {
message.channel.send(user.tag)
})``` how to convert this so it works in my script without using eval?
wat




no
that does not work that script when using in normal script
scripts
how to fix
so your copying something and want to know how to make it work



ok nice
const user = message.guild.fetchMember(message.guild.ownerID)``` this?
ok
does not reply
(fetch)
ah
Error: Invalid or uncached id provided.
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=fetchMember how to use that cache?
fetchMember is broken
use client.fetchUser and pass the result of that to fetchMember
client.fetchUser(message.guild.ownerID,false).then(user => {
message.channel.send(user.tag)
})``` i got this...
this works in eval but not in my script
how do i fix?
you provided no context
so i don't know
const Discord = require("discord.js");
const bot = new Discord.Client();
const config = require("../assets/config.json");
exports.run = async (client, message, args) => {
if(message.author.id != config.owner) return;
function findEmoji(id) {
var emoji = this.emojis.get(id);
const temp = this.emojis.get(id);
if (!emoji) return null;
if (!temp) return null;
var emoji = Object.assign({}, temp);
if (emoji.guild) emoji.guild = emoji.guild.id;
emoji.require_colons = emoji.requiresColons;
return emoji;
}
let getemojis = [
client.shard.broadcastEval(`(${findEmoji}).call(this, '469480312389369857')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '469482201126273044')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '469482498431123466')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '492061158971408414')`)
];
return Promise.all(getemojis).then(emojiArray => {
const foundEmoji = emojiArray.find(emoji => emoji);
if (!foundEmoji) return message.reply('Je n\'ai trouvé aucun émoji.');
return client.rest.makeRequest('get', Discord.Constants.Endpoints.Guild(foundEmoji.guild).toString(), true)
.then(raw => {
const guild = new Discord.Guild(client, raw);
const emoji = new Discord.Emoji(guild, foundEmoji);
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0].toString()}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});
}
Oh can i find the emojis and use in embed?
How*
:/
I'm pretty sure you're stringifying a function in that broadcastEval call
Émoji
e1: [object Object],
e2: [object Object],
e3: [object Object],
e4: [object Object],
The result
:/
oh nvm it's valid
const user = await Leveling.findOne({
guildID: message.channel.guild.id,
userID: message.author.id
}).lean()
const rank = await Leveling.find({
guildID: message.channel.guild.id,
xp: { $gt: user.level }
}).countDocuments()``` Is there an easier way to calculate a users rank? (Mongoose)
And the fonction is the findEmoji in https://github.com/discordjs/guide/blob/master/guide/sharding/extended.md#resulting-code
wot const foundEmoji = emojiArray.find(emoji => emoji);
and pretty sure you dont need to request each emoji using http
I don't know, I've almost never used sharding and I can't get the 4 emotions that way.
are you just trying to print the emojis or what
Yes in the embed
But
Émoji
e1: [object Object],
e2: [object Object],
e3: [object Object],
e4: [object Object],
:/
When I use the function to retrieve only one emoji it works, but not otherwise
:/
woat
I just use the emoji id
Oh okay
lemme try it first
I am in the lateral safety position
thank
Okay
basically just map the foundEmojis array
Mmmh okay
emojiArray = emojiArray.map(emoji => `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}>`);
// then use emojiArray as usual
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});```
kinda confusing
idk what the docs was trying to do
try that @earnest phoenix
For an embed
?? i dont see the purpose of that but well
For users status
(node:10118) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
const Discord = require("discord.js");
const bot = new Discord.Client();
const config = require("../assets/config.json");
exports.run = async (client, message, args) => {
if(message.author.id != config.owner) return;
function findEmoji(id) {
var emoji = this.emojis.get(id);
const temp = this.emojis.get(id);
if (!emoji) return null;
if (!temp) return null;
var emoji = Object.assign({}, temp);
if (emoji.guild) emoji.guild = emoji.guild.id;
emoji.require_colons = emoji.requiresColons;
return emoji;
}
let getemojis = [
client.shard.broadcastEval(`(${findEmoji}).call(this, '469480312389369857')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '469482201126273044')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '469482498431123466')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '492061158971408414')`)
];
return Promise.all(getemojis).then(emojiArray => {
const foundEmoji = emojiArray.find(emoji => emoji);
if (!foundEmoji) return message.reply('Je n\'ai trouvé aucun émoji.');
return client.rest.makeRequest('get', Discord.Constants.Endpoints.Guild(foundEmoji.guild).toString(), true)
.then(raw => {
const guild = new Discord.Guild(client, raw);
const emoji = new Discord.Emoji(guild, foundEmoji);
emojiArray = emojiArray.map(emoji => `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}>`);
// then use emojiArray as usual
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});
}
wait what how
I still don't understand how to use these 4 emojis in an embed.
oh
gotta check for null gdi
emojiArray = emojiArray.filter(e => e).map(emoji => `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}>`);```
change to this
Ye nvm
(node:10208) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
Again
return client.rest.makeRequest('get', Discord.Constants.Endpoints.Guild(foundEmoji.guild).toString(), true)
keep in mind that your bot won't be able to display or use the custom emoji if it's not in the guild where the custom emoji is in
dont think you need it
no I think it prints as long as your bot is in that guild no matter which shard @earnest phoenix
afaik
return client.rest.makeRequest('get', Discord.Constants.Endpoints.Guild(foundEmoji.guild).toString(), true).then(raw => {
yes that's what i was saying
the thing i was pointing at was the possibility that the user is a nitro user which used an emoji from a guild the bot is not in
The bot is in the guild
....
:/
so its fine actually
ah i see
ahh that rest chunk isnt needed tbh
return Promise.all(getemojis).then(emojiArray => {
emojiArray = emojiArray.filter(e => e).map(emoji => `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}>`);
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});
Okay
if there is any errors
add console.log(emojiArray.slice(0, 4)) before const embemo = ...
Okay
and tell me the output
hmm?
oof
something went wrong there
return Promise.all(getemojis).then(emojiArray => {
emojiArray = emojiArray.filter(e => e).map(emoji => JSON.stringify(emoji));
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});```
try that
weird
[ '<:undefined:undefined>',
'<:undefined:undefined>',
'<:undefined:undefined>',
'<:undefined:undefined>' ]
why isnt id defined
Émoji
e1: [{"guild":"427409812112932864","deleted":false,"id":"469480312389369857","name":"enligne","requiresColons":true,"managed":false,"animated":false,"_roles":[],"require_colons":true},null]
e2: [{"guild":"427409812112932864","deleted":false,"id":"469482201126273044","name":"occuper","requiresColons":true,"managed":false,"animated":false,"_roles":[],"require_colons":true},null]
e3: [{"guild":"427409812112932864","deleted":false,"id":"469482498431123466","name":"pasderanger","requiresColons":true,"managed":false,"animated":false,"_roles":[],"require_colons":true},null]
e4: [{"guild":"427409812112932864","deleted":false,"id":"492061158971408414","name":"streaming","requiresColons":true,"managed":false,"animated":false,"_roles":[],"require_colons":true},null]
:/
it's because of that filter
i'm pretty sure atleast
no it's not
what's your code right now?
Wait
when you're mapping the emojiArray
emoji is actually an array
so to get the readable format
emoji[0].propertyWhichYouNeed
Mmmh
Oh just emoji[0]. etc...?
yup
if you see your output above emoji is actually an array
then why tf
[emoji object, some other object that always seems to be null]
(node:11164) UnhandledPromiseRejectionWarning: ReferenceError: emoji is not defined
what's your code
return Promise.all(getemojis).then(emojiArray => {
emojiArray = emojiArray.filter(e => e).map(e => `<${e.animated ? 'a' : ''}:${e.name}:${e.id}>`);
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});```
that's close ^
@earnest phoenix you're doing it in the wrong place
look at the snippet above
Oh
idk whytf it isnt working
e1 this is for said emoji 1
Кто русский
yeah okok just try my code
Émoji
e1: <:undefined:undefined>
e2: <:undefined:undefined>
e3: <:undefined:undefined>
e4: <:undefined:undefined>
what's your code
@deft forum english here please, we cant understand you
If you just want to talk or chat then use #memes-and-media
oh wtf
OH
ME DUMB
FK ME
return Promise.all(getemojis).then(emojiArray => {
emojiArray = emojiArray.filter(e => e).map(e => `<${e[0].animated ? 'a' : ''}:${e[0].name}:${e[0].id}>`);
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});```
NOW
IT SHOULD WORK
Help me add a bot to the server
const Discord = require("discord.js");
const bot = new Discord.Client();
const config = require("../assets/config.json");
exports.run = async (client, message, args) => {
if(message.author.id != config.owner) return;
function findEmoji(id) {
var emoji = this.emojis.get(id);
const temp = this.emojis.get(id);
if (!emoji) return null;
if (!temp) return null;
var emoji = Object.assign({}, temp);
if (emoji.guild) emoji.guild = emoji.guild.id;
emoji.require_colons = emoji.requiresColons;
return emoji;
}
let getemojis = [
client.shard.broadcastEval(`(${findEmoji}).call(this, '469480312389369857')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '469482201126273044')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '469482498431123466')`),
client.shard.broadcastEval(`(${findEmoji}).call(this, '492061158971408414')`)
];
return Promise.all(getemojis).then(emojiArray => {
emojiArray = emojiArray.filter(e => e).map(e => `<${e.animated ? 'a' : ''}:${e.name}:${e.id}>`);
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
}
Okay
show output
@earnest phoenix yeah my brain isnt working well, thx haha
oh well I just realised
you did 4 broadcast eval statements
could have combined them into one by modifying the findemoji function and passing an array instead
thats why it returns null
and it does seem that just nice your shard that the emojis were on is shard 0
idk if that will break the code in the future
np
return Promise.all(getemojis).then(emojiArray => {
emojiArray = emojiArray.filter(e => e.filter(ee => ee)).map(e => `<${e[0].animated ? 'a' : ''}:${e[0].name}:${e[0].id}>`);
const embemo = new Discord.RichEmbed()
.setTitle("Émoji")
.setDescription(`e1: ${emojiArray[0]}\ne2: ${emojiArray[1]}\ne3: ${emojiArray[2]}\ne4: ${emojiArray[3]}`)
return message.reply(embemo);
});
});```
that should solve the problem
in future
if the shard is not 0
^^
bot.on("message",message=>{
setInterval(() => {
bot.channels.get("655144818799804448").send(bot.users.get("592021274361069568"))
}, 1200000)
})
Hi I want my bot to mention in me in a channel every X time
why is not working
One message removed from a suspended account.
One message removed from a suspended account.
yep thanks
hi again
bot.once("ready", () => {
setInterval(() => {
bot.channels.get("655144818799804448").send('<@' + 592021274361069568 + '><@' + 230676840052817920 + '>')
}, 60000)
})
why is not working properly
its mentioning my friend the 2nd ID but my ID is just shown not mentioning me
try adding a space between the > and <@
Why...
You could also just use templates
why not just do .send("<@yourid>\n <@friendid>")
you don't really need the + 's i don't think unless im stupid
@prime cliff cause im noob in js haha
@sudden geyser you mean > space <@
at the 2nd id?
Just do '@untold widget@smoky plume'
hi again
bot.once("ready", () => {
setInterval(() => {
bot.channels.get("655470156751044639").send('**Hey, dudes** <@id1> <@id2> **go !bump, damn.**')
}, 60000)
})
how to add in the same message a shorcut to a channel
by using the channel id
I mean, the bot will send every X time that message in a channel but I want it to send the shorcut to a channel in the same message
sounds like spam and api abuse
why would be abi abuse
if there are even more bots that has reminders
but I want to make it for myself
@earnest phoenix well so mine its okay or
why is tatsumaki having remindme then
if its not allowed
it is
because that triggers once
but it only reminds you once
they dont autopost every X times
yours loops and constantly pings which is a form of spam
well its reminding only once







