Aoi.js Plugins!
Requires Node V16+
Downloading:
npm i aoi.js-plugins@latest
Options:
- Giveaways
- Command Handler
- Dashboard (Discord Oauth help.)
Handler
Usage:
const aoijs = require("aoi.js");
const { Handler } = require("aoi.js-plugins");
const bot = new aoijs.Bot({
token: "your very secret token", //Discord Bot Token
prefix: "abcdefg", //Discord Bot Prefix
intents: "all" //Discord Intents
});
const handler = new Handler({
bot:bot,// your bot client. (required)
aoijs:aoijs,// aoi.js variable you have defined as. (required)
varfile:"vars.js",//variables file.
callbackfile:"callbacks.js",//callbacks file.
commandsfolder:"/commands/",//commands folder.
statusfolder:"/status/"//statuses folder.
})
vars.js
:
module.exports = {
hello:"Hi",
ok:"ok indeed"
}
callbacks.js
:
module.exports = (bot) => {
bot.onMessage();
bot.onInteractionCreate();
}
status folder
:
status1.js
:
module.exports=({
text:"Hello World!",
type:"PLAYING",
time:"12"
})
status2.js
:
module.exports=({
text:"with Bumblebee!",
type:"PLAYING",
time:"12"
})
and so on...
Dashboard
Useage:
const { Dash }=require("aoi.js-plugins")
const dash = new Dash({
bot:bot,//your bot
clientID:"943831369832861746",//client id
clientSecret:process.env.s,//client secret
redirectURI:"https://example.com/callback"//redirect uri
//see example dashboard for more info! https://github.com/Bumblebee-3/Aoi.js-dashboard-with-aoi.js-plugins
})
Functions Till Now:
All these are Dash functions. (needs to be awaited)
-
generateURL()
=> create a login link for the bot. -
getAccessToken(code)
=> from the code getting the user access token. -
getUser(accesstoken)
=> Getting basic details of the user. -
getGuilds(accesstoken)
=> Getting users guilds. -
getAdminGuilds(accesstoken)
=> Getting Guilds where the user is admin. -
getCommonAdminGuilds(accesstoken)
=> Getting guilds where user is admin and bot is there.
This dashboard extension was made with help of "Discord-oauth2" to make the creation of dashboards easier for all.
Example dashboard: here
For more inermediate developers, who want to use more functions of discord-oauth2 with aoi.js-plugins you can use this
const oauth = dash.oauth
and with that using discord-oauth2 callbacks.
Giveaways:
const { Giveaways } = require("./plugins.js")
const aoijs = require("aoi.js");
const bot = new aoijs.Bot({
token:"your token",
prefix:"your prefix",
intents:"all"
})
Constructor:
let gm = new Giveaways({
client:bot,//Your aoi.js client
storage:"storage.json",//storage file
botsCanWin:false,//can bots win?
embedColor: '#FF0000',//giveaway embed color
reaction: '🎉',//giveaway reaction emoji
embedColorEnd: '#000000',//ended giveaway message embed color.
reaction: '🎉',//reaction to join the giveaway.
dmWinMessage:"Congratulations, {member.username}!! You won {prize}. Link:{link}",//message dmed to the winner on giveaway completion
dmJoinMessage:"Hey {member.username} || <@{member.id}>!! You seemed to have joined the giveaway for {prize}. All the best! Link:{link}",//message dmed to member on joining the giveaway
dmLeaveMessage:"Hey {member.username}!! You seemed to have left the giveaway for {prize}. Link:{link}. If this wasn't you, please re-add your reaction!",//message dmed to member on leaving the giveaway/reaction being removed.
startMessages:{
giveaway:"🎉🎉 **NEW GIVEAWAY** 🎉🎉",//the message above the embed on giveaway start
giveawayEnded:"🎉🎉 **GIVEAWAY ENDED** 🎉🎉",//the message above the embed on giveaway end
inviteToParticipate:"React with 🎉 to participate!",//inviting to participate
winMessage:"Congratulations, {winners}! You won **{this.prize}**!\n{this.messageURL}",//on winning the message to send.
drawing:"Ending: {timestamp}",//picking winners in {timestamp}
embedFooter:"{this.winnerCount} winner(s)",//footer of the giveaway
noWinner:"Giveaway cancelled, no valid participations. ",//when no winners are there
winners:"Winner(s):",//winner count
endedAt:"Ended at",//on giveaway end, shows what time the giveaway ended at
hostedBy:"Hosted by: {this.hostedBy}"//hosted by {this.hostedBy}
},
lastChance:{
enabled:true,//is lastchance enabled?
content:"⚠️ **LAST CHANCE TO ENTER !** ⚠️",//last chance content
threshold:"30s",//time before the giveaway that it should get edited
embedColor:"#FF0000"//embed color
}
})
gm.loadFuncs()//loading the cutom functions.
Currently all params are needed!
Options in DM message:
-
{member.username}
=> User's username. -
{member.id}
=> User's ID. -
{prize}
=> prize of the giveaway. -
{link}
=> Link of the giveaway.
FUNCTIONS TILL NOW:
-
$Gstart[<time>;<winners>;<prize>;<channelid>;<hostid>]
=> Start the giveaway.
Parameters:
-
time
: Time of the giveaway. For example:30s
,1m
,1h
, e.t.c. -
winners
: Number of winners. For example:1
,2
,7
, e.t.c. -
prize
: Prize of the giveaway. For example:Discord Nitro $9.99
,XBOX game pass ultimate
, e.t.c. -
channelid
: ID of the channel where the giveaway has to be hosted. -
hostid
: ID of the giveaway host.
-
$Greroll[<messageid>;<winners>]
=> Reroll a giveaway (new winners).
Parameters:
-
messageid
: Message id of the giveaway to reroll. -
winners
: Number of winners to reroll. For example:1
,2
,7
, e.t.c.
-
$Gedit[<messageid>;<property>;<data>]
=> Edit a giveaway.
Parameters:
-
messageid
: Message id of the giveaway to edit. -
property
: Property of the giveaway. For example:prize
,winners
,time
. -
data
: Data depends on the property.
If property
is prize
then data needs to be a string [prize name].
If property
is winners
then data needs to be a integer [number of winners].
If property
is time
then data needs to be string [time i.e. 10s
, 1d
, -10m
(to remove time)].
-
$Gdelete[<messageid>]
=> Delete a giveaway.
Parameters:
-
messageid
: Message id of the giveaway to delete.
-
$Gpause[<messageid>]
=> Pause a giveaway.
Parameters:
-
messageid
: Message id of the giveaway to pause.
-
$GUnpause[<messageid>]
=> Unpause a giveaway.
Parameters:
-
messageid
: Message id of the giveaway to unpause.
-
$isGiveaway[messageid]
=> If the message id is a giveaway.
Parameters:
-
messageid
: Message id of to check if it is a giveaway.
-
$isActiveGiveaway[messageid]
=> If the message id is an active [going on currently] giveaway.
Parameters:
-
messageid
: Message id of to check if it is a active giveaway.
Note:
If using $Gstart
[Giveaways], The packace automaticaly ends the process. If using replit, use: .replit
with
run="while true; do node index.js; sleep 2; done"