I'm basically trying to make code into where it's user-friendly. Basically into a command. There are two commands but I'm only working on one at the moment. A one-time message channel. I'd like to make it where you can add a channel where if you speak once in the channel, the bot will give you a role that bans you from speaking in the channel.
The command is this
d!omca roleid channelid
then it will be added to the bot.
Here is the code I used.
var commando = require('discord.js-commando');
var discord = require('discord.js');
const Discord = require("discord.js");
class omchannel extends commando.Command
{
constructor(client)
{
super(client,{
name: "omca",
description: "Sets the one time message channel.",
memberName: "omca",
group: "channel",
usage: "d!omca CHANNELID",
accesableby: "Moderators",
aliases: ["oneadd", "onemessagechanneladdition"]
});
}
async run(message, args)
{
if(!message.member.hasPermission(["MANAGE_CHANNELS", "MANAGE_ROLES"])) return message.channel.send("You don't have sufficent permissions to use this!")
let role = message.guild.roles.find(role => role.id == args[0]) || message.mentions.roles.get(args[0])
if(role) return message.channel.send("You did not specify a role ID. You can get a ID by doing backslash@ROLENAME (Make sure role is mentionable).")
let channel = (channel => channel.id == args[1]) || message.channel.id(args[1])
if(channel) return message.channel.send("You did not specify a channel ID. You can get one by going into Dev Mode, right click the channel in the sidebar, and press Copy ID.")
if(message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have sufficent permissions! Give me them!")
if(message.channel.id == args[0]) {
let bannedRole = message.guild.roles.find(role => role.name === args[1])
message.member.addRole(bannedRole)
}
}
}
module.exports = omchannel;
I'm basically turning this code into something where the user can customize it.
doopliss.on('message', function(message) { {
if(message.channel.id == 'argument2') {
let bannedRole = message.guild.roles.find(role => role.name === 'argument1');
message.member.addRole(bannedRole);
}
}})
Instead of using the role name, I want to use the role ID.
Expect : A command where you can customize what channel is a one-time message channel, and you get a role assigned after.
Happens : Discord Bot works, but doesn't work. (The bot functions fine but the wrong message is being said)