survey approval/deny + other stuff idk

This commit is contained in:
Jill 2022-06-08 04:46:00 +03:00
parent 4bd0004bfb
commit 4e2011a8e6
12 changed files with 259 additions and 1356 deletions

View File

@ -15,5 +15,8 @@ module.exports = {
'indent': ['error', 2],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
}
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-var-requires': 'off'
},
};

3
.gitignore vendored
View File

@ -2,4 +2,5 @@ survey-responses/*
config.json
next.json
node_modules
tsconfig.tsbuildinfo
tsconfig.tsbuildinfo
built/*

View File

@ -1,89 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builders_1 = require("@discordjs/builders");
const discord_js_1 = 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 builders_1.SlashCommandBuilder()
.setName('change')
.setDescription('Change')
.addStringOption((option) => option.setName('what').setDescription('Change what? Examples include: "environment", "perspective", etc...').setRequired(true)),
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 discord_js_1.MessageEmbed()
.setTitle(title)
.setDescription(response)
.setTimestamp();
await interaction.reply({
embeds: [embed],
ephemeral: false,
});
}
};

View File

@ -1,69 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builders_1 = require("@discordjs/builders");
const discord_js_1 = 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 builders_1.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)),
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 discord_js_1.MessageEmbed()
.setDescription(response)
.setAuthor({
name: `${member.displayName} the ${sheriff ? 'Sheriff' : 'Investigator'}`,
iconURL: member.displayAvatarURL()
})
.setColor(color);
await interaction.reply({
embeds: [embed],
ephemeral: true,
});
}
};

View File

@ -1,113 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builders_1 = require("@discordjs/builders");
const discord_js_1 = 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 builders_1.SlashCommandBuilder()
.setName('monitor')
.setDescription('Monitor')
.addStringOption((option) => option.setName('what').setDescription('Monitor what? Examples include: "lobby", "bedroom", "park", "playground", etc...').setRequired(true)),
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 discord_js_1.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,
});
}
};

View File

@ -1,713 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const builders_1 = require("@discordjs/builders");
const discord_js_1 = require("discord.js");
const fs = __importStar(require("fs/promises"));
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 discord_js_1.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 discord_js_1.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 discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-time-correct-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-time-correct-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Favorite color?',
components: [
new discord_js_1.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 discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-dark-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-dark-no').setLabel('No').setStyle('PRIMARY'),
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-morality-a').setLabel('A').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-morality-b').setLabel('B').setStyle('PRIMARY')
]
},
{
text: 'How long ago did you last go on a bridge?',
components: [
new discord_js_1.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 discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-railroad1-switch').setLabel('Switch').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-railroad1-no').setLabel('Do not').setStyle('PRIMARY')
]
},
{
text: 'Which region do you live in?',
components: [
new discord_js_1.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 discord_js_1.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 discord_js_1.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 discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-cars1-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.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 discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-been-here-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-fridge-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-fridge-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Do you generally feel unsafe in your life?',
noNumber: true,
components: [
new discord_js_1.MessageSelectMenu()
.setCustomId('survey-unsafe')
.setOptions(extendOptions(['Yes', 'No', 'Sometimes']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'train',
components: [
new discord_js_1.MessageSelectMenu()
.setCustomId('survey-train')
.setOptions(extendOptions(['Option 1', 'Option 2']))
.setMinValues(1)
.setMaxValues(1)
]
},
{
text: 'Do you live on planet Earth?',
components: [
new discord_js_1.MessageButton().setCustomId('survey-earth-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-earth-no').setLabel('No').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-earth-maybe').setLabel('Maybe~ ;3').setStyle('PRIMARY')
]
},
{
text: 'Do you own a credit or debit card?',
components: [
new discord_js_1.MessageButton().setCustomId('survey-credit-card-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-railroad3-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-finished').setLabel('Done').setStyle('PRIMARY')
]
},
{
text: 'Which of these natural landmarks is your favorite?',
components: [
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-cars2-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-cars2-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Are you operating a railroad track?',
components: [
new discord_js_1.MessageButton().setCustomId('survey-railroad4-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-railroad4-truth-yes').setLabel('Yes').setStyle('PRIMARY'),
new discord_js_1.MessageButton().setCustomId('survey-railroad4-truth-no').setLabel('No').setStyle('PRIMARY')
]
},
{
text: 'Please rate your experience with this survey.',
noNumber: true,
components: [
new discord_js_1.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 discord_js_1.MessageButton().setCustomId('survey-closer6').setLabel('Yes.').setStyle('SUCCESS')
]
},
{
text: 'Do you like how mushrooms grow and expand?',
noNumber: true,
components: [
new discord_js_1.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 discord_js_1.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 discord_js_1.Collection();
const surveyInteractions = new discord_js_1.Collection();
const surveyAnwsered = new discord_js_1.Collection();
const surveyAnwsers = new discord_js_1.Collection();
const surveyCurrentMessage = new discord_js_1.Collection();
function pushResponse(resp, userId) {
const i = surveyProgress.get(userId);
const question = survey[i || 0];
if (question) {
resp.questionIndex = i;
resp.questionText = question.text;
if (resp.values && question.components) {
const components = question.components;
resp.questionOptions = components[0].options.map(o => o.label);
resp.values = resp.values.map(v => components[0].options.find(opt => opt.value === v)?.label || '');
if (components[0].maxValues === 1) {
resp.value = resp.values[0];
resp.values = undefined;
}
}
if (resp.type === 'BUTTON' && question.components) {
const components = question.components;
resp.value = components.find(opt => opt.customId === resp.id)?.label;
resp.questionOptions = 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 discord_js_1.Collection());
surveyProgress.set(userId, 0);
surveyAnwsers.set(userId, []);
surveyCurrentMessage.delete(userId);
}
async function advanceSurvey(userId, dontAdvanceProgress = false) {
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 discord_js_1.MessageActionRow().addComponents(new discord_js_1.MessageButton().setLabel('Approve').setStyle('SUCCESS').setCustomId('survey-reply-approve'), new discord_js_1.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 discord_js_1.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 discord_js_1.MessageActionRow().addComponents(...components)]) : undefined,
ephemeral: ephemeral,
fetchReply: true
});
surveyCurrentMessage.set(userId, msg.id);
}
}
module.exports = {
data: new builders_1.SlashCommandBuilder()
.setName('createsurvey')
.setDescription('Re-create the survey button'),
execute: async (interaction, member) => {
const row = new discord_js_1.MessageActionRow().addComponents(new discord_js_1.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
});
},
onClientReady: (bot) => {
bot.on('interactionCreate', interaction => {
if (!interaction.isMessageComponent())
return;
if (interaction.isModalSubmit())
return;
if (!interaction.customId.startsWith('survey-'))
return;
if (!interaction.member)
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 discord_js_1.Modal()
.setCustomId(interaction.customId)
.setTitle('Fire Pit Survey');
const i = surveyProgress.get(member.id);
const question = survey[i];
const input = new discord_js_1.TextInputComponent()
.setCustomId(question.id)
.setLabel(question.text.trim().split('\n')[0].slice(0, 44))
.setStyle(question.style || 'SHORT')
.setPlaceholder(question.placeholder || '')
.setRequired(true);
// @ts-ignore
const row = new discord_js_1.MessageActionRow().addComponents(input);
// @ts-ignore
modal.addComponents(row);
interaction.showModal(modal);
}
else {
surveyAnwsered.get(member.id).set(interaction.message.id, true);
let resp = {
id: interaction.customId,
type: interaction.componentType,
values: interaction.isSelectMenu() ? interaction.values : undefined
};
pushResponse(resp, member.id);
advanceSurvey(member.id);
}
});
bot.on('interactionCreate', interaction => {
if (!interaction.isModalSubmit())
return;
if (!interaction.member)
return;
const member = interaction.member;
// @ts-ignore
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 = {
id: field.customId,
type: field.type,
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();
});
}
};

View File

@ -1,144 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Discord = __importStar(require("discord.js"));
const fs = __importStar(require("fs"));
const { token, disableDaytimeAnnouncements } = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
const path = __importStar(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', async () => {
setInterval(() => {
let current = new Date().getTime();
// console.log(current, next.morning, next.night);
if (current > next.morning && !disableDaytimeAnnouncements) {
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 && !disableDaytimeAnnouncements) {
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 = (await Promise.resolve().then(() => __importStar(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);

View File

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { CategoryChannel, CommandInteraction, GuildMember, MessageActionRow, MessageEmbed, TextChannel } from 'discord.js';
import { CategoryChannel, CommandInteraction, GuildMember, MessageEmbed, TextChannel } from 'discord.js';
const rand = [
'This change has no significance.',
@ -36,7 +36,7 @@ const nicknames = [
'foggy',
'frog',
'fog'
]
];
module.exports = {
data: new SlashCommandBuilder()
@ -45,42 +45,45 @@ module.exports = {
.addStringOption((option) => option.setName('what').setDescription('Change what? Examples include: "environment", "perspective", etc...').setRequired(true)),
execute: async (interaction: CommandInteraction, member: GuildMember) => {
let what = interaction.options.getString('what')!;
const 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 as TextChannel).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)] as CategoryChannel;
await (interaction.channel as TextChannel).setParent(category);
await (interaction.channel as TextChannel).setPosition(Math.floor(Math.random() * category.children.size));
break;
default:
response = rand[Math.floor(Math.random() * rand.length)];
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 as TextChannel).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)] as CategoryChannel;
await (interaction.channel as TextChannel).setParent(category);
await (interaction.channel as TextChannel).setPosition(Math.floor(Math.random() * category.children.size));
break;
}
default:
response = rand[Math.floor(Math.random() * rand.length)];
}
const embed = new MessageEmbed()
@ -93,4 +96,4 @@ module.exports = {
ephemeral: false,
});
}
}
};

View File

@ -28,28 +28,28 @@ module.exports = {
.addBooleanOption((option) => option.setName('sheriff').setDescription('Switch to Sheriff-style investigation').setRequired(false)),
execute: async (interaction: CommandInteraction, member: GuildMember) => {
let who = interaction.options.getUser('who')!;
let sheriff = interaction.options.getBoolean('sheriff');
const who = interaction.options.getUser('who')!;
const 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.`;
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._`
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!_`
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)];
const 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;
}
@ -68,4 +68,4 @@ module.exports = {
ephemeral: true,
});
}
}
};

View File

@ -1,5 +1,4 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import type { GuildMember } from 'discord.js';
import { CommandInteraction, MessageEmbed } from 'discord.js';
const rand = require('random-seed').create();
@ -29,78 +28,75 @@ module.exports = {
.setDescription('Monitor')
.addStringOption((option) => option.setName('what').setDescription('Monitor what? Examples include: "lobby", "bedroom", "park", "playground", etc...').setRequired(true)),
execute: async (interaction: CommandInteraction, member: GuildMember) => {
execute: async (interaction: CommandInteraction) => {
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;
case 'home':
img = 'img12';
break;
case 'hell':
img = 'img4';
break;
case 'fire pit':
img = 'img4';
break;
case 'party':
img = 'img23';
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()
@ -114,4 +110,4 @@ module.exports = {
ephemeral: false,
});
}
}
};

View File

@ -1,7 +1,6 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction, GuildMember, MessageActionRow, MessageEmbed, MessageButton, Client, Collection, MessageComponentInteraction, MessageSelectMenu, Modal, TextInputComponent, MessageSelectOptionData, MessageInteraction, MessageComponentType, TextChannel, TextInputStyleResolvable } from 'discord.js';
import { CommandInteraction, GuildMember, MessageActionRow, MessageButton, Client, Collection, MessageComponentInteraction, MessageSelectMenu, Modal, TextInputComponent, MessageSelectOptionData, MessageComponentType, TextChannel, TextInputStyleResolvable, Message } from 'discord.js';
import * as fs from 'fs/promises';
import { inspect } from 'util';
const SURVEY_CHANNEL = '983479509376434216';
const RESPONSES_CHANNEL = '983762973858361364';
@ -13,23 +12,13 @@ function extendOptions(opt: string[]): MessageSelectOptionData[] {
return opt.map(t => ({label: t, value: t.toLowerCase().replace(/[^a-z0-9-]/g, '-')}));
}
function makeid(length: number) {
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: [
@ -217,7 +206,7 @@ const survey = [
]
},
{
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.`,
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')
@ -349,14 +338,14 @@ const survey = [
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: [
@ -449,7 +438,7 @@ const survey = [
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,
@ -460,7 +449,7 @@ const survey = [
.setMinValues(1)
.setMaxValues(1)
]
},
},/*
{
text: 'What is your opinion on mycology?',
noNumber: true,
@ -481,7 +470,7 @@ const survey = [
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,
@ -489,7 +478,7 @@ const survey = [
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')
]
}
]
];
interface SurveyResponse {
id: string,
@ -533,14 +522,14 @@ function pushResponse(resp: Partial<SurveyResponse>, userId: string) {
}
// for ordering purposes
let res = {
const 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, []);
@ -566,7 +555,7 @@ async function advanceSurvey(userId: string, dontAdvanceProgress = false) {
if (!question) {
const anwsers = surveyAnwsers.get(userId);
const filename = `survey-response-${userId}.json`;
const filename = `survey-responses/survey-response-${userId}.json`;
const stringified = JSON.stringify(anwsers, undefined, 2);
await fs.writeFile(filename, stringified, {encoding: 'utf8'});
@ -574,15 +563,15 @@ async function advanceSurvey(userId: string, dontAdvanceProgress = false) {
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'))
new MessageButton().setLabel('Approve').setStyle('SUCCESS').setCustomId(`survey-reply-approve-${userId}`),
new MessageButton().setLabel('Deny').setStyle('DANGER').setCustomId(`survey-reply-deny-${userId}`))
]
});
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.`,
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
});
@ -592,7 +581,7 @@ async function advanceSurvey(userId: string, dontAdvanceProgress = false) {
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')}`,
@ -610,7 +599,7 @@ module.exports = {
.setName('createsurvey')
.setDescription('Re-create the survey button'),
execute: async (interaction: CommandInteraction, member: GuildMember) => {
execute: async (interaction: CommandInteraction) => {
const row = new MessageActionRow().addComponents(
new MessageButton().setCustomId('survey-take').setLabel('Take Survey').setStyle('SECONDARY')
);
@ -626,7 +615,7 @@ module.exports = {
},
onClientReady: (bot: Client) => {
bot.on('interactionCreate', interaction => {
bot.on('interactionCreate', async (interaction) => {
if (!interaction.isMessageComponent()) return;
if (interaction.isModalSubmit()) return;
if (!interaction.customId.startsWith('survey-')) return;
@ -634,9 +623,45 @@ module.exports = {
const member = interaction.member as GuildMember;
if (interaction.customId === 'survey-reply-approve' || interaction.customId === 'survey-reply-deny') {
const approve = interaction.customId === 'survey-reply-approve';
if (interaction.customId.startsWith('survey-reply-approve-') || interaction.customId.startsWith('survey-reply-deny-')) {
const approve = interaction.customId.startsWith('survey-reply-approve-');
const id = interaction.customId.split('-')[3];
if (!approve) {
(await interaction.guild?.members.fetch(id))!.kick();
await interaction.reply({
content: `${member} denied the application.`,
ephemeral: false
});
const msg = interaction.message as Message;
await msg.edit({
content: msg.content,
components: [new MessageActionRow().addComponents(
new MessageButton().setCustomId('survey-reply-denied').setLabel(`${member.displayName} denied the application`).setStyle('DANGER').setDisabled(true)
)]
});
} else {
(await interaction.guild?.members.fetch(id))!.roles.add(member.guild!.roles.cache.find(r => r.name === '✦')!);
await interaction.reply({
content: `${member} approved the application.`,
ephemeral: false
});
const msg = interaction.message as Message;
await msg.edit({
content: msg.content,
components: [new MessageActionRow().addComponents(
new MessageButton().setCustomId('survey-reply-approved').setLabel(`${member.displayName} approved the application`).setStyle('SUCCESS').setDisabled(true)
)]
});
(await interaction.guild?.channels.fetch(GENERAL_CHANNEL) as TextChannel).send({
content: `_<@${id}> has been approved into the server._`,
});
}
return;
}
surveyInteractions.set(member.id, interaction);
@ -680,15 +705,17 @@ module.exports = {
.setPlaceholder(question.placeholder || '')
.setRequired(true);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const row = new MessageActionRow().addComponents(input);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
modal.addComponents(row);
interaction.showModal(modal);
} else {
surveyAnwsered.get(member.id)!.set(interaction.message.id, true);
let resp = {
const resp = {
id: interaction.customId,
type: interaction.componentType,
values: interaction.isSelectMenu() ? interaction.values : undefined
@ -705,6 +732,7 @@ module.exports = {
const member = interaction.member as GuildMember;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
surveyInteractions.set(member.id, interaction);
@ -715,7 +743,7 @@ module.exports = {
const field = interaction.fields.getField(question.id!);
let resp = {
const resp = {
id: field.customId,
type: field.type,
value: field.value
@ -724,7 +752,7 @@ module.exports = {
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;

View File

@ -7,32 +7,32 @@ 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));
const now = new Date();
const 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);
console.log('next morning set to ' + next);
return next.getTime();
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));
const now = new Date();
const 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);
console.log('next night set to ' + next);
return next.getTime();
return next.getTime();
}
interface DaytimeSchedule {
@ -43,99 +43,99 @@ interface DaytimeSchedule {
let next: DaytimeSchedule;
function save() {
fs.writeFileSync('./next.json', JSON.stringify(next));
fs.writeFileSync('./next.json', JSON.stringify(next));
}
if (fs.existsSync('./next.json')) {
next = JSON.parse(fs.readFileSync('./next.json', 'utf8'));
next = JSON.parse(fs.readFileSync('./next.json', 'utf8'));
} else {
next = {
morning: getNextMorning(),
night: getNextNight()
}
save();
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,
],
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'
'587108210683412493'
];
const morning = [
'goob morning',
'gm besties',
'morning !!!',
'it is Morning',
'gm',
'goom morbning'
'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'
'good night!!!!!!',
'nini all',
'goob night',
'goo night .....',
'sleep well everyone!!!!!',
'good night !! dont let the bugs bite'
];
bot.on('ready', async () => {
setInterval(() => {
let current = new Date().getTime();
setInterval(() => {
const current = new Date().getTime();
// console.log(current, next.morning, next.night);
// console.log(current, next.morning, next.night);
if (current > next.morning && !disableDaytimeAnnouncements) {
next.morning = getNextMorning();
channels.forEach(c => {
bot.channels.fetch(c)
.then(channel => (channel as Discord.TextBasedChannel).send(morning[Math.floor(Math.random() * morning.length)]))
.catch(err => console.log('couldnt find channel ' + c + ': ' + err));
});
save();
}
if (current > next.night && !disableDaytimeAnnouncements) {
next.night = getNextNight();
channels.forEach(c => {
bot.channels.fetch(c)
.then(channel => (channel as Discord.TextBasedChannel).send(night[Math.floor(Math.random() * night.length)]))
.catch(err => console.log('couldnt find channel ' + c + ': ' + err));
});
save();
}
}, 1000);
if (current > next.morning && !disableDaytimeAnnouncements) {
next.morning = getNextMorning();
channels.forEach(c => {
bot.channels.fetch(c)
.then(channel => (channel as Discord.TextBasedChannel).send(morning[Math.floor(Math.random() * morning.length)]))
.catch(err => console.log('couldnt find channel ' + c + ': ' + err));
});
save();
}
if (current > next.night && !disableDaytimeAnnouncements) {
next.night = getNextNight();
channels.forEach(c => {
bot.channels.fetch(c)
.then(channel => (channel as Discord.TextBasedChannel).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"));
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 = (await import(`./commands/${file}`));
bot.commands.set(cmd.data.name, cmd);
if (cmd.onClientReady) cmd.onClientReady(bot);
if (cmd.onClientReady) cmd.onClientReady(bot);
}
console.log('foggy online');
console.log('foggy online');
});
bot.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
if (!interaction.isCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command) 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);
}
try {
await command.execute(interaction, interaction.member);
} catch (error) {
interaction.reply({ content: '`ERROR`', ephemeral: true });
console.error(error);
}
});
bot.login(token);