guildUpdate/guildSystemChannelUpdate.js

  1. const event = __filename
  2. .replace(__dirname, "")
  3. .split(".")
  4. .slice(0, -1)
  5. .join(".")
  6. .replace("/", "")
  7. .replace("\\", "");
  8. module.exports = async (oldGuild, newGuild) => {
  9. /**
  10. * @event this
  11. * @description Emitted when the system channel is changed
  12. * @param {Discord:Guild} The guild where the changes were made
  13. * @param {Discord:TextChannel} The old system channel
  14. * @param {Discord:TextChannel} The new system channel
  15. * @example
  16. * client.on(event, async (guild, oldSystemChannel, newSystemChannel) => {
  17. * console.log(`The guild with the id ${guild.id} updated system channel (${oldSystemChannel} => ${newSystemChannel}).`);
  18. * });
  19. */
  20. var client = oldGuild.client;
  21. if (
  22. oldGuild.systemChannelID != newGuild.systemChannelID &&
  23. newGuild.systemChannelID != (null || undefined) &&
  24. oldGuild.systemChannelID != (null || undefined)
  25. )
  26. client.emit(
  27. event,
  28. newGuild,
  29. oldGuild.systemChannel,
  30. newGuild.systemChannel
  31. );
  32. };