How to create a new channel for a guild?

I have a bot that will create a text channel to write into when invited. My question is how can I do this with discord.js? More specifically. I have this code that I have written by just exploring the API:
const guild = await client.guilds.cache.get("<some-id>");
guild?.channels.create({
    name: "test",
    type: ChannelType.GuildText,
    topic: "test",
});

I'm guessing that this will work, but I'm not sure I understand what cache is about. I've seen this throughout the API, but I'm not sure how it works. Do I have to load the cache, or does it happen lazily whenever I try to interact with something?
Was this page helpful?