local currentDay = tonumber(os.date("%d")) local currentMonth = tonumber(parameters) and string.format("%02d", parameters) or os.date("%m") local past, upcoming, today = { }, { }, { } local pastIndex, upcomingIndex, todayIndex = 0, 0, 0 local day, get for memberId, memberData in next, memberProfiles do if memberData.bday and string.sub(memberData.bday, 4, 5) == currentMonth then day = tonumber(string.sub(memberData.bday, 1, 2)) get = #memberData.bday == 10 memberId = "<@" .. memberId .. "> [" .. discord.getMemberName(memberId) .. "] - " .. memberData.bday if day < currentDay then pastIndex = pastIndex + 1 past[pastIndex] = memberId .. (get and (" - is " .. getAge(memberData.bday) .. " years old.") or '') elseif day > currentDay then upcomingIndex = upcomingIndex + 1 upcoming[upcomingIndex] = memberId .. (get and (" - will be " .. (getAge(memberData.bday) + 1) .. " years old.") or '') else todayIndex = todayIndex + 1 today[todayIndex] = memberId .. (get and (" - " .. getAge(memberData.bday) .. " years old.") or '') end end end local fields, fieldsIndex = { }, 0 if todayIndex > 0 then fieldsIndex = 1 fields[fieldsIndex] = { name = ":tada: Today! :tada:", value = table.concat(today, "\n") } end if upcomingIndex > 0 then fieldsIndex = fieldsIndex + 1 fields[fieldsIndex] = { name = ":tada: Upcoming birthdays this month :tada:", value = table.concat(upcoming, "\n") } end if pastIndex > 0 then fieldsIndex = fieldsIndex + 1 fields[fieldsIndex] = { name = ":tada: Past birthdays this month :tada:", value = table.concat(past, "\n") } end local color, title, description if fieldsIndex > 0 then color = 0x65D665 else color = 0xD67265 title = ":( ..." description = "There is no birthday this month :disappointed:" end discord.reply({ embed = { color = color, fields = fields, title = title, description = description } })