Woffer12
Woffer12
TTCTheo's Typesafe Cult
Created by CommandoBrando on 8/24/2024 in #questions
Best way to do form?
Ive been happy with ract hook form through shad cn components
10 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
@Rem
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
This is weird because other stuff seems to work fine hidethepain
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
would there be a way for me to fix this issue without changing how that works? not particaly fond of doing a complete re-write of that system kappa
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
just return it to the api, i don't alter it. Its just sending/receiving data between the bot and api through nats, i don't know the specifics as i was not the one to set it up
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
Here is the full code of the sections
async function handleGetAllAutomodRules(client, data) {
const { guildId } = data;

try {
/** @type {Guild} */
const guild = client.guilds.cache.get(guildId);
const automodRule = guild.autoModerationRules.cache;

return { data: automodRule, ok: true };
} catch (error) {
console.error(error);
}
}

async function handleBlockMention(client, data) {
const { guildId, ruleId, ruleConfig } = data;

try {
/** @type {Guild} */
const guild = client.guilds.cache.get(guildId);
if (!guild) return { error: "No Guild", data: `No Guild was found with the ID: ${guildId}`, ok: false, status: 404 };

const automodRule = guild.autoModerationRules.cache.get(ruleId);
if (!automodRule) return { error: "No Rule", data: `No Rule was found with the ID: ${ruleId}`, ok: false, status: 404 };

const result = await automodRule.edit(ruleConfig);

return { data: result, ok: true, status: 200 };
} catch (error) {
console.error(error);
return { error: error.name, data: error.message, ok: false, status: 500 };
}
}
async function handleGetAllAutomodRules(client, data) {
const { guildId } = data;

try {
/** @type {Guild} */
const guild = client.guilds.cache.get(guildId);
const automodRule = guild.autoModerationRules.cache;

return { data: automodRule, ok: true };
} catch (error) {
console.error(error);
}
}

async function handleBlockMention(client, data) {
const { guildId, ruleId, ruleConfig } = data;

try {
/** @type {Guild} */
const guild = client.guilds.cache.get(guildId);
if (!guild) return { error: "No Guild", data: `No Guild was found with the ID: ${guildId}`, ok: false, status: 404 };

const automodRule = guild.autoModerationRules.cache.get(ruleId);
if (!automodRule) return { error: "No Rule", data: `No Rule was found with the ID: ${ruleId}`, ok: false, status: 404 };

const result = await automodRule.edit(ruleConfig);

return { data: result, ok: true, status: 200 };
} catch (error) {
console.error(error);
return { error: error.name, data: error.message, ok: false, status: 500 };
}
}
Rule config data looks like:
{
"name": "Block Custom Words",
"eventType": 1,
"triggerMetadata": {
"allowList": [],
"keywordFilter": [
"Word 1",
"Word 2",
"Word 3",
"Word 4",
"Word 5"
],
"regexPatterns": [],
"presets": [],
"mentionTotalLimit": null,
"mentionRaidProtectionEnabled": false
},
"actions": [],
"enabled": true,
"exemptRoles": [],
"exemptChannels": []
}
{
"name": "Block Custom Words",
"eventType": 1,
"triggerMetadata": {
"allowList": [],
"keywordFilter": [
"Word 1",
"Word 2",
"Word 3",
"Word 4",
"Word 5"
],
"regexPatterns": [],
"presets": [],
"mentionTotalLimit": null,
"mentionRaidProtectionEnabled": false
},
"actions": [],
"enabled": true,
"exemptRoles": [],
"exemptChannels": []
}
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
I get the rules originally with this code (below) do some stuff with it, then run the code above ( https://canary.discord.com/channels/222078108977594368/1198436552083247114/1198617628864938114 ) on it
const guild = await client.guilds.fetch(guildId);
const automodRule = await guild.autoModerationRules.fetch();
const guild = await client.guilds.fetch(guildId);
const automodRule = await guild.autoModerationRules.fetch();
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
Collection(2) [Map] {
'1165052597539967056' => AutoModerationRule {
id: '1165052597539967056',
guild: null,
creatorId: '224188754946949130',
triggerType: 1,
name: 'Block Custom Words',
eventType: 1,
triggerMetadata: {
keywordFilter: [Array],
regexPatterns: [Array],
presets: [],
allowList: [Array],
mentionTotalLimit: null,
mentionRaidProtectionEnabled: false
},
actions: [ [Object], [Object], [Object] ],
enabled: true,
exemptRoles: Collection(0) [Map] {},
exemptChannels: Collection(0) [Map] {}
},
'1193716862526169168' => AutoModerationRule {
id: '1193716862526169168',
guild: null,
creatorId: '308272531570425856',
triggerType: 5,
name: 'Block Mention Spam',
eventType: 1,
triggerMetadata: {
keywordFilter: [],
regexPatterns: [],
presets: [],
allowList: [],
mentionTotalLimit: 20,
mentionRaidProtectionEnabled: true
},
actions: [ [Object] ],
enabled: true,
exemptRoles: Collection(0) [Map] {},
exemptChannels: Collection(0) [Map] {}
}
}
Collection(2) [Map] {
'1165052597539967056' => AutoModerationRule {
id: '1165052597539967056',
guild: null,
creatorId: '224188754946949130',
triggerType: 1,
name: 'Block Custom Words',
eventType: 1,
triggerMetadata: {
keywordFilter: [Array],
regexPatterns: [Array],
presets: [],
allowList: [Array],
mentionTotalLimit: null,
mentionRaidProtectionEnabled: false
},
actions: [ [Object], [Object], [Object] ],
enabled: true,
exemptRoles: Collection(0) [Map] {},
exemptChannels: Collection(0) [Map] {}
},
'1193716862526169168' => AutoModerationRule {
id: '1193716862526169168',
guild: null,
creatorId: '308272531570425856',
triggerType: 5,
name: 'Block Mention Spam',
eventType: 1,
triggerMetadata: {
keywordFilter: [],
regexPatterns: [],
presets: [],
allowList: [],
mentionTotalLimit: 20,
mentionRaidProtectionEnabled: true
},
actions: [ [Object] ],
enabled: true,
exemptRoles: Collection(0) [Map] {},
exemptChannels: Collection(0) [Map] {}
}
}
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
So i switched it to get from the cache but that does not fix the issue, both client.guilds.cache and guild.autoModerationRules.cache return what they should but i still get the null.
const guild = client.guilds.cache.get(guildId);
const automodRule = guild.autoModerationRules.cache.get(ruleId);
const result = await automodRule.edit(ruleConfig);
const guild = client.guilds.cache.get(guildId);
const automodRule = guild.autoModerationRules.cache.get(ruleId);
const result = await automodRule.edit(ruleConfig);
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
dang
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
strange
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
so should i be using the cache instead of directly fetching things?
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
logs the 2 rules present in the guild
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
going to go to bed now but if you know anything about this please comment wumplove
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
does a rule.edit() work fine for you?
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
just to add, using things like .setName() also do not work (they just call this.edit() so basically the same thing i am trying to do overall)
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
if anyone else has any ideas i would like to hear
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
yea it returns true
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
this is quite interesting because i am not sure if this is something i can fix hm
40 replies
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
i don't believe so
40 replies