-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
requested changes and updated DB ver
- Loading branch information
1 parent
ff0ed96
commit 3cda94b
Showing
9 changed files
with
135 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { GuildMember, DMChannel } from "discord.js"; | ||
import { textLog } from "../../../common/moderator"; | ||
import Tools from "../../../common/tools"; | ||
import { logger, handleReactionTimeout, emojiCollector } from "../common"; | ||
|
||
export const addBreakRole = async ( | ||
member: GuildMember, | ||
dmChannel: DMChannel | ||
) => { | ||
const confirmationMessage = await dmChannel.send( | ||
"It looks like you want a little break! It is understandable you can get it by clicking on the :sloth: emoji below. You can send me !menu again to remove it.\n**Be advised: You can only use the sloth emoji to toggle your break role every 24 hours**" | ||
); | ||
|
||
const breakRole = Tools.getRoleByName("Break", member.guild); | ||
await confirmationMessage.react("🦥"); | ||
|
||
const reaction = await emojiCollector(confirmationMessage); | ||
|
||
if (!reaction) { | ||
await handleReactionTimeout(confirmationMessage, dmChannel); | ||
return; | ||
} | ||
|
||
try { | ||
await confirmationMessage.delete(); | ||
await member.roles.add(breakRole); | ||
await dmChannel.send("Enjoy your break!"); | ||
return; | ||
} catch (e) { | ||
logger.error("Failed to add break role", e); | ||
await textLog(`I could not give <@${member.id}> the break role!`); | ||
await dmChannel.send( | ||
"Looks like I couldn't give you the break role, I informed the Support team about it, in the meantime you can manually ask one of the Moderators!" | ||
); | ||
return; | ||
} | ||
}; |
This file was deleted.
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
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,53 @@ | ||
import { UsersOnBreak } from "@yes-theory-fam/database/client"; | ||
import { GuildMember, DMChannel } from "discord.js"; | ||
import { textLog } from "../../../common/moderator"; | ||
import Tools from "../../../common/tools"; | ||
import { | ||
isCooldownDone, | ||
emojiCollector, | ||
logger, | ||
handleReactionTimeout, | ||
} from "../common"; | ||
|
||
export const removeBreakRole = async ( | ||
member: GuildMember, | ||
userData: UsersOnBreak, | ||
dmChannel: DMChannel | ||
) => { | ||
const checkTime = await isCooldownDone(userData); | ||
|
||
if (!checkTime) { | ||
await dmChannel.send( | ||
"I'm sorry it hasn't been 24 hours since you used this command! If you really want the break role removed you can contact one of our moderators!" | ||
); | ||
return; | ||
} | ||
|
||
const breakRole = Tools.getRoleByName("Break", member.guild); | ||
const confirmationMessage = await dmChannel.send( | ||
"It looks like you're ready to rejoin the server! Once you're ready click on the green check below!" | ||
); | ||
await confirmationMessage.react("✅"); | ||
|
||
const reaction = await emojiCollector(confirmationMessage); | ||
|
||
if (!reaction) { | ||
await handleReactionTimeout(confirmationMessage, dmChannel); | ||
return; | ||
} | ||
|
||
try { | ||
await member.roles.remove(breakRole); | ||
await dmChannel.send( | ||
"Your break role was removed, we're happy to have you back!" | ||
); | ||
return; | ||
} catch (e) { | ||
logger.error("Failed to remove break role", e); | ||
await textLog(`I could not remove <@${member.id}> break role!`); | ||
await dmChannel.send( | ||
"Looks like I had a little hiccup trying to remove your role, I've contacted Support about your little issue! Sorry in advance." | ||
); | ||
return; | ||
} | ||
}; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DMChannel, GuildMember } from "discord.js"; | ||
import { isOnBreak } from "../common"; | ||
import { addBreakRole } from "./add-break"; | ||
import { removeBreakRole } from "./remove-break"; | ||
|
||
export const breakToggle = async ( | ||
member: GuildMember, | ||
dmChannel: DMChannel | ||
) => { | ||
const userOnBreak = await isOnBreak(member.id); | ||
|
||
if (userOnBreak) { | ||
await removeBreakRole(member, userOnBreak, dmChannel); | ||
return; | ||
} | ||
|
||
await addBreakRole(member, dmChannel); | ||
}; |
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
File renamed without changes.