init commit

This commit is contained in:
Jill 2022-06-07 23:28:20 +00:00
commit 3c0b1c31a2
10 changed files with 1468 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
survey-responses/*
config.json
next.json
node_modules

101
commands/change.js Normal file
View File

@ -0,0 +1,101 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { CommandInteraction, GuildMember, MessageActionRow, MessageEmbed } = require('discord.js');
const rand = [
'This change has no significance.',
'You do not know what this can do.',
'Nothing has changed.',
'Nothing of value has been changed.',
'You\'ll want to find something of value to change next time.'
];
const names = [
'Fire\'s Pit',
'Flaming Pit',
'Pit of Fire',
'Pit Fire',
'Pire Fit',
'White Space',
'The void',
'Fire pit',
'fire pit'
];
const channels = [
'toyota',
'ъ',
'deadlocked',
'stereo-madness',
'basketball',
'send-help'
];
const nicknames = [
'напиток безалкогольный сильногаз',
'forg',
'foggy',
'frog',
'fog'
]
module.exports = {
data: new SlashCommandBuilder()
.setName('change')
.setDescription('Change')
.addStringOption((option) => option.setName('what').setDescription('Change what? Examples include: "environment", "perspective", etc...').setRequired(true)),
/**
*
* @param {CommandInteraction} interaction
* @param {GuildMember} member
*/
execute: async (interaction, member) => {
let what = interaction.options.getString('what');
let title = `**${member.displayName}** changed the **${what}**`;
let response;
switch (what.toLowerCase()) {
case 'environment':
case 'surroundings':
const name = names[Math.floor(Math.random() * names.length)];
response = `You feel as if you're in a new space entirely. You find yourself in **${name}**.`;
await interaction.guild.setName(name, 'environment change');
break;
case 'perspective':
case 'vision':
const channel = channels[Math.floor(Math.random() * channels.length)];
response = `You've decided you want to change your perspective on the place you find yourself in. You are now in **#${channel}**.`;
await interaction.channel.setName(channel);
break;
case 'persona':
case 'self':
title = 'I\'m afraid I can\'t do that.';
response = `You're locked in as is, **${member.user.username}**. Noone but you can change this.`;
break;
case 'identity':
response = `I've changed my nickname in accordance. I hope this identity pleases you.`;
await interaction.guild.me.setNickname(nicknames[Math.floor(Math.random() * nicknames.length)]);
break;
case 'location':
case 'position':
response = `You do not feel like your surroundings have changed, but rather where you are relative to your surroundings has changed.`;
const categories = Array(...interaction.guild.channels.cache.filter(v => v.type === 'GUILD_CATEGORY').values());
const category = categories[Math.floor(Math.random() * categories.length)];
await interaction.channel.setParent(category);
await interaction.channel.setPosition(Math.floor(Math.random() * category.children.size));
break;
default:
response = rand[Math.floor(Math.random() * rand.length)];
}
const embed = new MessageEmbed()
.setTitle(title)
.setDescription(response)
.setTimestamp();
await interaction.reply({
embeds: [embed],
ephemeral: false,
});
}
}

76
commands/investigate.js Normal file
View File

@ -0,0 +1,76 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { CommandInteraction, GuildMember, MessageActionRow, MessageEmbed } = require('discord.js');
const rand = require('random-seed').create();
const results = [
['Vigilante', 'Veteran', 'Mafioso', 'Ambusher'],
['Medium', 'Janitor', 'Retributionist'],
['Survivor', 'Vampire Hunter', 'Amnesiac'],
['Spy', 'Blackmailer', 'Jailor'],
['Sheriff', 'Executioner', 'Werewolf'],
['Framer', 'Vampire', 'Jester'],
['Lookout', 'Forger', 'Witch'],
['Escort', 'Transporter', 'Consort', 'Hypnotist'],
['Doctor', 'Disguiser', 'Serial Killer'],
['Investigator', 'Consigliere', 'Mayor'],
['Bodyguard', 'Godfather', 'Arsonist']
];
function seperate(l) {
return l.slice(0, -1).join(', ') + ' or ' + l.slice(-1);
}
module.exports = {
data: new SlashCommandBuilder()
.setName('investigate')
.setDescription('Investigate someone.')
.addUserOption((option) => option.setName('who').setDescription('Investigate who?').setRequired(true))
.addBooleanOption((option) => option.setName('sheriff').setDescription('Switch to Sheriff-style investigation').setRequired(false)),
/**
*
* @param {CommandInteraction} interaction
* @param {GuildMember} member
*/
execute: async (interaction, member) => {
let who = interaction.options.getUser('who');
let sheriff = interaction.options.getBoolean('sheriff');
let response;
let color;
if (who.id === member.id) {
response = `You decided to investigate yourself tonight. The only thing you've found out this night is that this is a waste of time.`;
color = 0x333333;
} else {
if (sheriff) {
rand.seed(who.id);
const good = rand.random() > 0.4;
if (good) {
response = `You decided to investigate **${who.username}** tonight.\n_You cannot find evidence of wrongdoing. Your target seems innocent._`
color = 0x55ff55;
} else {
response = `You decided to investigate **${who.username}** tonight.\n_Your target is suspicious!_`
color = 0xff3333;
}
} else {
rand.seed(who.id);
let result = results[rand.range(results.length)];
response = `You decided to investigate **${who.username}** tonight.\nYour target could be a ${seperate(result.map(r => '**' + r + '**'))}.`;
color = 0x444444;
}
}
const embed = new MessageEmbed()
.setDescription(response)
.setAuthor({
name: `${member.displayName} the ${sheriff ? 'Sheriff' : 'Investigator'}`,
iconURL: member.displayAvatarURL()
})
.setColor(color);
await interaction.reply({
embeds: [embed],
ephemeral: true,
});
}
}

121
commands/monitor.js Normal file
View File

@ -0,0 +1,121 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { CommandInteraction, GuildMember, MessageActionRow, MessageEmbed } = require('discord.js');
const rand = require('random-seed').create();
const images = [
'img1',
'img2',
'img3',
'img4',
'img5',
'img7',
'img8',
'img9',
'img10',
'img11',
'img12',
'img14',
'img15',
'img16',
'img17',
'img19',
'img20'
];
module.exports = {
data: new SlashCommandBuilder()
.setName('monitor')
.setDescription('Monitor')
.addStringOption((option) => option.setName('what').setDescription('Monitor what? Examples include: "lobby", "bedroom", "park", "playground", etc...').setRequired(true)),
/**
*
* @param {CommandInteraction} interaction
* @param {GuildMember} member
*/
execute: async (interaction, member) => {
let img;
let what = interaction.options.getString('what');
if (what.startsWith('the ')) what = what.slice(4);
switch (what.toLowerCase().trim()) {
case 'home':
img = 'img12';
break;
case 'hell':
img = 'img4';
break;
case 'fire pit':
img = 'img4';
break;
case 'party':
img = 'img23';
break;
case 'lobby':
img = 'img22';
break;
case 'rollercoaster':
case 'park':
case 'amusement park':
img = 'img13';
break;
case 'pit':
case 'hole':
img = 'img21';
break;
case 'forest':
img = 'img18';
break;
case 'slide':
case 'metal slide':
case 'playground':
img = 'img6';
break;
case 'staircase':
img = 'img3';
break;
case 'security':
case 'security footage':
case 'camera':
img = 'img12';
break;
case 'lobby':
img = 'img19';
break;
case 'bedroom':
img = 'img20';
break;
case 'bathroom':
img = 'img10';
break;
case 'living room':
case 'livingroom':
img = 'img15';
break;
case 'store':
case 'shop':
img = 'img11';
break;
case 'void':
case 'darkness':
case 'emptiness':
img = 'img16';
break;
default:
rand.seed(what.toLowerCase().trim());
img = images[rand.range(images.length)];
break;
}
const embed = new MessageEmbed()
.setTitle(what)
.setImage(`https://oat.zone/f/monitor-images/${img}.png`)
.setFooter('Image may not always be accurate.')
.setTimestamp();
await interaction.reply({
embeds: [embed],
ephemeral: false,
});
}
}

727
commands/survey.js Normal file
View File

@ -0,0 +1,727 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { CommandInteraction, GuildMember, MessageActionRow, MessageEmbed, MessageButton, Client, Collection, MessageComponentInteraction, MessageSelectMenu, Modal, TextInputComponent } = require('discord.js');
const fs = require('fs/promises');
const { inspect } = require('util');
const SURVEY_CHANNEL = '983479509376434216';
const RESPONSES_CHANNEL = '983762973858361364';
const GENERAL_CHANNEL = '587108210683412493';
const ephemeral = true;
function extendOptions(opt) {
return opt.map(t => ({label: t, value: t.toLowerCase().replace(/[^a-z0-9-]/g, '-')}));
}
function makeid(length) {
let result = '';
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
const survey = [
{},
{
text: 'What is your name?',
textResponse: true,
id: 'survey-name'
},
{
text: 'Your pronouns?',
components: [
new MessageSelectMenu()
.setCustomId('survey-pronouns')
.setOptions([
{
label: 'he/him',
value: 'he-him'
},
{
label: 'she/her',
value: 'she-her'
},
{
label: 'they/them',
value: 'they-them'
},
{
label: 'it/it',
value: 'it-it'
},
{
label: 'Other',
value: 'other',
description: 'You\'ll be able to specify later.'
}
])
.setMinValues(1)
.setMaxValues(5)
]
},
{
text: 'What are your interests/hobbies?',
textResponse: true,
id: 'survey-interests',
style: 'PARAGRAPH'
},
{
text: 'What do you see in this image?\nhttps://cdn.discordapp.com/attachments/789023763396165633/983471779060281364/unknown.png',
textResponse: true,
id: 'survey-image',
style: 'PARAGRAPH'
},
{
text: 'Which of the following game genres are you currently interested in?',
components: [
new MessageSelectMenu()
.setCustomId('survey-genre')
.setOptions([
{
label: 'FPS',
value: 'fps'
},
{
label: 'Strategy',
value: 'strategy'
},
{
label: 'Platformer',
value: 'platformer'
},
{
label: 'Rhythm Game',
value: 'rhythm-game'
},
{
label: 'Puzzle',
value: 'puzzle'
},
{
label: 'Shoot-em-up',
value: 'shmup'
}
])
.setMinValues(1)
.setMaxValues(6)
]
},
{
text: 'Favorite color?',
textResponse: true,
id: 'survey-color1',
placeholder: 'Red, orange, etc...'
},
{
text: 'Which of these music artists do you listen to?',
components: [
new MessageSelectMenu()
.setCustomId('survey-artist')
.setOptions([
{
label: 'Mr. Bill',
value: 'mr-bill'
},
{
label: 'Virtual Riot',
value: 'virtual-riot'
},
{
label: 'Mr. Beast',
value: 'mr-beast'
}
])
.setMinValues(1)
.setMaxValues(3)
]
},
{
text: 'What time is it currently?',
textResponse: true,
id: 'survey-time'
},
{
text: 'Did you provide the correct time?',
components: [
new MessageButton().setCustomId('survey-time-correct-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-time-correct-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Favorite color?',
components: [
new MessageSelectMenu()
.setCustomId('survey-color2')
.setOptions([
{
label: 'Chair',
value: 'chair'
},
{
label: 'Lithium',
value: 'lithium'
},
{
label: 'Read a => String -> a',
value: 'read-signature'
},
{
label: 'Option 3',
value: 'option3'
}
])
.setMinValues(1)
.setMaxValues(4)
]
},
{
text: 'How many amperes have you had pushed into your heart at once in your lifetime?',
components: [
new MessageSelectMenu()
.setCustomId('survey-heart')
.setOptions([
{
label: '1',
value: 'one'
},
{
label: '2',
value: 'two'
},
{
label: '3',
value: 'three'
},
{
label: '4',
value: 'four'
},
{
label: '5',
value: 'five'
}
])
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Are you afraid of the dark?',
components: [
new MessageButton().setCustomId('survey-dark-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-dark-no').setLabel('No').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-dark-maybe').setLabel('Maybe').setStyle('PRIMARY')
]
},
{
text: `Which of these statements on morality do you most resonate with?\nA. Morality is a science which can be understood. There are inherent moral truths in the world.\nB. There does not exist a moral reality, but only perceptions on what is good or bad.`,
components: [
new MessageButton().setCustomId('survey-morality-a').setLabel('A').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-morality-b').setLabel('B').setStyle('PRIMARY')
]
},
{
text: 'How long ago did you last go on a bridge?',
components: [
new MessageSelectMenu()
.setCustomId('survey-bridge')
.setOptions(extendOptions(['A day ago', 'A week ago', 'A month ago', 'Several months ago', 'A year ago', 'Don\'t remember/Earlier']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Are you afraid of death?',
components: [
new MessageSelectMenu()
.setCustomId('survey-death')
.setOptions(extendOptions(['Yes', 'No', 'Maybe', 'Death is just a step to a different world']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'What is your current heartrate?',
textResponse: true,
id: 'survey-heartrate',
placeholder: '90BPM, 120BPM, etc...'
},
{
text: 'You are operating a railroad track.\nA train is rapidly coming towards a track with 5 people strapped to the rails, unable to move. You are able to redirect the train onto another track, which has one person strapped to it. Do you make the switch and kill the one person, or do nothing and let the 5 people die?',
components: [
new MessageButton().setCustomId('survey-railroad1-switch').setLabel('Switch').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-railroad1-no').setLabel('Do not').setStyle('PRIMARY')
]
},
{
text: 'Which region do you live in?',
components: [
new MessageSelectMenu()
.setCustomId('survey-region')
.setOptions(extendOptions(['Europe', 'Asia', 'North America', 'South America', 'Moscow River', 'Africa', 'Oceania']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Select the character you resonate with the most.',
components: [
new MessageSelectMenu()
.setCustomId('survey-character')
.setOptions([
{
label: '⯧',
value: 'a'
},
{
label: '▩',
value: 'b'
},
{
label: '',
value: 'c'
},
{
label: '∵',
value: 'd'
},
{
label: '⨆',
value: 'e'
}])
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Which of these statements describe you the best?',
components: [
new MessageSelectMenu()
.setCustomId('survey-statement')
.setOptions(extendOptions(['Is that a cut on your face, or part of your eye?', 'The gash weaves down as if you cry', 'The pain itself is reason why']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'When was the last time you experienced a power surge?',
components: [
new MessageSelectMenu()
.setCustomId('survey-power-surge')
.setOptions(extendOptions(['A day ago', 'A week ago', 'A month ago', 'Several months ago', 'A year ago', 'Don\'t remember/Earlier']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Have you ever shown any interest in automobiles and cars?',
components: [
new MessageButton().setCustomId('survey-cars1-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-cars1-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'You are operating a railroad track.\nA person is strapped to the rails unable to move, however there is a fork right before that splits off to a different track with no people. Do you switch to save the person?',
components: [
new MessageSelectMenu()
.setCustomId('survey-railroad2')
.setOptions([
{
label: 'Yes',
value: 'yes'
},
{
label: 'Bloodshed',
value: 'bloodshed',
description: 'The correct choice'
}
])
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Have you been here before?',
components: [
new MessageButton().setCustomId('survey-been-here-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-been-here-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Please provide your social media accounts.',
textResponse: true,
id: 'survey-socialmedia',
style: 'PARAGRAPH',
placeholder: 'Twitter, YouTube, etc. Please provide as many as possible.'
},
{
text: 'Is your refrigerator running?',
components: [
new MessageButton().setCustomId('survey-fridge-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-fridge-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Do you generally feel unsafe in your life?',
noNumber: true,
components: [
new MessageSelectMenu()
.setCustomId('survey-unsafe')
.setOptions(extendOptions(['Yes', 'No', 'Sometimes']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'train',
components: [
new MessageSelectMenu()
.setCustomId('survey-train')
.setOptions(extendOptions(['Option 1', 'Option 2']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Do you live on planet Earth?',
components: [
new MessageButton().setCustomId('survey-earth-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-earth-no').setLabel('No').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-earth-maybe').setLabel('Maybe~ ;3').setStyle('PRIMARY')
]
},
{
text: 'Do you own a credit or debit card?',
components: [
new MessageButton().setCustomId('survey-credit-card-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-credit-card-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'You are operating a railroad track.\nYou will be alone on your shift this night, with no one to watch, leaving you with a perfect opportunity to strap an explosive on one of the tracks. Do you cause a horrible accident resulting in the deaths of thousands?',
components: [
new MessageButton().setCustomId('survey-railroad3-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-railroad3-option-2').setLabel('Option 2').setStyle('PRIMARY')
]
},
{
text: 'Please click on the button when you\'re finished watching the video.\nhttps://www.youtube.com/watch?v=FsTCet79i2k',
components: [
new MessageButton().setCustomId('survey-finished').setLabel('Done').setStyle('PRIMARY')
]
},
{
text: 'Which of these natural landmarks is your favorite?',
components: [
new MessageSelectMenu()
.setCustomId('survey-landmark')
.setOptions(extendOptions(['Darvaza Gas Crater', 'Nazca Lines', 'Bermuda Triangle', 'The Hole']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Have you ever shown any interest in automobiles and cars?',
components: [
new MessageButton().setCustomId('survey-cars2-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-cars2-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Are you operating a railroad track?',
components: [
new MessageButton().setCustomId('survey-railroad4-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-railroad4-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Please explain why/why not.',
textResponse: true,
id: 'survey-railroad4-why',
style: 'PARAGRAPH'
},
{
text: 'Were you telling the truth in your previous 2 anwsers?',
components: [
new MessageButton().setCustomId('survey-railroad4-truth-yes').setLabel('Yes').setStyle('PRIMARY'),
new MessageButton().setCustomId('survey-railroad4-truth-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Please rate your experience with this survey.',
noNumber: true,
components: [
new MessageSelectMenu()
.setCustomId('survey-rating')
.setOptions(extendOptions(['1 ⭐', '2 ⭐⭐', '3 ⭐⭐⭐', '4 ⭐⭐⭐⭐', '5 ⭐⭐⭐⭐⭐']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'What is your opinion on mycology?',
noNumber: true,
textResponse: true,
id: 'survey-mycology',
style: 'PARAGRAPH'
},
{
text: 'Do you like mushrooms as a concept?',
noNumber: true,
components: [
new MessageButton().setCustomId('survey-closer6').setLabel('Yes.').setStyle('SUCCESS')
]
},
{
text: 'Do you like how mushrooms grow and expand?',
noNumber: true,
components: [
new MessageButton().setCustomId('survey-closer7').setLabel('Yes.').setStyle('SUCCESS')
]
},
{
text: 'Would you become a stepping stone for mushrooms to grow and expand?',
noNumber: true,
components: [
new MessageButton().setCustomId('survey-closer8').setLabel('YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES').setStyle('SUCCESS')
]
}
]
const surveyProgress = new Collection();
const surveyInteractions = new Collection();
const surveyAnwsered = new Collection();
const surveyAnwsers = new Collection();
const surveyCurrentMessage = new Collection();
function pushResponse(resp, userId) {
const i = surveyProgress.get(userId);
const question = survey[i];
if (question) {
resp.questionIndex = i;
resp.questionText = question.text;
if (resp.values && question.components) {
resp.questionOptions = question.components[0].options.map(o => o.label);
resp.values = resp.values.map(v => question.components[0].options.find(opt => opt.value === v)?.label);
if (question.components[0].maxValues === 1) {
resp.value = resp.values[0];
resp.values = undefined;
}
}
if (resp.type === 'BUTTON' && question.components) {
resp.value = question.components.find(opt => opt.customId === resp.id)?.label;
resp.questionOptions = question.components.map(o => o.label);
}
}
// for ordering purposes
let res = {
id: resp.id,
type: resp.type,
questionIndex: resp.questionIndex,
questionText: resp.questionText,
questionOptions: resp.questionOptions || null,
value: resp.value || resp.values || null
}
if (!surveyAnwsers.get(userId)) {
surveyAnwsers.set(userId, []);
}
if (res.questionIndex) {
surveyAnwsers.get(userId).push(res);
}
}
function resetProgress(userId) {
surveyAnwsered.set(userId, new Collection());
surveyProgress.set(userId, 0);
surveyAnwsers.set(userId, []);
surveyCurrentMessage.set(userId, undefined);
}
async function advanceSurvey(userId, dontAdvanceProgress) {
if (!dontAdvanceProgress) surveyProgress.set(userId, (surveyProgress.get(userId) || 0) + 1);
const interaction = surveyInteractions.get(userId);
const i = surveyProgress.get(userId);
const question = survey[i];
if (!question) {
const anwsers = surveyAnwsers.get(userId);
const filename = `survey-response-${userId}.json`;
const stringified = JSON.stringify(anwsers, undefined, 2);
await fs.writeFile(filename, stringified, {encoding: 'utf8'});
(await interaction.client.channels.fetch(RESPONSES_CHANNEL)).send({
content: `Recieved a response from <@${userId}>`,
files: [filename],
components: [new MessageActionRow().addComponents(
new MessageButton().setLabel('Approve').setStyle('SUCCESS').setCustomId('survey-reply-approve'),
new MessageButton().setLabel('Deny').setStyle('DANGER').setCustomId('survey-reply-deny'))
]
});
await interaction.deferReply({
ephemeral: ephemeral
});
await interaction.followUp({
content: `**Thank you for your participation!** Your responses have been recorded and you will soon become a member of the Fire Pit based on your anwsers.`,
ephemeral: ephemeral
});
resetProgress(userId);
} else {
let components = [];
if (question.components) components = question.components;
if (question.textResponse) components.push(
new MessageButton().setCustomId(question.id + '-modal').setLabel('Anwser').setStyle('PRIMARY')
)
const msg = await interaction.reply({
content: `${question.noNumber ? '' : `${i}. `}${question.text.split('\n')[0] === '' ? '' : `**${question.text.split('\n')[0]}**`}\n${question.text.split('\n').slice(1).join('\n')}`,
components: components ? ([new MessageActionRow().addComponents(...components)]) : undefined,
ephemeral: ephemeral,
fetchReply: true
});
surveyCurrentMessage.set(userId, msg.id);
}
}
module.exports = {
data: new SlashCommandBuilder()
.setName('createsurvey')
.setDescription('Re-create the survey button'),
/**
*
* @param {CommandInteraction} interaction
* @param {GuildMember} member
*/
execute: async (interaction, member) => {
const row = new MessageActionRow().addComponents(
new MessageButton().setCustomId('survey-take').setLabel('Take Survey').setStyle('SECONDARY')
);
await interaction.channel.send({
content: '**Hello!**\n\nIt would be great to know more about you and your interests before you\'re accepted into the Discord server, so please answer some simple questions for us!',
components: [row]
});
await interaction.reply({
content: 'done',
ephemeral: true
});
},
/**
*
* @param {Client} client
*/
onClientReady: (bot) => {
bot.on('interactionCreate', interaction => {
if (!interaction.isMessageComponent()) return;
if (interaction.isModalSubmit()) return;
if (!interaction.customId.startsWith('survey-')) return;
const member = interaction.member;
if (interaction.customId === 'survey-reply-approve' || interaction.customId === 'survey-reply-deny') {
const approve = interaction.customId === 'survey-reply-approve';
}
surveyInteractions.set(member.id, interaction);
if (interaction.customId === 'survey-take') {
const index = surveyProgress.get(member.id);
if (index && index > 0) {
const currentMessage = surveyCurrentMessage.get(member.id);
if (currentMessage) {
surveyAnwsered.get(member.id).set(currentMessage, true);
}
advanceSurvey(member.id, true);
return;
} else {
resetProgress(member.id);
}
} else {
if (!surveyAnwsered.get(member.id)) {
interaction.deferUpdate();
return;
}
}
if (surveyAnwsered.get(member.id).get(interaction.message.id)) {
interaction.deferUpdate();
return;
}
if (interaction.customId.endsWith('-modal')) {
const modal = new Modal()
.setCustomId(interaction.customId)
.setTitle('Fire Pit Survey');
const i = surveyProgress.get(member.id);
const question = survey[i];
const input = new TextInputComponent()
.setCustomId(question.id)
.setLabel(question.text.trim().split('\n')[0].slice(0, 44))
.setStyle(question.style || 'SHORT')
.setPlaceholder(question.placeholder || '')
.setRequired(true);
const row = new MessageActionRow().addComponents(input);
modal.addComponents(row);
interaction.showModal(modal);
} else {
surveyAnwsered.get(member.id).set(interaction.message.id, true);
let resp = {};
resp.id = interaction.customId;
resp.type = interaction.componentType;
if (interaction.values) {
resp.values = interaction.values;
}
pushResponse(resp, member.id);
advanceSurvey(member.id);
}
});
bot.on('interactionCreate', interaction => {
if (!interaction.isModalSubmit()) return;
const member = interaction.member;
surveyInteractions.set(member.id, interaction);
surveyAnwsered.get(member.id).set(interaction.message.id, true);
const i = surveyProgress.get(member.id);
const question = survey[i];
const field = interaction.fields.getField(question.id);
let resp = {};
resp.id = field.customId;
resp.type = field.type;
resp.value = field.value;
pushResponse(resp, member.id);
advanceSurvey(member.id);
})
bot.on('messageCreate', msg => {
if (msg.channel.id !== SURVEY_CHANNEL) return;
if (msg.author.id === msg.client.user.id) return;
msg.delete();
});
}
};

16
delete-commands.js Normal file
View File

@ -0,0 +1,16 @@
const fs = require("node:fs");
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const {token} = require('./config.json');
const rest = new REST({ version: "9" }).setToken(token);
rest.get(Routes.applicationGuildCommands('898850107892596776', '587108210121506816')).then((data) => {
const promises = [];
for (const command of data) {
const deleteUrl = `${Routes.applicationGuildCommands('898850107892596776', '587108210121506816')}/${command.id}`;
promises.push(rest.delete(deleteUrl));
}
console.log(`Removing ${promises.length} commands...`);
Promise.all(promises).then(() => console.log('Done!'));
});

19
deploy-commands.js Normal file
View File

@ -0,0 +1,19 @@
const fs = require("node:fs");
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const {token} = require('./config.json');
const rest = new REST({ version: "9" }).setToken(token);
const commands = [];
const commandFiles = fs.readdirSync("./commands").filter((file) => file.endsWith(".js") && !file.startsWith('.'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}
rest
.put(Routes.applicationGuildCommands('898850107892596776', '587108210121506816'), { body: commands })
.then(() => console.log(`${commands.length} commands added`))
.catch(console.error);

136
index.js Normal file
View File

@ -0,0 +1,136 @@
const Discord = require('discord.js');
const {token} = require('./config.json');
const fs = require('fs');
const path = require('path');
const morningHour = 8;
const eveningHour = 21;
function getNextMorning() {
let now = new Date();
let next = new Date();
if (now.getUTCHours() >= morningHour) {
next.setTime(next.getTime() + 1000 * 60 * 60 * 24);
}
next.setUTCHours(morningHour);
next.setUTCMinutes(Math.floor(Math.random() * 60));
next.setUTCSeconds(Math.floor(Math.random() * 60));
console.log('next morning set to ' + next);
return next.getTime();
}
function getNextNight() {
let now = new Date();
let next = new Date();
if (now.getUTCHours() >= eveningHour) {
next.setTime(next.getTime() + 1000 * 60 * 60 * 24);
}
next.setUTCHours(eveningHour);
next.setUTCMinutes(Math.floor(Math.random() * 60));
next.setUTCSeconds(Math.floor(Math.random() * 60));
console.log('next night set to ' + next);
return next.getTime();
}
let next;
function save() {
fs.writeFileSync('./next.json', JSON.stringify(next));
}
if (fs.existsSync('./next.json')) {
next = JSON.parse(fs.readFileSync('./next.json', 'utf8'));
} else {
next = {
morning: getNextMorning(),
night: getNextNight()
}
save();
}
const bot = new Discord.Client({
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
});
const channels = [
'587108210683412493'
];
const morning = [
'goob morning',
'gm besties',
'morning !!!',
'it is Morning',
'gm',
'goom morbning'
];
const night = [
'good night!!!!!!',
'nini all',
'goob night',
'goo night .....',
'sleep well everyone!!!!!',
'good night !! dont let the bugs bite'
];
bot.on('ready', () => {
setInterval(() => {
let current = new Date().getTime();
// console.log(current, next.morning, next.night);
if (current > next.morning) {
next.morning = getNextMorning();
channels.forEach(c => {
bot.channels.fetch(c)
.then(channel => channel.send(morning[Math.floor(Math.random() * morning.length)]))
.catch(err => console.log('couldnt find channel ' + c + ': ' + err));
});
save();
}
if (current > next.night) {
next.night = getNextNight();
channels.forEach(c => {
bot.channels.fetch(c)
.then(channel => channel.send(night[Math.floor(Math.random() * night.length)]))
.catch(err => console.log('couldnt find channel ' + c + ': ' + err));
});
save();
}
}, 1000);
bot.commands = new Discord.Collection();
const cmdFiles = fs.readdirSync(path.join(__dirname, "./commands")).filter((file) => file.endsWith(".js"));
for (const file of cmdFiles) {
const cmd = require(`./commands/${file}`);
bot.commands.set(cmd.data.name, cmd);
if (cmd.onClientReady) cmd.onClientReady(bot);
}
console.log('foggy online');
});
bot.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction, interaction.member);
} catch (error) {
interaction.reply({ content: "`ERROR`", ephemeral: true });
console.error(error);
}
});
bot.login(token);

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "foggy-morning",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "oatmealine",
"license": "AGPL-3.0",
"dependencies": {
"@discordjs/builders": "^0.13.0",
"@discordjs/rest": "^0.4.1",
"discord.js": "^13.8.0",
"random-seed": "^0.3.0"
}
}

251
pnpm-lock.yaml Normal file
View File

@ -0,0 +1,251 @@
lockfileVersion: 5.3
specifiers:
'@discordjs/builders': ^0.13.0
'@discordjs/rest': ^0.4.1
discord.js: ^13.8.0
random-seed: ^0.3.0
dependencies:
'@discordjs/builders': 0.13.0
'@discordjs/rest': 0.4.1
discord.js: 13.8.0
random-seed: 0.3.0
packages:
/@discordjs/builders/0.13.0:
resolution: {integrity: sha512-4L9y26KRNNU8Y7J78SRUN1Uhava9D8jfit/YqEaKi8gQRc7PdqKqk2poybo6RXaiyt/BgKYPfcjxT7WvzGfYCA==}
engines: {node: '>=16.9.0'}
dependencies:
'@sapphire/shapeshift': 2.2.0
'@sindresorhus/is': 4.6.0
discord-api-types: 0.31.2
fast-deep-equal: 3.1.3
ts-mixer: 6.0.1
tslib: 2.3.1
dev: false
/@discordjs/builders/0.14.0:
resolution: {integrity: sha512-+fqLIqa9wN3R+kvlld8sgG0nt04BAZxdCDP4t2qZ9TJsquLWA+xMtT8Waibb3d4li4AQS+IOfjiHAznv/dhHgQ==}
engines: {node: '>=16.9.0'}
dependencies:
'@sapphire/shapeshift': 3.1.0
'@sindresorhus/is': 4.6.0
discord-api-types: 0.33.4
fast-deep-equal: 3.1.3
ts-mixer: 6.0.1
tslib: 2.4.0
dev: false
/@discordjs/collection/0.7.0:
resolution: {integrity: sha512-R5i8Wb8kIcBAFEPLLf7LVBQKBDYUL+ekb23sOgpkpyGT+V4P7V83wTxcsqmX+PbqHt4cEHn053uMWfRqh/Z/nA==}
engines: {node: '>=16.9.0'}
dev: false
/@discordjs/collection/0.7.0-dev.1653480253-68d5169:
resolution: {integrity: sha512-s8z+4G82yrIbS0OxqVyitkS72mvE6lxYW8zjsKfpqPAIG6fKQ9n41c9HEsCG1VlWNeQ6F23fKf2hT3bGIdRGsQ==}
engines: {node: '>=16.9.0'}
dev: false
/@discordjs/rest/0.4.1:
resolution: {integrity: sha512-rtWy+AIfNlfjGkAgA2TJLASdqli07aTNQceVGT6RQQiQaEqV0nsfBO4WtDlDzk7PmO3w+InP3dpwEolJI5jz0A==}
engines: {node: '>=16.9.0'}
dependencies:
'@discordjs/collection': 0.7.0-dev.1653480253-68d5169
'@sapphire/async-queue': 1.3.1
'@sapphire/snowflake': 3.2.2
'@types/node-fetch': 2.6.1
discord-api-types: 0.29.0
form-data: 4.0.0
node-fetch: 2.6.7
tslib: 2.3.1
transitivePeerDependencies:
- encoding
dev: false
/@sapphire/async-queue/1.3.1:
resolution: {integrity: sha512-FFTlPOWZX1kDj9xCAsRzH5xEJfawg1lNoYAA+ecOWJMHOfiZYb1uXOI3ne9U4UILSEPwfE68p3T9wUHwIQfR0g==}
engines: {node: '>=v14.0.0', npm: '>=7.0.0'}
dev: false
/@sapphire/shapeshift/2.2.0:
resolution: {integrity: sha512-UEnKgMlQyI0yY/q+lCMX0VJft9y86IsesgbIQj6e62FBYSaMVr+IaMNpi4z45Q14VnuMACbK0yrbHISNqgUYcQ==}
engines: {node: '>=v15.0.0', npm: '>=7.0.0'}
dev: false
/@sapphire/shapeshift/3.1.0:
resolution: {integrity: sha512-PkxFXd3QJ1qAPS05Dy2UkVGYPm/asF1Ugt2Xyzmv4DHzO3+G7l+873C4XFFcJ9M5Je+eCMC7SSifgPTSur5QuA==}
engines: {node: '>=v15.0.0', npm: '>=7.0.0'}
dev: false
/@sapphire/snowflake/3.2.2:
resolution: {integrity: sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ==}
engines: {node: '>=v14.0.0', npm: '>=7.0.0'}
dev: false
/@sindresorhus/is/4.6.0:
resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==}
engines: {node: '>=10'}
dev: false
/@types/node-fetch/2.6.1:
resolution: {integrity: sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==}
dependencies:
'@types/node': 17.0.23
form-data: 3.0.1
dev: false
/@types/node/17.0.23:
resolution: {integrity: sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==}
dev: false
/@types/ws/8.5.3:
resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==}
dependencies:
'@types/node': 17.0.23
dev: false
/asynckit/0.4.0:
resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=}
dev: false
/combined-stream/1.0.8:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
dependencies:
delayed-stream: 1.0.0
dev: false
/delayed-stream/1.0.0:
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
engines: {node: '>=0.4.0'}
dev: false
/discord-api-types/0.29.0:
resolution: {integrity: sha512-Ekq1ICNpOTVajXKZguNFrsDeTmam+ZeA38txsNLZnANdXUjU6QBPIZLUQTC6MzigFGb0Tt8vk4xLnXmzv0shNg==}
dev: false
/discord-api-types/0.31.2:
resolution: {integrity: sha512-gpzXTvFVg7AjKVVJFH0oJGC0q0tO34iJGSHZNz9u3aqLxlD6LfxEs9wWVVikJqn9gra940oUTaPFizCkRDcEiA==}
dev: false
/discord-api-types/0.33.4:
resolution: {integrity: sha512-Y6RMvXsHKiBgQhm/q5MgRieXc4Tzh5p/JuDyqreI48lmy+AQfO+g9Xhz0tuGBaN1FtsrLT7mD+lbFONPo5vdwA==}
dev: false
/discord.js/13.8.0:
resolution: {integrity: sha512-EPAA/2VLycYN5wSzavqa4iJ6qj3UtQFtHw5TH/60Fj29ymfEsCQVn//o1mTpwDxzwb+rPIrWhkxKIGGnjfv0Iw==}
engines: {node: '>=16.6.0', npm: '>=7.0.0'}
dependencies:
'@discordjs/builders': 0.14.0
'@discordjs/collection': 0.7.0
'@sapphire/async-queue': 1.3.1
'@types/node-fetch': 2.6.1
'@types/ws': 8.5.3
discord-api-types: 0.33.4
form-data: 4.0.0
node-fetch: 2.6.7
ws: 8.7.0
transitivePeerDependencies:
- bufferutil
- encoding
- utf-8-validate
dev: false
/fast-deep-equal/3.1.3:
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
dev: false
/form-data/3.0.1:
resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==}
engines: {node: '>= 6'}
dependencies:
asynckit: 0.4.0
combined-stream: 1.0.8
mime-types: 2.1.35
dev: false
/form-data/4.0.0:
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
engines: {node: '>= 6'}
dependencies:
asynckit: 0.4.0
combined-stream: 1.0.8
mime-types: 2.1.35
dev: false
/json-stringify-safe/5.0.1:
resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=}
dev: false
/mime-db/1.52.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: false
/mime-types/2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
mime-db: 1.52.0
dev: false
/node-fetch/2.6.7:
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
engines: {node: 4.x || >=6.0.0}
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
dependencies:
whatwg-url: 5.0.0
dev: false
/random-seed/0.3.0:
resolution: {integrity: sha1-2UXy4fOPSejViRNDG4v2u5N1Vs0=}
engines: {node: '>= 0.6.0'}
dependencies:
json-stringify-safe: 5.0.1
dev: false
/tr46/0.0.3:
resolution: {integrity: sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=}
dev: false
/ts-mixer/6.0.1:
resolution: {integrity: sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg==}
dev: false
/tslib/2.3.1:
resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==}
dev: false
/tslib/2.4.0:
resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==}
dev: false
/webidl-conversions/3.0.1:
resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=}
dev: false
/whatwg-url/5.0.0:
resolution: {integrity: sha1-lmRU6HZUYuN2RNNib2dCzotwll0=}
dependencies:
tr46: 0.0.3
webidl-conversions: 3.0.1
dev: false
/ws/8.7.0:
resolution: {integrity: sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: ^5.0.2
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
dev: false