wen
wen
Explore posts from servers
DIAdiscord.js - Imagine a bot
Created by wen on 12/23/2023 in #djs-questions
Preventing Unknown Interaction Crash
i get "unknown interaction" error at random times... like sometimes a button works fine and sometimes it gives the said error.... ofc the bot crashes when it happens... is there any way i can prevent it from crashing when this happens ? and also keep the button collector going ?
6 replies
DIAdiscord.js - Imagine a bot
Created by wen on 10/6/2023 in #djs-questions
Image URL doesn't show up in embed
No description
5 replies
DIAdiscord.js - Imagine a bot
Created by wen on 9/17/2023 in #djs-voice
Trying to play a local wav file in a vc but it doesn't play more than a min.
Trying to play a local wav audio file in a vc but it doesn't play for more than a min even though the actual file is of 3 mins. Code:
if (GuildVoice.has(message.guild.id))
return message.reply("Sorry! already in another voice channel");

let connection;
connection = await joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guild.id,
selfMute: false,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator,
});

let filePath =
"./Audio/path/to-file.wav";

let src = await createAudioResource(filePath, {
inputType: StreamType.Arbitrary,
});

const player = await createAudioPlayer({
behaviors: { noSubscriber: "pause" },
});
await connection.subscribe(player);
await player.play(src);

player.on(AudioPlayerStatus.Idle, async () => {
await sleep(1500);
connection.destroy();
});
if (GuildVoice.has(message.guild.id))
return message.reply("Sorry! already in another voice channel");

let connection;
connection = await joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guild.id,
selfMute: false,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator,
});

let filePath =
"./Audio/path/to-file.wav";

let src = await createAudioResource(filePath, {
inputType: StreamType.Arbitrary,
});

const player = await createAudioPlayer({
behaviors: { noSubscriber: "pause" },
});
await connection.subscribe(player);
await player.play(src);

player.on(AudioPlayerStatus.Idle, async () => {
await sleep(1500);
connection.destroy();
});
10 replies
DIAdiscord.js - Imagine a bot
Created by wen on 9/16/2023 in #djs-questions
Separate content into pages
lets say i make an api call and it returns a massive paragraph which i would like to put in an embed with different pages... like in the first page there will be the first 4000 chars and so on... and u can switch b/w the pages using buttons how do i separate the content into pages and the content can be of any length so it cannot be hard coded
3 replies
DIAdiscord.js - Imagine a bot
Created by wen on 2/23/2023 in #djs-questions
Getting guild members on a sharded bot
I want to check if a user is present in a guild on the userUpdate event im doing this
client.guilds.cache.forEach(async (g) => {
if(!g.members.cache.get(id)) return;
}
client.guilds.cache.forEach(async (g) => {
if(!g.members.cache.get(id)) return;
}
now since i sharded my bot i gotta use fetchClientValues ( i think ) and the fetch client values for guilds.cache returns an array inside an array with 2 objects of the guilds the bot is in but they are no the full member object... they have a member property which is also an array but only has the cached member id ( only an array of id's ) s accessing the sharded guild object:
let res = await client.shard.fetchClientValues(`guilds.cache`);
res[0][0] //----> guild object ( not the full one )
res[0][0].members // ----> [ id1, id2, id3, ... ]
let res = await client.shard.fetchClientValues(`guilds.cache`);
res[0][0] //----> guild object ( not the full one )
res[0][0].members // ----> [ id1, id2, id3, ... ]
so is there any other method for what i need ?
14 replies
DIAdiscord.js - Imagine a bot
Created by wen on 2/6/2023 in #djs-questions
shard.broadcastEval gives me a reference error even tho all vars are defined
So I just sharded my bot and was playing around with client.broadcastEval and it gives me this. got a channelCreate.js event file like so:
module.exports = async (Discord, client, newChannel) => {
let logC;
console.log(newChannel.guild.name);
client.shard.broadcastEval(
async (c, { channelId }) => {
logC = await c.channels.fetch(channelId);
if (logC) {
logC = logC;
return true;
}
},
{ context: { channelId: "1061724696493703248" } }
);
logC.send("SHARD GOOD");
};
module.exports = async (Discord, client, newChannel) => {
let logC;
console.log(newChannel.guild.name);
client.shard.broadcastEval(
async (c, { channelId }) => {
logC = await c.channels.fetch(channelId);
if (logC) {
logC = logC;
return true;
}
},
{ context: { channelId: "1061724696493703248" } }
);
logC.send("SHARD GOOD");
};
and it gives this error when a channel is created
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^

Error [ReferenceError]: newChannel is not defined
at eval (eval at _eval (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\client\Client.js:479:12), <anonymous>:2:9)
at eval (eval at _eval (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\client\Client.js:479:12), <anonymous>:7:9)
at Client._eval (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\client\Client.js:479:12)
at ShardClientUtil._handleMessage (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\sharding\ShardClientUtil.js:194:82)
at process.emit (node:events:402:35)
at emit (node:internal/child_process:917:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^

Error [ReferenceError]: newChannel is not defined
at eval (eval at _eval (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\client\Client.js:479:12), <anonymous>:2:9)
at eval (eval at _eval (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\client\Client.js:479:12), <anonymous>:7:9)
at Client._eval (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\client\Client.js:479:12)
at ShardClientUtil._handleMessage (C:\Users\ddmis\OneDrive\Desktop\nah\Discord V14 bot\node_modules\discord.js\src\sharding\ShardClientUtil.js:194:82)
at process.emit (node:events:402:35)
at emit (node:internal/child_process:917:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
but it logs the guild name before crashing... also after the bot crashes it restarts itself automatically and thats weird cuz i dont have no such thing set up
69 replies
DIAdiscord.js - Imagine a bot
Created by wen on 2/4/2023 in #djs-questions
Getting objects from client cache after sharding
So I am about to shard my bot... its not yet public but I want to make it shard compatible from the beginning. My question is that... is getting stuff like guild object or user object from the cache or anything from the client cache in general if its different after sharding
14 replies
DIAdiscord.js - Imagine a bot
Created by wen on 1/17/2023 in #djs-voice
Play local file
is this enough to play an mp3 file ?
let connection;
connection = await joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guild.id,
selfMute: false,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator,
});

let src = await createAudioResource(
path.resolve(
"../../../pathToFile.mp3"
),

{ inlineVolume: true }
);
src.volume.setVolume(1);

const player = await createAudioPlayer();
await connection.subscribe(player);
await player.play(src);

message.channel.send("playing");
let connection;
connection = await joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guild.id,
selfMute: false,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator,
});

let src = await createAudioResource(
path.resolve(
"../../../pathToFile.mp3"
),

{ inlineVolume: true }
);
src.volume.setVolume(1);

const player = await createAudioPlayer();
await connection.subscribe(player);
await player.play(src);

message.channel.send("playing");
94 replies
DIAdiscord.js - Imagine a bot
Created by wen on 1/8/2023 in #djs-questions
Do not have permissions to use my own bot the second time
just created my own slash + prefix cmd handler but there is a problem with the slash part after i use any one slash cmd and then go to use another one (of the same bot) it says that i do not have any permission to use commands of that bot ( it says this in the slash commands dialog ) box it can use it again just once if i refresh the discord client
36 replies
DIAdiscord.js - Imagine a bot
Created by wen on 1/7/2023 in #djs-questions
Problem getting channel
so i have logChannel defined like this
globalThis.logChannel = client.channels.cache.get("channel id");
globalThis.logChannel = client.channels.cache.get("channel id");
and i have my error handler in a folder in the work dir... but it gives the error that cannot read properties of undefined i also used my eval cmd and it returns the channel info just fine
67 replies
DIAdiscord.js - Imagine a bot
Created by wen on 11/29/2022 in #djs-questions
userUpdate for global users
Does the userUpdate event work for cached users only ? And not for all discord users
43 replies
DIAdiscord.js - Imagine a bot
Created by wen on 11/14/2022 in #djs-questions
User Badges
Is there anyway to fetch all the badges of a user? Like in my case it only returns HOUSE_BALANCE and not the active developer badge
5 replies
DIAdiscord.js - Imagine a bot
Created by wen on 9/7/2022 in #djs-questions
Message Content problems
My bot can't access message content although the intents are enabled on the portal
68 replies