Add /announce which schedules a message in a channel at a date and time to the minute, once or repeating daily, weekly, every other week or monthly on a day of the month, deleting its previous post when it repeats; /announce list, /announce pause and /announce resume, at most ten announcements, and a random mode which picks one of five lines from the code each time
Schedule announcements in any channel at a specific date and time (UTC). Choose from one-time, daily, weekly, every two weeks, or monthly on a specific day. Type "random" as the message to rotate through five motivational messages each time. Pause and resume announcements, view all scheduled posts with /announce list, and manage up to 10 announcements. Repeating announcements automatically delete their previous post before sending the new one.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
✅ Announcement scheduled for Tuesday, September 15, 2026, 09:00 AM (repeating daily) in #general:
Good morning! Don't forget to check today's events
Good morning! Don't forget to check today's events.
✅ Announcement scheduled for Thursday, September 17, 2026, 02:30 PM (repeating weekly) in #general:
(random message)
1. ✅ Active | #general | daily | 2 months ago
Good morning! Don't forget to check toda
2. ✅ Active | #general | weekly | 2 months ago
(random)
⏸️ Paused announcement #1.
✨ New opportunities await — stay active!
▶️ Resumed announcement #1. Next run: September 24, 2026, 09:00 AM
// Scheduled announcements with multiple repeat modes and random message support
interface Announcement {
id: string;
channelId: string;
message: string;
repeat: 'once' | 'daily' | 'weekly' | 'biweekly' | 'monthly';
dayOfMonth?: number; // for monthly
nextRun: number; // timestamp
paused: boolean;
lastMessageId?: string; // track the previous post to delete on repeat
random: boolean; // whether to pick random messages
}
const RANDOM_MESSAGES = [
"🌟 Don't forget to check out today's events!",
'✨ New opportunities await — stay active!',
'🎯 Remember to complete your daily tasks!',
'🚀 Keep up the great work, everyone!',
'💫 Another day, another chance to shine!',
];
// Parse "YYYY-MM-DD HH:MM" in UTC
function parseDateTime(dateStr: string, timeStr: string): number | null {
// "today" and "tomorrow" spare the typing for the common case.
const word = dateStr.trim().toLowerCase();
if (word === 'today' || word === 'tomorrow') {
const d = new Date(Date.now() + (word === 'tomorrow' ? 86400000 : 0));
dateStr = d.toISOString().slice(0, 10);
}
const dateMatch = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
const timeMatch = timeStr.match(/^(\d{1,2}):(\d{2})$/);
if (!dateMatch || !timeMatch) return null;
const [, year, month, day] = dateMatch;
const [, hour, minute] = timeMatch;
const h = parseInt(hour);
const m = parseInt(minute);
if (h < 0 || h > 23 || m < 0 || m > 59) return null;
const date = new Date(`${year}-${month}-${day}T${hour.padStart(2, '0')}:${minute.padStart(2, '0')}:00Z`);
return date.getTime();
}
function getNextRun(firstRun: number, repeat: string, dayOfMonth?: number): number {
const now = Date.now();
if (repeat === 'once') return firstRun;
let next = firstRun;
const day = 86400000;
if (repeat === 'daily') {
while (next <= now) next += day;
} else if (repeat === 'weekly') {
while (next <= now) next += 7 * day;
} else if (repeat === 'biweekly') {
while (next <= now) next += 14 * day;
} else if (repeat === 'monthly' && dayOfMonth) {
// Advance month by month to the same day
const d = new Date(next);
while (next <= now) {
d.setUTCMonth(d.getUTCMonth() + 1);
// Handle edge case: if day doesn't exist in new month, use last day
d.setUTCDate(Math.min(dayOfMonth, new Date(d.getUTCFullYear(), d.getUTCMonth() + 1, 0).getDate()));
next = d.getTime();
}
}
return next;
}
mee6.command(
'announce create',
{
description: 'Schedule a message in a channel',
options: [
{ name: 'channel', type: 'channel', description: 'Where to post', required: true },
{ name: 'date', type: 'string', description: 'Date: YYYY-MM-DD, today or tomorrow', required: true },
{ name: 'time', type: 'string', description: 'Time: HH:MM (UTC, 24h)', required: true },
{
name: 'message',
type: 'string',
description: 'What to post (or "random" for rotating messages)',
required: true,
},
{
name: 'repeat',
type: 'string',
description: 'Frequency',
choices: [
{ name: 'Once', value: 'once' },
{ name: 'Daily', value: 'daily' },
{ name: 'Weekly', value: 'weekly' },
{ name: 'Every 2 weeks', value: 'biweekly' },
{ name: 'Monthly', value: 'monthly' },
],
},
],
},
async (ctx) => {
const channelId = ctx.option<string>('channel');
const dateStr = ctx.option<string>('date');
const timeStr = ctx.option<string>('time');
const message = ctx.option<string>('message');
const repeat = ctx.option<string>('repeat', 'once') as 'once' | 'daily' | 'weekly' | 'biweekly' | 'monthly';
// Check limit
const announcements = await mee6.store.get<Announcement[]>('announcements', []);
if (announcements.length >= 10) {
await ctx.reply('You already have 10 announcements scheduled. Pause or delete one first.');
return;
}
// Parse datetime
const timestamp = parseDateTime(dateStr, timeStr);
if (!timestamp) {
await ctx.reply(
'Invalid date or time. Use **YYYY-MM-DD**, **today** or **tomorrow** for date and **HH:MM** (24-hour, UTC) for time.\nExample: `tomorrow` and `14:30`'
);
return;
}
// Must be at least 30s in the future, and within 1 year
const now = Date.now();
if (timestamp < now + 30000) {
await ctx.reply('The scheduled time must be at least 30 seconds in the future.');
return;
}
if (timestamp > now + 31536000000) {
await ctx.reply('The scheduled time cannot be more than 1 year in the future.');
return;
}
// For monthly, extract day of month
let dayOfMonth: number | undefined;
if (repeat === 'monthly') {
const d = new Date(timestamp);
dayOfMonth = d.getUTCDate();
}
const isRandom = message.toLowerCase() === 'random';
const id = `announce_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
const announcement: Announcement = {
id,
channelId,
message: isRandom ? '' : message,
repeat,
dayOfMonth,
nextRun: timestamp,
paused: false,
random: isRandom,
};
announcements.push(announcement);
await mee6.store.set('announcements', announcements);
// Schedule it
const delaySeconds = Math.floor((timestamp - Date.now()) / 1000);
await mee6.schedule.once(id, delaySeconds, { id });
const repeatLabel = repeat === 'once' ? 'once' : `repeating ${repeat}`;
const msgPreview = isRandom ? '(random message)' : message.slice(0, 50);
await ctx.reply(
`✅ Announcement scheduled for <t:${Math.floor(
timestamp / 1000
)}:F> (${repeatLabel}) in <#${channelId}>:\n> ${msgPreview}`
);
}
);
mee6.command('announce list', { description: 'View all scheduled announcements' }, async (ctx) => {
const announcements = await mee6.store.get<Announcement[]>('announcements', []);
if (announcements.length === 0) {
await ctx.reply('No announcements scheduled. Use `/announce create` to create one.');
return;
}
const lines = announcements.map((a, i) => {
const status = a.paused ? '⏸️ Paused' : '✅ Active';
const repeatLabel = a.repeat === 'once' ? 'once' : a.repeat;
const msgPreview = a.random ? '*(random)*' : a.message.slice(0, 40);
const nextRun = a.paused ? 'paused' : `<t:${Math.floor(a.nextRun / 1000)}:R>`;
return `**${i + 1}.** ${status} | <#${a.channelId}> | ${repeatLabel} | ${nextRun}\n> ${msgPreview}`;
});
await ctx.reply({ embed: { title: '📋 Scheduled Announcements', description: lines.join('\n\n'), color: 0x5865f2 } });
});
mee6.command(
'announce pause',
{
description: 'Pause an announcement',
options: [
{ name: 'number', type: 'integer', description: 'Announcement number (from /announce list)', required: true },
],
},
async (ctx) => {
const num = ctx.option<number>('number');
const announcements = await mee6.store.get<Announcement[]>('announcements', []);
if (num < 1 || num > announcements.length) {
await ctx.reply('Invalid number. Use `/announce list` to see your announcements.');
return;
}
const announcement = announcements[num - 1];
if (announcement.paused) {
await ctx.reply('That announcement is already paused.');
return;
}
announcement.paused = true;
await mee6.store.set('announcements', announcements);
await mee6.schedule.cancel(announcement.id);
await ctx.reply(`⏸️ Paused announcement #${num}.`);
}
);
mee6.command(
'announce resume',
{
description: 'Resume a paused announcement',
options: [
{ name: 'number', type: 'integer', description: 'Announcement number (from /announce list)', required: true },
],
},
async (ctx) => {
const num = ctx.option<number>('number');
const announcements = await mee6.store.get<Announcement[]>('announcements', []);
if (num < 1 || num > announcements.length) {
await ctx.reply('Invalid number. Use `/announce list` to see your announcements.');
return;
}
const announcement = announcements[num - 1];
if (!announcement.paused) {
await ctx.reply('That announcement is already active.');
return;
}
// Recalculate next run
announcement.nextRun = getNextRun(announcement.nextRun, announcement.repeat, announcement.dayOfMonth);
announcement.paused = false;
await mee6.store.set('announcements', announcements);
const delaySeconds = Math.floor((announcement.nextRun - Date.now()) / 1000);
if (delaySeconds < 30) {
await ctx.reply('The next scheduled time has passed. Please reschedule with `/announce create`.');
return;
}
await mee6.schedule.once(announcement.id, delaySeconds, { id: announcement.id });
await ctx.reply(`▶️ Resumed announcement #${num}. Next run: <t:${Math.floor(announcement.nextRun / 1000)}:f>`);
}
);
mee6.on('scheduled', async (ctx) => {
if (!ctx.payload || typeof ctx.payload !== 'object' || !('id' in ctx.payload)) return;
const { id } = ctx.payload as { id: string };
const announcements = await mee6.store.get<Announcement[]>('announcements', []);
const announcement = announcements.find((a) => a.id === id);
if (!announcement || announcement.paused) return;
// Delete the previous message if this is a repeat
if (announcement.lastMessageId && announcement.repeat !== 'once') {
try {
await mee6.deleteMessage(announcement.channelId, announcement.lastMessageId);
} catch (e) {
mee6.log(`Could not delete previous message: ${e}`);
}
}
// Pick message
const messageText = announcement.random
? RANDOM_MESSAGES[Math.floor(Math.random() * RANDOM_MESSAGES.length)]
: announcement.message;
// Post
const sent = await ctx.send(announcement.channelId, messageText);
announcement.lastMessageId = sent.messageId;
// If repeating, schedule the next run
if (announcement.repeat !== 'once') {
announcement.nextRun = getNextRun(announcement.nextRun, announcement.repeat, announcement.dayOfMonth);
await mee6.store.set('announcements', announcements);
const delaySeconds = Math.floor((announcement.nextRun - Date.now()) / 1000);
if (delaySeconds >= 30) {
await mee6.schedule.once(id, delaySeconds, { id });
}
} else {
// Remove one-time announcements after posting
const filtered = announcements.filter((a) => a.id !== id);
await mee6.store.set('announcements', filtered);
}
});