Rocky43007
Rocky43007
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
If anyone wants the working code, here it is: https://gist.github.com/Rocky43007/f0c8f75a37c846ffcd21ab9ad4bb8e8b WARNING: You do have to patch any functions used in the Interaction object. For example, .reply() needs to be patched in the interaction object from the client side or your command will error out why it tries to run <CommandInteraction>.reply()
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Cool
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Also, JSON serializable can't send functions if I'm correct?
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Fair enough. I did get it working though. Thanks for all your help!
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Hm. client.shard.send() should work.
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
I just need it to send a string saying testComplete and that's it.
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Wait, can client emit to the sharding manager?
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
It was the bitfields
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Maybe it's the bitfields?
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Got a better error this time: TypeError: Do not know how to serialize a BigInt
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Ok, figured it out!
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Which, doesn't work. But that might be because I just don't understand the docs.
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
So something like
shard?.eval((c, context = inter) => {
c.emit('test', context);
});
shard?.eval((c, context = inter) => {
c.emit('test', context);
});
?
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Oh, come on!
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
So, I've changed gears and I'm trying to have the mock_interaction generated before being sent to a test event on client. I've had it work with c.emit("test," "test") with the bot's client.on("test") outputting test in the console. However, the second I try this:
try {
// let client: Client | null = null;

shard?.on('ready', () => {
const inter = generateMockInteraction('status');
console.log(inter);
shard?.eval(c => {
c.emit('test', inter);
});
});
// if (client === null) {
// throw new Error('Client is null');
// }
// runAllTests(client);
} catch (e) {
console.error(e);
process.exit(exitCode);
}
try {
// let client: Client | null = null;

shard?.on('ready', () => {
const inter = generateMockInteraction('status');
console.log(inter);
shard?.eval(c => {
c.emit('test', inter);
});
});
// if (client === null) {
// throw new Error('Client is null');
// }
// runAllTests(client);
} catch (e) {
console.error(e);
process.exit(exitCode);
}
I now get Error [ReferenceError]: inter is not defined. Now, this should be working because I'm running the code and just sending an object now to the client. But... it's not.
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
:faceDesk:
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Ohhhhh, that makes more sense
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
(At this point, I'm just going to document what it took to get it working [if it ever works] for future devs)
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
Welp, I tried this and it didn't work because Client is always null:
try {
let client: Client | null = null;

shard?.on('ready', () => {
shard?.eval(c => {
c.on('ready', () => {
client = c;
});
return {};
});
});
if (client === null) {
throw new Error('Client is null');
}
runAllTests(client);
} catch (e) {
console.error(e);
process.exit(exitCode);
}
try {
let client: Client | null = null;

shard?.on('ready', () => {
shard?.eval(c => {
c.on('ready', () => {
client = c;
});
return {};
});
});
if (client === null) {
throw new Error('Client is null');
}
runAllTests(client);
} catch (e) {
console.error(e);
process.exit(exitCode);
}
Gist: https://gist.github.com/Rocky43007/75803ae37f5c3e832bd2d4371f355296#file-tester_v3-ts
40 replies
DIAdiscord.js - Imagine an app
Created by Rocky43007 on 5/9/2024 in #djs-questions
Trying to get Client from ShardingManager for Test Suite
👍
40 replies