-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactionlog.js
99 lines (93 loc) · 3.79 KB
/
actionlog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const { SlashCommandBuilder } = require('@discordjs/builders');
const {MessageEmbed} = require("discord.js")
const langFile = require('../../Language/lang.json')
const profileModel = require('../../Database/schema/profileSchema');
module.exports = {
data: new SlashCommandBuilder()
.setName('actionlog')
.setDescription('Set Server Aciton Log')
.addChannelOption(option =>
option.setName('channel')
.setDescription('Mention The Channel')
.setRequired(true)),
async execute(interaction) {
const server = await profileModel.findOne({
serverId: interaction.guild.id,
});
var logs = interaction.options.getChannel('channel')
if (server.cownerusers.includes(interaction.user.id)) {
if (logs.type === 'GUILD_TEXT') {
logs.createWebhook(' Logger', {
avatar: 'https://media.discordapp.net/attachments/944630667017330728/944630741889859594/logo.png',
}).then(webhook =>
profileModel.findOneAndUpdate(
{
serverId: interaction.guild.id,
},
{
acitonslogs: webhook.url,
}
)
).catch(console.error);
let done = new MessageEmbed()
.setColor('GREEN')
.setDescription(`${langFile[interaction.lang]['actionlogs']}` +`<#${logs.id}>`)
.setFooter(" Logger")
.setTimestamp()
return interaction.reply({
embeds: [done] , ephemeral: true
});
} else {
let err = new MessageEmbed()
.setColor('RED')
.setTitle(`${langFile[interaction.lang]['actiologserr']}`)
.setFooter(" Logger")
.setTimestamp()
return interaction.reply({
embeds: [err] , ephemeral: true
});
}
} else
if (interaction.user.id === interaction.guild.ownerId ) {
if (logs.type === 'GUILD_TEXT') {
logs.createWebhook(' Logger', {
avatar: 'https://media.discordapp.net/attachments/944630667017330728/944630741889859594/logo.png',
}).then(webhook =>
profileModel.findOneAndUpdate(
{
serverId: interaction.guild.id,
},
{
acitonslogs: webhook.url,
}
)
).catch(console.error);
let done = new MessageEmbed()
.setColor('GREEN')
.setDescription(`${langFile[interaction.lang]['actionlogs']}` +`<#${logs.id}>`)
.setFooter(" Logger")
.setTimestamp()
return interaction.reply({
embeds: [done] , ephemeral: true
});
} else {
let err = new MessageEmbed()
.setColor('RED')
.setTitle(`${langFile[interaction.lang]['actiologserr']}`)
.setFooter(" Logger")
.setTimestamp()
return interaction.reply({
embeds: [err] , ephemeral: true
});
}
}
let owneronly = new MessageEmbed()
.setTitle(`You Can't Use This Command!`)
.setDescription(`${langFile[interaction.lang]['permerr']}`)
.setColor('RED')
.setTimestamp()
return interaction.reply({
embeds: [owneronly] , ephemeral: true
});
}
}