-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8033df
commit d6fe8ee
Showing
14 changed files
with
358 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ChannelType, Events } from "discord.js"; | ||
import client from ".."; | ||
import addPermissionsToChannel from "../utils/addPermissionsToChannel"; | ||
|
||
client.on(Events.ChannelCreate, async channel => { | ||
if (channel.type != ChannelType.GuildAnnouncement) return; | ||
await addPermissionsToChannel(channel); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Events, EmbedBuilder, TextChannel } from 'discord.js'; | ||
import client from '../index'; | ||
import { removeGuild } from '../database'; | ||
|
||
client.on(Events.GuildDelete, async guild => { | ||
try { | ||
// Send a message to the logging channel | ||
const embedLoggingChannel = new EmbedBuilder() | ||
.setTitle("Left Guild :<") | ||
.setColor('Blurple') | ||
.setDescription(`Left guild: **${guild.name}**`) | ||
.setThumbnail(guild.iconURL()) | ||
.addFields({ name: 'Guild ID', value: guild.id, inline: true }) | ||
|
||
const loggingChannelId = process.env.DISCORD_LOGGING_CHANNEL; | ||
if (!loggingChannelId) { | ||
throw new Error('DISCORD_LOGGING_CHANNEL environment variable is not defined.'); | ||
} | ||
|
||
const channel = await client.channels.fetch(loggingChannelId) as TextChannel; | ||
await channel?.send({ embeds: [embedLoggingChannel] }); | ||
removeGuild(guild.id); | ||
|
||
} catch (error) { | ||
console.error(`Error when leaving server: ${error}`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { NewsChannel } from "discord.js"; | ||
import client from ".."; | ||
import log from "./log"; | ||
|
||
export default async function addPermissionsToChannel(targetChannel: NewsChannel): Promise<boolean> { | ||
try { | ||
if (client.user) { | ||
await targetChannel.permissionOverwrites.create(client.user.id, { | ||
ManageChannels: true, | ||
ManageMessages: true, | ||
SendMessages: true, | ||
ViewChannel: true, | ||
}) | ||
} | ||
return true; | ||
} catch (error) { | ||
console.error(`Could not add permissions to channel: ${error}`); | ||
log(false, `Could not add permissions to channel: ${error}`); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.