-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Joehoel/v13
Compagnon v2.0
- Loading branch information
Showing
57 changed files
with
995 additions
and
380 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,13 @@ | ||
TOKEN= | ||
CLIENT_ID= | ||
PREFIX= | ||
PORT= | ||
API_KEY= | ||
MONGO_URI= | ||
NODE_ENV= | ||
DATABASE_URL= | ||
NODE_TLS_REJECT_UNAUTHORIZED= | ||
COOKIE= | ||
GENIUS_TOKEN= | ||
REDIS_PATH= | ||
REDIS_KEY_PREFIX= |
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,39 @@ | ||
import { wait } from "@/lib/helpers"; | ||
import SlashCommand, { CommandType } from "@/modules/SlashCommand"; | ||
import { Message, TextChannel } from "discord.js"; | ||
|
||
export default new SlashCommand({ | ||
name: "clear", | ||
description: "Clear the chat", | ||
options: [ | ||
{ | ||
name: "amount", | ||
type: CommandType.NUMBER, | ||
required: true, | ||
description: "Amount of messages to clear from the chat", | ||
}, | ||
], | ||
async execute(interaction) { | ||
const amount = interaction.options.getNumber("amount")!; | ||
|
||
if (amount > 101) { | ||
return interaction.reply({ content: "You can`t delete more than 100 messages at once!", ephemeral: true }); | ||
} | ||
|
||
if (amount < 1) { | ||
return interaction.reply({ content: "You have to delete at least 1 message!", ephemeral: true }); | ||
} | ||
|
||
await interaction.channel!.messages.fetch({ limit: amount }).then((messages) => { | ||
(interaction.channel as TextChannel).bulkDelete(messages); | ||
}); | ||
|
||
const message = (await interaction.reply({ | ||
content: `Successfully deleted **${amount}** messages!`, | ||
fetchReply: true, | ||
})) as Message; | ||
|
||
await wait(2000); | ||
return message.delete(); | ||
}, | ||
}); |
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,41 @@ | ||
import { USERS } from "@/lib/contants"; | ||
import { embed } from "@/lib/helpers"; | ||
import SlashCommand, { CommandType } from "@/modules/SlashCommand"; | ||
|
||
export default new SlashCommand({ | ||
name: "answer", | ||
description: "Answer the question of the day", | ||
options: [ | ||
{ | ||
name: "answer", | ||
description: "The answer to the question", | ||
type: CommandType.STRING, | ||
required: true, | ||
}, | ||
], | ||
async execute(interaction) { | ||
const author = interaction.user; | ||
|
||
// Get answer from the interaction | ||
const answer = interaction.options.getString("answer")!; | ||
|
||
// Reply to only the user that submitted the answer | ||
interaction.reply({ ephemeral: true, content: answer }); | ||
|
||
// TODO: Change to USERS.JESSE | ||
const member = await interaction.client.users.fetch(USERS.JESSE); | ||
|
||
// Send answer to Jesse | ||
await member.send({ | ||
embeds: [ | ||
embed({ | ||
description: answer, | ||
author: { | ||
name: author.username, | ||
iconURL: author.displayAvatarURL() ?? author.defaultAvatarURL, | ||
}, | ||
}), | ||
], | ||
}); | ||
}, | ||
}); |
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,12 @@ | ||
import SlashCommand, { CommandType } from "@/modules/SlashCommand"; | ||
|
||
export default new SlashCommand({ | ||
name: "avatar", | ||
description: "Get the avatar URL of the selected user, or your own avatar.", | ||
options: [{ name: "target", description: "The user's avatar to show", type: CommandType.USER }], | ||
execute(interaction) { | ||
const user = interaction.options.getUser("target"); | ||
if (user) return interaction.reply(`${user.username}'s avatar: ${user.displayAvatarURL({ dynamic: true })}`); | ||
return interaction.reply(`Your avatar: ${interaction.user.displayAvatarURL({ dynamic: true })}`); | ||
}, | ||
}); |
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,11 @@ | ||
import { gif } from "@/lib/helpers"; | ||
import SlashCommand from "@/modules/SlashCommand"; | ||
|
||
export default new SlashCommand({ | ||
name: "dab", | ||
description: "Sends a random dab gif in chat", | ||
async execute(interaction) { | ||
const url = await gif("dab"); | ||
interaction.reply(url); | ||
}, | ||
}); |
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,13 @@ | ||
import { gif } from "@/lib/helpers"; | ||
import SlashCommand, { CommandType } from "@/modules/SlashCommand"; | ||
|
||
export default new SlashCommand({ | ||
name: "gif", | ||
description: "Sends a random GIF in chat", | ||
options: [{ name: "tag", description: "Tag to search a gif for", type: CommandType.STRING, required: true }], | ||
async execute(interaction) { | ||
const tag = interaction.options.getString("tag")!; | ||
const url = await gif(tag); | ||
interaction.reply(url); | ||
}, | ||
}); |
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,26 @@ | ||
import Reddit from "@/lib/reddit"; | ||
import SlashCommand, { CommandType } from "@/modules/SlashCommand"; | ||
import { MessageEmbed } from "discord.js"; | ||
|
||
export default new SlashCommand({ | ||
name: "meme", | ||
description: "Shows a random lit meme from the provided subreddit (defaults to 'r/dankmemes')", | ||
options: [{ name: "sub", description: "subreddit", type: CommandType.STRING, required: false }], | ||
async execute(interaction) { | ||
const subreddit = interaction.options.getString("sub") ?? "dankmemes"; | ||
|
||
const reddit = new Reddit(subreddit); | ||
const { title, url, date, author, sub, link } = await reddit.getRandomHotPost(); | ||
|
||
const embed = new MessageEmbed() | ||
.setColor("#ffc600") | ||
.setTitle(title) | ||
.setDescription(sub) | ||
.setFooter(author) | ||
.setURL(link) | ||
.setImage(url) | ||
.setTimestamp(date); | ||
|
||
return interaction.reply({ embeds: [embed] }); | ||
}, | ||
}); |
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,28 @@ | ||
import { embed } from "@/lib/helpers"; | ||
import SlashCommand from "@/modules/SlashCommand"; | ||
import { Message } from "discord.js"; | ||
|
||
export default new SlashCommand({ | ||
name: "ping", | ||
description: "Pong!", | ||
async execute(interaction) { | ||
const message = (await interaction.reply({ | ||
embeds: [ | ||
embed({ | ||
description: `**Pong!**`, | ||
}), | ||
], | ||
fetchReply: true, | ||
})) as Message; | ||
|
||
const ping = message.createdTimestamp - interaction.createdTimestamp!; | ||
|
||
await message.edit({ | ||
embeds: [ | ||
embed({ | ||
description: `**Pong!** \`${ping}ms\``, | ||
}), | ||
], | ||
}); | ||
}, | ||
}); |
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,109 @@ | ||
import { embed } from "@/lib/helpers"; | ||
import SlashCommand, { CommandType } from "@/modules/SlashCommand"; | ||
import { SlashCommandOptionBase } from "@discordjs/builders/dist/interactions/slashCommands/mixins/CommandOptionBase"; | ||
import { Interaction, Message } from "discord.js"; | ||
|
||
const options = [ | ||
"🇦", | ||
"🇧", | ||
"🇨", | ||
"🇩", | ||
"🇪", | ||
"🇫", | ||
"🇬", | ||
"🇭", | ||
"🇮", | ||
"🇯", | ||
"🇰", | ||
"🇱", | ||
"🇲", | ||
"🇳", | ||
"🇴", | ||
"🇵", | ||
"🇶", | ||
"🇷", | ||
"🇸", | ||
"🇹", | ||
"🇺", | ||
"🇻", | ||
"🇼", | ||
"🇽", | ||
"🇾", | ||
"🇿", | ||
]; | ||
|
||
const pollLog: { [userId: string]: { lastPoll: number } } = {}; | ||
|
||
function canSendPoll(userId: string): boolean { | ||
if (pollLog[userId]) { | ||
const timeSince = Date.now() - pollLog[userId].lastPoll; | ||
if (timeSince < 30000) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
export default new SlashCommand({ | ||
name: "poll", | ||
description: "Create a poll where people can react to vote", | ||
options: [ | ||
{ name: "question", description: "question", type: CommandType.STRING }, | ||
{ | ||
name: "answer_1", | ||
description: "optional answer", | ||
required: false, | ||
type: CommandType.STRING, | ||
}, | ||
{ | ||
name: "answer_2", | ||
description: "optional answer", | ||
required: false, | ||
type: CommandType.STRING, | ||
}, | ||
{ | ||
name: "answer_3", | ||
description: "optional answer", | ||
required: false, | ||
type: CommandType.STRING, | ||
}, | ||
{ | ||
name: "answer_4", | ||
description: "optional answer", | ||
required: false, | ||
type: CommandType.STRING, | ||
}, | ||
{ | ||
name: "answer_5", | ||
description: "optional answer", | ||
required: false, | ||
type: CommandType.STRING, | ||
}, | ||
{ | ||
name: "answer_6", | ||
description: "optional answer", | ||
required: false, | ||
type: CommandType.STRING, | ||
}, | ||
], | ||
async execute(interaction) { | ||
const question = interaction.options.getString("question"); | ||
const author = interaction.user; | ||
|
||
const message = (await interaction.reply({ | ||
embeds: [ | ||
embed({ | ||
title: `${question}`, | ||
footer: { | ||
text: `Poll started by: ${author.username}`, | ||
iconURL: author.avatarURL()!, | ||
}, | ||
}), | ||
], | ||
fetchReply: true, | ||
})) as Message; | ||
await message.react("👍"); | ||
await message.react("👎"); | ||
await message.react("🤷♀️"); | ||
}, | ||
}); |
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
Oops, something went wrong.