RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty - javascript

I have this code, and I keep getting this error:
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.
at Object.run (C:\Users\Sochum\Desktop\BobloxBot\commands\GroupStats.js:41:2)
Line 41 has this code: .addFields(
Here is the code:
const embed = new Discord.MessageEmbed()
.setTitle(`${groupname}`)
.addFields(
{ name: `🤴 Group Owner`, value: `<#${owner}>` },
{ name: `👑 Group Co-Owner`, value: `<#${co_owner}>` },
{ name: `🚹 Member Count`, value: `${membercount}` },
{ name: `💰 Group Funds`, value: `${funds}` },
{ name: `📦 Group Items`, value: `${group_items}` },
{ name: `🎂Group Birthday`, value: `${Group_Bday}` },
{ name: `🤝Group Sharing Circle`, value: `${sharing_circle}` },
{ name: `📈Group Warwins`, value: `${Group_Warwins}` },
{ name: `📉Group Warlosses`, value: `${Group_Warlosses}` },
)
message.channel.send(embed)
I can't seem to find a problem anywhere, so I am not sure why I am getting this error

I've ran your code and it works fine for me. This error happens when one of the field value is empty, so be sure that all your variables are defined and that they can be read inside of a string.

Related

why am I getting an invalid token standard error?

I want to update the metadata of an NFT using metaplex js library,
I followed the docs but I keep gettin an invalid token standard error.
const new_uri = await metaplex.nfts().uploadMetadata(
uri_obj,
)
await metaplex.nfts().update({
nftOrSft: nft,
uri:new_uri.uri
});
I created a new storage unit in airweave and got it's url but I keep getting the error
and not just on the url but when I try to change the name for testing purposes aswell.
full error:
return resolvedError ? new ProgramError.ParsedProgramError(program, resolvedError, error.logs) : new ProgramError.UnknownProgramError(program, error);
^
ParsedProgramError: The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [135] that translates to "Invalid token standard".
Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]
Caused By: InvalidTokenStandard: Invalid token standard
Program Logs:
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]
| Program log: Instruction: Token Metadata Update
| Program log: Invalid token standard
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 18628 of 200000 compute units
| Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x87
here is the uri_object that I'm using
{
name: 'Suteki #467',
symbol: 'TEKI',
description: "Suteki is a unique collection of 6000 anime PFP's that focus on community building and creating real-world value. Claim your Buzoku (tribe), follow the lore and work up the ranks of the hierarchy to become a Oyabun (Family boss).",
seller_fee_basis_points: 900,
image: 'https://bafybeifsrfzvrms7ptbuv2pjhg3a5lr6waxhd6qyjzpm3ynogs3cbvfcdq.ipfs.nftstorage.link/467.png?ext=png',
attributes: [
{ trait_type: 'Background', value: 'Sand' },
{ trait_type: 'Type', value: 'Light Scar' },
{ trait_type: 'Tattoo or Scar Small', value: 'Mouth Scar' },
{ trait_type: 'Tattoo or Scar Large', value: 'Suteki Faction' },
{ trait_type: 'Mouth', value: 'Smile' },
{ trait_type: 'Eyes', value: 'Blue' },
{ trait_type: 'EyeBrows', value: 'Raised Right' },
{ trait_type: 'Clothes', value: 'Spike Blazer' },
{ trait_type: 'Mask', value: 'Cloth Wrap Blizzard' },
{ trait_type: 'Hair', value: 'Blue Comb Over' },
{ trait_type: 'Rank', value: 'Shatei (Little Brother)' },
{ trait_type: 'Buzoku', value: 'Akamatsu' }
],
properties: {
category: 'image',
files: [ [Object] ],
creators: [ [Object], [Object] ]
},
collection: { name: 'Suteki', family: 'Suteki' }
}

How can send data from an array in one embed message (discord.js)

I want to send data from an array in one embed message with few fields but my code sends them as 4 different embed messages with one field
I tried with this Code :
const pListEmbed = new Discord.MessageEmbed()
.setColor('#03fc41')
.setTitle('Connected')
.setDescription(Total : ${list.length})
.setThumbnail(config.logo)
.addFields(
array.flatMap(user => [
{ name: 'ID', value: user.id, inline: true },
{ name: 'Name', value: user.user_name, inline: true },
{ name: 'Identifier', value: user.identifier, inline: true }
])
)
)
.setTimestamp(new Date())
.setFooter('Used by: ' + message.author.tag, ${config.SERVER_LOGO});
message.channel.send(pListEmbed);
But it sends 4 embed messages with just one field that have id,username and identifier, and i don't want it like this. I want it to send one embed message with 4 different fields that have these 4 id,username and identifiers (we don't know how many of them we have)
Array :
[
{
id: '46892319372',
user_name: 'testerOne',
identifier: '20202'
}
]
[
{
id: '15243879678',
user_name: 'testerTwo',
identifier: '20201'
}
]
[
{
id: '02857428679',
user_name: 'testerThree',
identifier: '20203'
}
]
[
{
id: '65284759703',
user_name: 'testerFour',
identifier: '20204'
}
]
Your question is very unclear. If you want to send one embed for every user containing the ID, name and identifier, then you could do this:
list.forEach(user => {
const pListEmbed = new Discord.MessageEmbed()
.setColor('#03fc41')
.setTitle('Connected')
.setDescription(Total : ${list.length})
.setThumbnail(config.logo)
.setTimestamp(new Date())
.setFooter('Used by: ' + message.author.tag, ${config.SERVER_LOGO});
.addFields(
{
name: "ID"
value: user.id,
inline: true
},
{
name: "Name"
value: user.user_name,
inline: true
},
{
name: "Identifier"
value: user.identifier,
inline: true
}
)
message.channel.send(pListEmbed);
})
If on the other hand you want to send one embed only and it contains all the IDs, all the names, and all the identifiers, then this is impossible. Embed have character limits and since you don't know how many users you have, there could be thousands, thus busting the limit. And that would block you from sending the embed.
Also your "array" is in fact multiple arrays containing only one element each. I don't know if that's what you intended or not but it's not an array but multiple little ones.

DiscordJS v13 Invalid Form Body

I am trying to make a toggle able slash command, if they pick the disable option it turns it off but when if you pick the enable option it asks to pick a channel but it gives this error
Error:
DiscordAPIError[50035]: Invalid Form Body
23.name[BASE_TYPE_REQUIRED]: This field is required
rawError: {
code: 50035,
errors: { '23': [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'put',
url: 'https://discord.com/api/v9/applications/971024098098569327/commands'
Code:
module.exports = {
name: 'welcomer',
permissions: 'MANAGE_CHANNELS',
description: 'Set Where Welcome Messages Get Sent To.',
options: [
{
name: 'toggle',
description: 'Toggle On/Off The Welcomer',
type: 3,
required: true,
choices: [
{
name: 'disable',
value: 'off',
},
{
name: 'enable',
value: 'on',
choices: [
{
name: 'channel',
description: 'Select channel to send welcome messages to',
type: 7,
required: true,
},
]
},
],
},
],
Those would be an example of a subcommand and need to be indicated as such and will need descriptions in a couple places.
module.exports = {
name: 'welcomer',
permissions: 'MANAGE_CHANNELS',
description: 'Set Where Welcome Messages Get Sent To.',
options: [{
name: 'disable',
description: `'Disable welcomer`, // Added needed description
type: 1, //converted to subcommmand
}, {
name: 'enable',
description: `'Enable welcomer`, // Added needed description
type: 1, //converted to subcommmand
options: [{
name: 'channel',
description: 'Select channel to send welcome messages to',
type: 7,
required: true,
channel_types: [0] // allows only text channels to be selected
}]
}],
// run command pick only one of the below two
// if command.execute()
async execute(client, interaction, args)
// if command.run()
run: async (client, interaction, args) =>
// command code below here assumes you have the code in your `interactionCreate` listener to set up args
{
if (args.disable) {
// Code to turn off
} else if (args.enable) {
const channel = args.channel
// Code to turn on
};
}
}

Unable to get users .joinedAt value

Trying to write an info command. I don't think I'm correctly getting the guild member to get the .joinedAt value, and I haven't been able to find a recent example. Here is the relevant code. Any help appreciated:
const user = await interaction.options.getUser("user").fetch(true);
embed.setTitle(`User info for ${user.username}`);
embed.addFields(
{ name: "User Tag:", value: `${user.tag}`, inline: true },
{ name: "User ID:", value: `${user.id}`, inline: true },
{ name: "Bot Status:", value: `${user.bot}`, inline: true },
{
name: "Account Creation Date:",
value: `${user.createdAt}`,
inline: false
},
// I'm trying to get the .joinedAt value here
{
name: "Guild Join Date:",
value: `${interaction.message.guild.member(user).joinedAt}`,
inline: false
}
);
You are getting just common user using getUser instead of getMember which is server member

Ignore error when importing users to Google Suite

I am importing users to Google Suite from a Google sheet using Google Apps Script. I have made "custom attributes" in Google Admin Console, some of them are set to type email. Everything works great except when one user lack those email addresses.
My users are kids, and the emailaddresses are to the kid's parents. One kid might have 1 parent and 1 email. Other kids have 4 parents and 4 emails.
If all variables (epost1, epost2, epost3 and epost4) are filled with email-addresses the user is added. If one of the variables are empty, the script stops with the following message:
GoogleJsonResponseException: API call to directory.users.insert failed
with error: Invalid Input: custom_schema (line 272, file
"nyeMedlemmer")
I tried to put an if-statement in the code, but that was not possible. Is there a way I can tell the script to just ignore those errors?
My code (after the variables are set):
var user = {
primaryEmail: epost,
name: {
givenName: fmnavn,
familyName: etternavn
},
addresses: [
{
type: "home",
formatted: adr
},
{
type: "other",
formatted: adr2
},
{
type: "home",
postalCode: postnr
}
],
phones: [
{
value: mobil,
type: "home"
}
],
emails: [
{
address: epostPriv,
type: "home"
}
],
recoveryEmail: epost1,
locations: [
{
floorName: grad,
type: "desk",
area: "desk"
}
],
gender: {
type: kjonn
},
orgUnitPath: "/Speidere/Stifinnere/"+tropp,
customSchemas: {
Personlig_informasjon: {
skole: skolen,
hensyn: hensynet,
bursdag: dato
},
Innmeldingssvar: {
hjelpe_til: hjelpen,
teste: testen,
merknad: merknaden,
bilde: bildet,
samtykke: samtykket,
innmeldingsdato: innmeldingsdatoen
},
Foresatt: {
foresatt_navn: [
{
value: navn1
},
{
value: navn2,
},
{
value: navn3
},
{
value: navn4
}
],
foresatt_epost: [
{
value: epost1
},
{
value: epost2
},
{
value: epost3
},
{
value: epost4
}
],
foresatt_mob: [
{
value: mobil1
},
{
value: mobil2
},
{
value: mobil3
},
{
value: mobil4
}
]
},//foresatt
},//CustomSchemas
password: passord
}; //var user
user = AdminDirectory.Users.insert(user);
Sometimes all I need is a little break away from the code... I suddenly dawned on my that I could do the if earlier in code:
var epostForesatt = "{value:"+ epost1+"}";
if (epost2 != '') {
var epostForesatt = epostForesatt + ",{value:"+ epost2+"}";
}
if (epost3 != '') {
var epostForesatt = epostForesatt + ",{value:"+ epost3+"}";
}
if (epost4 != '') {
var epostForesatt = epostForesatt + ",{value:"+ epost4+"}";
}
And then later in, down in "var user customSchemas" I edit the code to to use this variable.
Foresatt: {
foresatt_navn: [
{
value: navn1
},
{
value: navn2,
},
{
value: navn3
},
{
value: navn4
}
],
foresatt_epost: [epostForesatt],

Categories