dd
const [ book, setBook ] = useRecoilState(axiosSelector)
const clickHandlerName = () =>{
const _book = [...book].sort((a, b) => (a.title > b.title) ? 1 : -1)
console.log(_book)
setBook(_book)
}
Error message -
Uncaught Error: Attempt to set read-only RecoilValue:
nothing's changing the 'book' state directly but why is that error showing up?
(the conole logging is working just fine, i believe the problem must have to do with "setBook(_book)" line)
Related
This Is My index.js
const LOAD_SLASH = process.argv[2] == "load"
const CLIENT_ID = "981858607362629663"
const GUILD_ID = "970702726348546078"
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates
]
})
client.slashcommands = new Discord.Collection()
client.player = new Player(client, {
ytdlOptions: {
quality: "highestaudio",
highWaterMark: 1 << 25
}
})
let commands = []
const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
const slashcmd = require(`./slash/${file}`)
client.slashcommands.set(slashcmd.data.name, slashcmd)
if (LOAD_SLASH) commands.push(slashcmd.data.toJSON())
}
I Recieve The Following Error After I Run node index.js load :-
DiscordAPIError[50035]: Invalid Form Body 5[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names must be unique at SequentialHandler.runRequest
I have tried uninstalling and re-installing discord.js, still I am experiencing this error, I would really like some help!
You have a duplicate command name somewhere in your files. Try finding it with the following snippet:
const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
const slashcmd = require(`./slash/${file}`)
console.log(slashcmd.data.name)
}
Find the command name which is logged twice and edit the command file accordingly.
In one of the files you duplicated name with another file
I would like to create other address/accounts belonging to my initial account, the goal is to have several separate addresses and carry out transactions by paying the fees from my main accounts.
It's like the exchanges create accounts that belong to them and they make transactions between by paying the fees.
This is my example:
// BANK or Exchange
const BankaccountKeypair = web3.Keypair.fromSecretKey([160,15,25, ...]);
const BANK_wallet = splEasy.Wallet.fromKeypair(connection,BankaccountKeypair);
// Customer A (to)
const A_wallet = splEasy.Wallet.fromKeypair(connection,web3.Keypair.fromSecretKey([20,18,125, ...]));
var myToken = new splToken.Token(
connection,
new web3.PublicKey('TRmbtbEW4g.......'),
splToken.TOKEN_PROGRAM_ID,
BANK_wallet
);
// A account (to)
var A_walletAccount = await myToken.getOrCreateAssociatedAccountInfo( A_wallet.publicKey );
// B account(from)
const B_walletAccount = await myToken.createAssociatedTokenAccount( BANK_wallet.publicKey );
// transaction
var transaction = new web3.Transaction()
.add(
splToken.Token.createTransferInstruction(
splToken.TOKEN_PROGRAM_ID,
B_walletAccount.address,
A_walletAccount.address,
BANK_wallet.publicKey,
[],
0
)
);
// signature
var signature = await web3.sendAndConfirmTransaction() ....
But I got an error on:
// B account(from)
const B_walletAccount = await myToken.createAssociatedTokenAccount( BANK_wallet.publicKey );
throw new TypeError('unexpected type, use Uint8Array');
^
TypeError: unexpected type, use Uint8Array
I tried by
const B_walletAccount = await myToken.createAssociatedTokenAccount([160,15,25, ...]);
But I got:
if (!allowOwnerOffCurve && !web3_js.PublicKey.isOnCurve(owner.toBuffer())) {
^
TypeError: owner.toBuffer is not a function
When I use
getOrCreateAssociatedAccountInfo(B_wallet);
it's working but, Transaction is failed :
var transaction = new web3.Transaction()
.add(
splToken.Token.createTransferInstruction(
splToken.TOKEN_PROGRAM_ID,
B_walletAccount1.address,
A_walletAccount.address,
BANK_wallet.publicKey,
[],
2000000
)
);
// error :
Transaction simulation failed: Error processing Instruction 0: custom program error: 0x4
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
Program log: Instruction: Transfer
Program log: Error: owner does not match
*/
I need to have lot of address without SOL/lamports that I should transfer myToken between those addresses
i have this reaction role system everything works up to the last part where the coulour slection happens
async run(message, client, con) {
await message.channel.send("Give the color for the embed.")
answer = await message.channel.awaitMessages(answer => answer.author.id === message.author.id,{max: 1});
var color = (answer.map(answers => answers.content).join()).toUpperCase()
if(color.toUpperCase()==='CANCEL') return (message.channel.send("The Process Has Been Cancelled!"))
function embstr(){
var finalString = '';
for(var i =0;i<n;i++){
finalString += b[i]+ ' - '+a[i] +'\n';
}
return finalString;
}
const botmsg = message.client.channels.cache.get(channel => channel.id === reactChannel)
const embed = new MessageEmbed()
.setTitle(embtitle)
.setColor(color)
.setDescription(embstr());
botmsg.send(embed);
message.channel.send("Reaction Role has been created successfully")
here is the error message
{
"stack": "TypeError: Cannot read property 'send' of undefined
at SlowmodeCommand.run (B:\\stuff\\Downloads\\Admeeeeeen bot\\src\\commands\\reactionroles\\createreactionrole.js:100:22)
at processTicksAndRejections (node:internal/process/task_queues:93:5)"
}
The .get() method takes in a snowflake as its parameter. AKA an ID of a certain object. It is not an iterator, meaning that what you're currently attempting to do is not right JavaScript wise.
Instead of passing in a parameter to represent a channel object, we'll just want to pass in the ID of the channel that we'd like to get. Alternatively, you could replace .get() with .find() there, which is in fact an iterator that uses this form of a callback, although it's insufficient in our case considering we can just use .get() which is more accurate when it comes to IDs.
/**
* Insufficient code:
* const botmsg = message.client.channels.cache.find(channel => channel.id === reactChannel)
*/
const botmsg = message.client.channels.cache.get(reactChannel /* assuming that reactChannel represents a channel ID */)
Whenever I use my checkwarns command to check the number of warns a user has it gives me this error:
2019-03-20T23:55:35.590941+00:00 app[worker.1]: (node:4)
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'warns' of
undefined
2019-03-20T23:55:35.590958+00:00 app[worker.1]: at
Object.module.exports.run (/app/commands/checkwarns.js:10:35)
I don't know how to fix this I can't find any problems with my code.
const Discord = require("discord.js");
const fs = require("fs");
const ms = require("ms");
let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
module.exports.run = async(bot, message, args) => {
if (!message.member.hasPermission("MANAGE_MESSAGES")) return
message.reply("You don't have permssion to use this command");
let wUser = message.guild.member(message.mentions.users.first()) ||
message.guild.members.get(args[0])
if (!wUser) return message.reply("Couldn't find that user");
let warnlevel = warns[wUser.id].warns;
if (!warns[wUser.id]) warns[wUser.id] = {
warns: 0
};
message.delete().catch();
let warnembed = new Discord.RichEmbed()
.setTitle("**warns**")
.setColor("#0xff80ff")
.addField("User Warns", warnlevel, true);
message.channel.send(warnembed);
}
module.exports.help = {
name: "checkwarns"
}
I'm using Heroku to host the bot.
Your issue might be occuring here:
let warnlevel = warns[wUser.id].warns;
If the key wUser.id doesn't exist, the value of warns[wUser.id] would be undefined, which doesn't contain any user-defined properties. Hence, you get an error trying to read the value of warns (a user-defined property) in undefined.
To get around this, you want to check whether an object at warns[wUser.id] actually exists first. An easy way to do this is by doing the following:
var warnLevel;
if (warns[wUser.id] != undefined) {
warnLevel = warns[wUser.id].warns
}
else {
// Do something else to initialize either warnLevel or warns[wUser.id] here
}
I'm attempting to convert an existing project into a cocoapod so that it will be easier to use however when I run
pod spec lint --verbose
I get a number of errors similar to
- ERROR | [iOS] xcodebuild: CoreDataServices/CoreDataServices/Services/Count/CDSCountService.m:28:9: error: use of undeclared identifier 'NSFetchRequest'
I have the following as my podspec:
Pod::Spec.new do |s|
s.name = "CoreDataServices"
s.version = "0.2.0"
s.summary = "CoreDataServices contains a set of helper classes to abstract away common core data functionality."
s.homepage = "http://www.williamboles.me"
s.license = { :type => 'MIT',
:file => 'LICENSE.md' }
s.author = "William Boles"
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/wibosco/CoreDataServices.git",
:branch => "master",
:tag => s.version }
s.source_files = "CoreDataServices/**/*.{h,m}"
s.public_header_files = "CoreDataServices/**/*.{h}"
s.frameworks = 'UIKit', 'CoreData'
s.requires_arc = true
end
I have cocoapod version 0.39.0 installed.
Building the project using xcodebuild outside of cocoapods results in the project being built without errors.
I managed to get there in the end but it's an odd one:
Pod::Spec.new do |s|
s.name = "CoreDataServices"
s.version = "0.2.0"
s.summary = "CoreDataServices contains a set of helper classes to abstract away common core data functionality."
s.homepage = "http://www.williamboles.me"
s.license = { :type => 'MIT',
:file => 'LICENSE.md' }
s.author = "William Boles"
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/wibosco/CoreDataServices.git",
:branch => "master",
:tag => s.version }
s.source_files = "CoreDataServices/**/*.{h,m}"
s.public_header_files = "CoreDataServices/**/*.{h}"
s.requires_arc = true
s.frameworks = 'UIKit', 'CoreData'
end
I moved s.requires_arc = true to be above s.framework = 'UIKit', 'CoreData' and the errors went away.
I also noticed that if I inverted the ordering of the framesworks so that it becomes
s.frameworks = 'CoreData', 'UIKit'
s.requires_arc = true
that also worked