WIP on addreaction detection
This commit is contained in:
parent
63e4ba7bc3
commit
c7edb070bf
2
deps.ts
2
deps.ts
|
@ -4,7 +4,7 @@ import config from './config.ts';
|
||||||
import { LOCALMODE } from './flags.ts';
|
import { LOCALMODE } from './flags.ts';
|
||||||
export const botId = getBotIdFromToken(LOCALMODE ? config.localtoken : config.token);
|
export const botId = getBotIdFromToken(LOCALMODE ? config.localtoken : config.token);
|
||||||
|
|
||||||
export { ActivityTypes, createBot, editBotNickname, editBotStatus, Intents, sendMessage, startBot } from 'https://deno.land/x/discordeno@13.0.0/mod.ts';
|
export { ActivityTypes, createBot, editBotNickname, editBotStatus, Intents, sendMessage, startBot, getReactions } from 'https://deno.land/x/discordeno@13.0.0/mod.ts';
|
||||||
|
|
||||||
export type { Bot, CreateMessage, Emoji, EventHandlers, Guild, Member, Message, User } from 'https://deno.land/x/discordeno@13.0.0/mod.ts';
|
export type { Bot, CreateMessage, Emoji, EventHandlers, Guild, Member, Message, User } from 'https://deno.land/x/discordeno@13.0.0/mod.ts';
|
||||||
|
|
||||||
|
|
2
mod.ts
2
mod.ts
|
@ -22,7 +22,7 @@ initLog('logs', DEBUG);
|
||||||
// Start up the Discord Bot
|
// Start up the Discord Bot
|
||||||
const bot = createBot({
|
const bot = createBot({
|
||||||
token: LOCALMODE ? config.localtoken : config.token,
|
token: LOCALMODE ? config.localtoken : config.token,
|
||||||
intents: Intents.MessageContent | Intents.GuildMessages | Intents.DirectMessages | Intents.Guilds,
|
intents: Intents.MessageContent | Intents.GuildMessages | Intents.DirectMessages | Intents.Guilds | Intents.GuildMessageReactions,
|
||||||
events,
|
events,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,9 @@ import {
|
||||||
log,
|
log,
|
||||||
LT,
|
LT,
|
||||||
// Discordeno deps
|
// Discordeno deps
|
||||||
Message,
|
Message,getReactions,
|
||||||
} from '../../deps.ts';
|
} from '../../deps.ts';
|
||||||
import commands from '../commands/_index.ts';
|
import commands from '../commands/_index.ts';
|
||||||
import { pollReactions } from '../functions/pollReactions.ts';
|
|
||||||
import functions from '../functions/_index.ts';
|
import functions from '../functions/_index.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from '../utils.ts';
|
||||||
|
|
||||||
|
@ -78,6 +77,17 @@ export const messageCreate = async (bot: Bot, message: Message) => {
|
||||||
commands.sendMessage(bot, message, args);
|
commands.sendMessage(bot, message, args);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'test':
|
||||||
|
const test = await bot.helpers.getMessage(413640605491658754n, 1016090989816987701n);
|
||||||
|
console.log(test)
|
||||||
|
if (test.reactions && test.reactions.length) {
|
||||||
|
console.log(test.reactions[0])
|
||||||
|
const what = `${test.reactions[0].emoji.name}${test.reactions[0].emoji.id ? `:${test.reactions[0].emoji.id}` : ''}`;
|
||||||
|
console.log(what)
|
||||||
|
await getReactions(bot, 413640605491658754n, 1016090989816987701n, what)
|
||||||
|
}
|
||||||
|
// bot.helpers
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Non-standard commands
|
// Non-standard commands
|
||||||
console.log(`${command} WIP`);
|
console.log(`${command} WIP`);
|
||||||
|
|
|
@ -4,9 +4,21 @@ import {
|
||||||
Bot,
|
Bot,
|
||||||
} from '../../deps.ts';
|
} from '../../deps.ts';
|
||||||
import { ReactionAdd } from '../types/eventTypes.ts';
|
import { ReactionAdd } from '../types/eventTypes.ts';
|
||||||
|
import utils from '../utils.ts';
|
||||||
|
import functions from '../functions/_index.ts';
|
||||||
|
|
||||||
export const reactionAdd = (bot: Bot, payload: ReactionAdd) => {
|
export const reactionAdd = async (bot: Bot, payload: ReactionAdd) => {
|
||||||
if (config.pollChannels.includes(payload.channelId)) {
|
if (config.pollChannels.includes(payload.channelId)) {
|
||||||
console.log(payload);
|
try {
|
||||||
|
const message = await bot.helpers.getMessage(payload.channelId, payload.messageId);
|
||||||
|
const onlyOneWordRX = /(only one)/g
|
||||||
|
if (message.content.toLowerCase().includes('clan poll') && message.content.toLowerCase().match(onlyOneWordRX)?.length) {
|
||||||
|
functions.onlyOneReaction(bot, message);
|
||||||
|
|
||||||
|
// bot.helpers.getReactions()
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
utils.commonLoggers.messageGetError('reactionAdd.ts:14', `failed to get message ${payload.channelId}-${payload.messageId}`, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { pollReactions } from './pollReactions.ts';
|
import { pollReactions } from './pollReactions.ts';
|
||||||
|
import { onlyOneReaction } from './onlyOneReaction.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
pollReactions,
|
pollReactions,
|
||||||
|
onlyOneReaction,
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import {
|
||||||
|
// Discordeno deps
|
||||||
|
Bot,
|
||||||
|
} from "../../deps.ts";
|
||||||
|
|
||||||
|
export const onlyOneReaction = (bot: Bot) => { };
|
Loading…
Reference in New Issue