Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit 89e4b54

Browse files
committed
Merge branch 'dev'
2 parents b777369 + 19ed660 commit 89e4b54

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

Util/Moderation.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ async function ban(interaction, member, reason = "No reason provided", joke = fa
4444
type: "ban",
4545
});
4646

47-
let logChannel = await interaction.guild.channels.fetch(logCha)
48-
await logChannel.send({ embeds: [logEmbed] }).catch(console.error)
47+
let logChannel = await interaction.client.channels.fetch(logCha).catch(e => { })
48+
if (logChannel) await logChannel.send({ embeds: [logEmbed] }).catch(console.error)
4949
}
5050
}
5151
interaction.followUp({ embeds: [replyEmbed] }).catch(console.error)
@@ -95,8 +95,8 @@ async function kick(interaction, member, reason = "No reason provided", joke = f
9595
type: "kick",
9696
});
9797

98-
let logChannel = await interaction.guild.channels.fetch(logCha)
99-
await logChannel.send({ embeds: [logEmbed] })
98+
let logChannel = await interaction.client.channels.fetch(logCha).catch(e => { })
99+
if (logChannel) await logChannel.send({ embeds: [logEmbed] })
100100
}
101101
}
102102
interaction.followUp({ embeds: [replyEmbed] })
@@ -136,34 +136,42 @@ async function warn(interaction, user, reason, joke = false, db) {
136136

137137
logEmbed.setAuthor({ name: `Case ${dbcr.id} | Warn | ${user.tag} | ${user.id}`, iconURL: (avatar ? avatar : undefined) })
138138

139-
let logChannel = await interaction.guild.channels.fetch(logCha)
140-
await logChannel.send({ embeds: [logEmbed] })
139+
let logChannel = await interaction.client.channels.fetch(logCha).catch(e => { })
140+
if (logChannel) await logChannel.send({ embeds: [logEmbed] })
141141
};
142142

143143
await user.send({ embeds: [dmEmbed] }).catch(e => { console.error(`Couldn't message ${user.tag} (warn)`) })
144144
await interaction.followUp({ embeds: [replyEmbed] })
145145
}
146146

147-
async function timeout(interaction, member, reason, unit, RealLen, joke = false, db) {
147+
async function timeout(interaction, member, reason = "No reason provided", unit, RealLen, joke = false, db) {
148148
let length = RealLen;
149-
if (reason == undefined) {
150-
reason = "No reason provided"
151-
}
152149

153150
if (!(member instanceof GuildMember)) {
154151
member = await interaction.guild.members.fetch(member)
155152
}
156153

157154
const replyEmbed = new EmbedBuilder()
158155
.setColor("#43b582")
156+
const avatar = await member.user.avatarURL({ extention: 'png', size: 4096 })
157+
const logEmbed = new EmbedBuilder()
158+
.setAuthor({ name: `Case idk | Timeout | ${member.user.tag} | ${member.user.id}`, iconURL: (avatar ? avatar : undefined) })
159+
.setColor("#f04a47")
160+
.setTimestamp(new Date())
161+
.addFields(
162+
{ name: "**User**", value: escapeMarkdown(member.user.tag), inline: true },
163+
{ name: "**Moderator**", value: escapeMarkdown(interaction.user.tag), inline: true },
164+
{ name: "**Reason**", value: reason, inline: true }
165+
);
166+
159167

160168
if (reason !== "No reason provided") {
161169
replyEmbed.setDescription(`**${escapeMarkdown(member.user.tag)} has been timed out for ${RealLen} ${unit} for "${reason}".**`);
162170
}
163171
else if (reason === "No reason provided") {
164172
replyEmbed.setDescription(`**${escapeMarkdown(member.user.tag)} has been timed out for ${RealLen} ${unit}.**`)
165173
}
166-
174+
167175
if (member.user.id === interaction.client.user.id) {
168176
if (reason === "No reason provided") {
169177
replyEmbed.setDescription(`Timed out undefined for ${RealLen} ${unit}`)
@@ -194,12 +202,17 @@ async function timeout(interaction, member, reason, unit, RealLen, joke = false,
194202
else if (length <= 2.4192e+9) {
195203
if (!joke) {
196204
member.timeout(length, reason + "| Timeout by" + interaction.user.tag).then(async () => {
197-
db.create({
205+
let dbcr = await db.create({
198206
type: "timeout",
199207
reason: reason,
200208
Executor: interaction.user.tag,
201209
userID: member.user.id
202210
})
211+
212+
logEmbed.setAuthor({ name: `Case ${dbcr.id} | Timeout | ${member.user.tag} | ${member.user.id}`, iconURL: (avatar ? avatar : undefined) })
213+
214+
let logChannel = await interaction.client.channels.fetch(logCha).catch(e => { })
215+
if (logChannel) await logChannel.send({ embeds: [logEmbed] })
203216
await interaction.followUp({ embeds: [replyEmbed] })
204217
}).catch(err => { console.error(err); replyEmbed.setDescription(`Couldn't timeout ${escapeMarkdown(member.user.tag)}: \`\`\`${err}\`\`\``); replyEmbed.setColor("#ff0000"); return interaction.followUp({ embeds: [replyEmbed] }) })
205218
}

0 commit comments

Comments
 (0)