Some fix?

This commit is contained in:
Supositware 2022-09-23 19:45:59 +02:00
parent 605390bfe2
commit eecb6020ea

View file

@ -1,5 +1,6 @@
import fs from 'node:fs'; import fs from 'node:fs';
export function rand(text, message) { export function rand(text, interaction) {
interaction.author = interaction.user;
// Find a value in an array of objects in Javascript - https://stackoverflow.com/a/12462387 // Find a value in an array of objects in Javascript - https://stackoverflow.com/a/12462387
function search(nameKey, myArray) { function search(nameKey, myArray) {
for (let i = 0; i < myArray.length; i++) { for (let i = 0; i < myArray.length; i++) {
@ -23,15 +24,15 @@ export function rand(text, message) {
const variables = [ const variables = [
{ {
name: /\[author\]/, name: /\[author\]/,
value: message ? message.author.username : '', value: interaction ? interaction.author.username : '',
}, },
{ {
name: /\[member\]/, name: /\[member\]/,
value: message ? message.guild ? message.guild.members.cache.random().user.username : '' : '', value: interaction ? interaction.guild ? interaction.guild.members.cache.random().user.username : '' : '',
}, },
{ {
name: /\[memberRand\]/, name: /\[memberRand\]/,
value: (() => message.guild ? message.guild.members.cache.random().user.username : ''), value: (() => interaction.guild ? interaction.guild.members.cache.random().user.username : ''),
}, },
{ {
name: /\[dice\d*\]/, name: /\[dice\d*\]/,