Skip to content

Commit

Permalink
Course Command Fixing - Collection Null Value Error (#162)
Browse files Browse the repository at this point in the history
* Accounting for non-channel returns associated to snowflakes

* Utilise cache directly as fetch falls back to a cache call anyway
  • Loading branch information
Domin0de authored Oct 31, 2023
1 parent 4bac7ae commit b9576b5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion commands/rolesPermOverride.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const in_overwrites = (overwrites, id) =>
async function editChannels(interaction, channels) {
for (const data of channels) {
const channel = data[1];

if (!channel) continue;

const is_valid = is_valid_course_name(channel.name);

if (!is_valid || channel.type !== "GUILD_TEXT") continue;
Expand Down Expand Up @@ -98,6 +101,9 @@ async function allFixed(interaction, channels) {
const unfixed = [];
for (const data of channels) {
const channel = data[1];

if (!channel) continue;

const fixed = await isFixed(interaction, channel);

if (!fixed) unfixed.push(channel.name);
Expand Down Expand Up @@ -143,7 +149,7 @@ module.exports = {

if (!interaction.options.getBoolean("singlechannel")) {
// Get all channels and run specified function
const channels = await interaction.guild.channels.fetch();
const channels = interaction.guild.channels.cache;

if (!interaction.options.getBoolean("check")) {
await editChannels(interaction, channels);
Expand Down

0 comments on commit b9576b5

Please sign in to comment.