commit
This commit is contained in:
parent
d80a463e55
commit
abc07b2b1b
5 changed files with 180 additions and 109 deletions
|
@ -1,6 +1,5 @@
|
|||
import { Events, Message, Collection, EmbedBuilder, WebhookClient } from "discord.js";
|
||||
import { getChatResponse, MistralMessage, Models, InputPrice, OutputPrice, ReturnedValue, Prompts } from "../libs/mistralai.js";
|
||||
import { User, connectToDb, addUser, getUser, incrementQuota } from "../libs/mysql.js";
|
||||
import { Message, EmbedBuilder, WebhookClient } from "discord.js";
|
||||
import { MistralMessage, Prompts } from "../libs/mistralai.js";
|
||||
|
||||
export function helpEmbed(iconURL: string) {
|
||||
return new EmbedBuilder()
|
||||
|
@ -34,7 +33,7 @@ export function errorEmbed(error: string, iconURL: string) {
|
|||
return new EmbedBuilder()
|
||||
.setTitle("Error")
|
||||
.setDescription(error)
|
||||
.setFooter({ text: "Bot by @ninja_jambon."})
|
||||
.setFooter({ text: "Bot by @ninja_jambon.", iconURL: iconURL})
|
||||
.setColor("#000000");
|
||||
}
|
||||
|
||||
|
@ -42,14 +41,51 @@ export function quotaEmbed(quota: number, iconURL: string) {
|
|||
return new EmbedBuilder()
|
||||
.setTitle("Quota left")
|
||||
.setDescription(`You have ${0.4 - quota}$ left this month.`)
|
||||
.setFooter({ text: "Bot by @ninja_jambon."})
|
||||
.setFooter({ text: "Bot by @ninja_jambon.", iconURL: iconURL})
|
||||
.setColor("#000000");
|
||||
}
|
||||
|
||||
|
||||
export function qotdconfirm(qotd: string, iconURL: string) {
|
||||
return new EmbedBuilder()
|
||||
.setTitle("Confirmation de la QOTD")
|
||||
.setDescription(`Vous êtes sur le point d'envoyer cette question du jour : \n - "${qotd}"\nConfirmez-vous ?`)
|
||||
.setFooter({ text: "Bot by @ninja_jambon.", iconURL: iconURL})
|
||||
.setColor("#000000");
|
||||
}
|
||||
|
||||
export function qotdEmbed(qotd: string, iconURL: string) {
|
||||
return new EmbedBuilder()
|
||||
.setTitle(`Question du jour | ${new Date(Date.now()).toLocaleDateString("fr-FR", {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
})}`)
|
||||
.setDescription(qotd)
|
||||
.setFooter({ text: "Bot by @ninja_jambon.", iconURL: iconURL})
|
||||
.setColor("#000000");
|
||||
}
|
||||
|
||||
export function confirmedQotd(qotd: string, iconURL: string) {
|
||||
return new EmbedBuilder()
|
||||
.setTitle("QOTD envoyée")
|
||||
.setDescription(`Vous avez envoyé cette question du jour : \n - "${qotd}"`)
|
||||
.setFooter({ text: "Bot by @ninja_jambon.", iconURL: iconURL})
|
||||
.setColor("#000000");
|
||||
}
|
||||
|
||||
export function canceledQotd(qotd: string, iconURL: string) {
|
||||
return new EmbedBuilder()
|
||||
.setTitle("QOTD annulée")
|
||||
.setDescription(`Vous n'avez pas envoyé cette question du jour : \n - "${qotd}"`)
|
||||
.setFooter({ text: "Bot by @ninja_jambon.", iconURL: iconURL})
|
||||
.setColor("#000000");
|
||||
}
|
||||
|
||||
export async function getMessages(message: Message, channelid: string, userid: string): Promise<MistralMessage[]> {
|
||||
var discordMessages = await message.channel.messages.fetch({ limit: 7 })
|
||||
discordMessages.filter((m) => m.content && (m.author.id == message.author.id || m.author.id == process.env.BOT_ID))
|
||||
discordMessages.reverse();
|
||||
var filteredMessages = discordMessages.filter(m => m.content && (m.author.id == message.author.id || m.author.id == process.env.BOT_ID))
|
||||
filteredMessages.reverse();
|
||||
|
||||
var messages: MistralMessage[] = [
|
||||
{
|
||||
|
@ -58,7 +94,7 @@ export async function getMessages(message: Message, channelid: string, userid: s
|
|||
}
|
||||
]
|
||||
|
||||
discordMessages.forEach(discordMessage => {
|
||||
filteredMessages.forEach(discordMessage => {
|
||||
messages.push({
|
||||
role: discordMessage.author.id == process.env.BOT_ID ? "assistant" : "user",
|
||||
content: discordMessage.content,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue