#creating guild events - is there a better way than this?

42 messages · Page 1 of 1 (latest)

merry krakenBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • 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!
lethal birch
#

How is that related to djs whatsoever

#

What are you trying to achieve within djs

scenic plank
#

but I think I may have finally found a way to do it

lethal birch
#

That’s discordnet or whatever that is

scenic plank
#

it was to show the idea of what I wanted to see what djs could possibly do

lethal birch
#

That’s not even javascript lmao

scenic plank
#

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',
});```
cinder steepleBOT
#

class Client (extends BaseClient)
The main hub for interacting with the Discord API, and the starting point for any bot.

lethal birch
#

Look at the events section

scenic plank
lethal birch
#

That’ll show all of the events with parameters

lethal birch
cinder steepleBOT
lethal birch
#

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

scenic plank
#

So there isnt a way in djs to actually create new events?

lethal birch
#

Wdym by a new event, a new GuildScheduledEvent?

#

Ofc there is

cinder steepleBOT
scenic plank
#

yes, that is what I am trying to do

lethal birch
#

Check this

#

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

scenic plank
#

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);```
lethal birch
#

Do you even have a valid logged in client?

scenic plank
#

yep

lethal birch
#

Then use it

#

again

#

.find() takes a function

#

guild.scheduledEvents

#

Is the manager

scenic plank
#

oh so did GuildScheduledEventManager get replaced?

lethal birch
#

Nope, why would it? Lol

#

You don’t make new managers like that, you access the managers on a property

scenic plank
#

ah okay, sorry still trying to wrap my head aroound this. It is all still new to me

lethal birch
#

It’s all good