| Discord Bot Handler | Announcement System

Status
This thread has been locked.

IAmVolvic

Supreme
Feedback score
4
Posts
177
Reactions
49
Resources
0
Can someone help me with a message or announcement system? so I have a database(SQL) in the database I have a table called announcement | announcement_message | active | , What I want the bot to do is it will keep checking the database every 2 minutes and if it sees that active = 1 then send a message to announcement channel with the announcement message(it will only post once) if it sees Active = 0 then delete the last message it made in the channel.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

LamerGamerYT

Discord Bots - Discord Setups
Premium
Feedback score
24
Posts
329
Reactions
84
Resources
0
Which programming language are you using?
 

IAmVolvic

Supreme
Feedback score
4
Posts
177
Reactions
49
Resources
0
Never mind then. I could have told you about this, if it was in Java.
It is xD But could you help me with this?

How can I get the layout of the command right?
Code:
const Discord = require("discord.js");
const ms = require("ms");

module.exports = {
    name: "announce",
    description: "announce.",
    execute: async (message, args) => {
    let sChannel = message.mentions.channels.first();
    if(!sChannel) return message.channel.send("Couldn't find chanel.");
    let sMessage = args[22];
    let dayInMilliseconds = 4432;
    let time = args[1];
    if(!mutetime) return console.log(mutetime);
    console.log(time);
 setInterval (function () {
     console.log(time);
              sChannel.send(`${sMessage}`).then(msg => msg.delete(ms(time)));              //send it to whatever channel the bot has permissions to send on
         }, ms(time));
    }
}
The command is trying to do this !announce #CHANNEL(#announcements) TIME(30s = 30 seconds) MESSAGE(Hello and welcome to our server)

I can't seem to understand how to get
Code:
let sMessage = args[22];
let time = args[1];
To get the lines right
 

LamerGamerYT

Discord Bots - Discord Setups
Premium
Feedback score
24
Posts
329
Reactions
84
Resources
0
It is xD But could you help me with this?

How can I get the layout of the command right?
Code:
const Discord = require("discord.js");
const ms = require("ms");

module.exports = {
    name: "announce",
    description: "announce.",
    execute: async (message, args) => {
    let sChannel = message.mentions.channels.first();
    if(!sChannel) return message.channel.send("Couldn't find chanel.");
    let sMessage = args[22];
    let dayInMilliseconds = 4432;
    let time = args[1];
    if(!mutetime) return console.log(mutetime);
    console.log(time);
 setInterval (function () {
     console.log(time);
              sChannel.send(`${sMessage}`).then(msg => msg.delete(ms(time)));              //send it to whatever channel the bot has permissions to send on
         }, ms(time));
    }
}
The command is trying to do this !announce #CHANNEL(#announcements) TIME(30s = 30 seconds) MESSAGE(Hello and welcome to our server)

I can't seem to understand how to get
Code:
let sMessage = args[22];
let time = args[1];
To get the lines right
Why do you have sMessage as args[22] , that will only get the 22th word of the message...
 

IAmVolvic

Supreme
Feedback score
4
Posts
177
Reactions
49
Resources
0
Why do you have sMessage as args[22] , that will only get the 22th word of the message...
I now did it like this
Code:
 let sMessage = args.slice(2).join(" ");
let mutetime = args[1];

Everything works fine till if someone breaks the first bit of the command like a typo,

!announce #yulxvol_chat 30s My name is Volvic! - Works fine

!announce "typo" #yulxvol_chat 30s My name is Volvic! - This will spam the chat like crazy[DOUBLEPOST=1533315279][/DOUBLEPOST]
Java is not equal to Javascript
Yeah you're right, Keep thinking they are lol
 
Last edited:

LamerGamerYT

Discord Bots - Discord Setups
Premium
Feedback score
24
Posts
329
Reactions
84
Resources
0
I now did it like this
Code:
 let sMessage = args.slice(2).join(" ");
let mutetime = args[1];

Everything works fine till if someone breaks the first bit of the command like a typo,

!announce #yulxvol_chat 30s My name is Volvic! - Works fine

!announce "typo" #yulxvol_chat 30s My name is Volvic! - This will spam the chat like crazy[DOUBLEPOST=1533315279][/DOUBLEPOST]
Yeah you're right, Keep thinking they are lol
Check if "typo" is a valid channel or not first, then proceed with the command. If it is not, just stop the command then and there!
 

IAmVolvic

Supreme
Feedback score
4
Posts
177
Reactions
49
Resources
0
Check if "typo" is a valid channel or not first, then proceed with the command. If it is not, just stop the command then and there!
Thats not what I mean xD

If someone did this command !announce das32d #yulxvol_chat 30s My name is Volvic! - This will spam the chat like crazy
 
Status
This thread has been locked.
Top