- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
#creating guild events - is there a better way than this?
42 messages · Page 1 of 1 (latest)
because it shows what I am trying to do which is figure out how to do the same thing in discord js (GuildScheduledEventManager)
but I think I may have finally found a way to do it
That’s not even djs though
That’s discordnet or whatever that is
it was to show the idea of what I wanted to see what djs could possibly do
That’s not even javascript lmao
which ultimately led me to this ``` const guildID = process.env.GUILD_ID;
const guild = interaction.client.guilds.cache.find(guildID);
if (!guild)
return console.log('Guild not found');
const event_manager = new GuildScheduledEventManager(guild);
await event_manager.create({
name: 'Test Event',
scheduledStartTime: new Date(1687284000000),
privacyLevel: GuildScheduledEventPrivacyLevel.GuildOnly,
entityType: GuildScheduledEventEntityType.Voice,
description: 'This is a test Scheduled Event',
channel: '1118952214774419569',
image: null,
reason: 'Testing with creating a Scheduled Event',
});```
Client (extends BaseClient)
The main hub for interacting with the Discord API, and the starting point for any bot.
Look at the events section
correct, again that was to show what I wanted to do in it
That’ll show all of the events with parameters
That’s not how you access the manager
Guild#scheduledEvents
A manager of the scheduled events of this guild
You don’t make new managers, you access the property from where it’s coming from
<interaction>.user, <message>.author, <Client>.users etc
And find takes a function, not a key
So there isnt a way in djs to actually create new events?
Guild#scheduledEvents
A manager of the scheduled events of this guild
yes, that is what I am trying to do
Check this
https://old.discordjs.dev/#/docs/discord.js/14.11.0/class/GuildScheduledEventManager?scrollTo=create
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
You access the manager by grabbing the guild, <client>.guilds.cache.get(id) then accessing the manager on that guild if it’s exists
All Guilds are cached if you have the Guilds intent
ah okay, let me look a tad more, making progress just got ReferenceError: GuildScheduledEventManager is not defined which is further than I was
console.log(guild, "bob");
if (!guild)
return console.log('Guild not found');
const event_manager = new GuildScheduledEventManager(guild);```
Do you even have a valid logged in client?
yep
Then use it
again
.find() takes a function
guild.scheduledEvents
Is the manager
oh so did GuildScheduledEventManager get replaced?
Nope, why would it? Lol
You don’t make new managers like that, you access the managers on a property
ah okay, sorry still trying to wrap my head aroound this. It is all still new to me
It’s all good