Sending message to specific channel based on an argument
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have searched up and found multiple forum posts on both Reddit and StackOverflow where users are asking how to send a message to the specific channel, but I cannot find one where you can send to a specific channel using an Argument. What I mean is that you use
return bot.channels.get(channel).send(embed);
I have been testing around with this "function" and have managed to send the message to a specific channel, but it also includes the arg[0] aka the channel id. The command is
announce "CHANNEL ID" "MESSAGE"
It does send the embed with the message to that specific channel I input, but It adds the CHANNEL ID
to the embed, so I tried to use arg[0]
in the embed's .setDescription(arg[0])
but it didn't work. It spat out an error message to me which I have no idea what means. But maybe one if you pro's out there know what I can do. Here is the entire command Code:
if (cmd === `${prefix}announce`) {
console.log(message.author.username + " executed an Announcement in the channel #" + message.channel.name);
const embed = new Discord.RichEmbed()
.setColor("#e56b00")
.setAuthor("Announcement from " + message.author.username, message.author.avatarURL)
.setDescription(arg)
.setFooter(message.author.username)
.setTimestamp();
return bot.channels.get(channel).send(embed);
}
And here is the error code. Note that the error only pops up when I put arg[0]
in the .setDescription()
part of the embed. The channel let works fine with arg[1]
(node:7900) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at Client.bot.on (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsindex.js:32:34)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketshandlersMessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketsWebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:296:17)
at WebSocket.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibevent-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibwebsocket.js:137:47)
at Receiver.dataMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibreceiver.js:409:14)
(node:7900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
javascript bots discord discord.js
add a comment |
I have searched up and found multiple forum posts on both Reddit and StackOverflow where users are asking how to send a message to the specific channel, but I cannot find one where you can send to a specific channel using an Argument. What I mean is that you use
return bot.channels.get(channel).send(embed);
I have been testing around with this "function" and have managed to send the message to a specific channel, but it also includes the arg[0] aka the channel id. The command is
announce "CHANNEL ID" "MESSAGE"
It does send the embed with the message to that specific channel I input, but It adds the CHANNEL ID
to the embed, so I tried to use arg[0]
in the embed's .setDescription(arg[0])
but it didn't work. It spat out an error message to me which I have no idea what means. But maybe one if you pro's out there know what I can do. Here is the entire command Code:
if (cmd === `${prefix}announce`) {
console.log(message.author.username + " executed an Announcement in the channel #" + message.channel.name);
const embed = new Discord.RichEmbed()
.setColor("#e56b00")
.setAuthor("Announcement from " + message.author.username, message.author.avatarURL)
.setDescription(arg)
.setFooter(message.author.username)
.setTimestamp();
return bot.channels.get(channel).send(embed);
}
And here is the error code. Note that the error only pops up when I put arg[0]
in the .setDescription()
part of the embed. The channel let works fine with arg[1]
(node:7900) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at Client.bot.on (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsindex.js:32:34)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketshandlersMessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketsWebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:296:17)
at WebSocket.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibevent-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibwebsocket.js:137:47)
at Receiver.dataMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibreceiver.js:409:14)
(node:7900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
javascript bots discord discord.js
I tried, didn't let me use the code format. It just bugged out. Thanks I also need to add: pastebin.com/SKfe2f9g
– Marius
Nov 23 '18 at 13:43
Thank you George
– Marius
Nov 23 '18 at 13:46
add a comment |
I have searched up and found multiple forum posts on both Reddit and StackOverflow where users are asking how to send a message to the specific channel, but I cannot find one where you can send to a specific channel using an Argument. What I mean is that you use
return bot.channels.get(channel).send(embed);
I have been testing around with this "function" and have managed to send the message to a specific channel, but it also includes the arg[0] aka the channel id. The command is
announce "CHANNEL ID" "MESSAGE"
It does send the embed with the message to that specific channel I input, but It adds the CHANNEL ID
to the embed, so I tried to use arg[0]
in the embed's .setDescription(arg[0])
but it didn't work. It spat out an error message to me which I have no idea what means. But maybe one if you pro's out there know what I can do. Here is the entire command Code:
if (cmd === `${prefix}announce`) {
console.log(message.author.username + " executed an Announcement in the channel #" + message.channel.name);
const embed = new Discord.RichEmbed()
.setColor("#e56b00")
.setAuthor("Announcement from " + message.author.username, message.author.avatarURL)
.setDescription(arg)
.setFooter(message.author.username)
.setTimestamp();
return bot.channels.get(channel).send(embed);
}
And here is the error code. Note that the error only pops up when I put arg[0]
in the .setDescription()
part of the embed. The channel let works fine with arg[1]
(node:7900) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at Client.bot.on (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsindex.js:32:34)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketshandlersMessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketsWebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:296:17)
at WebSocket.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibevent-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibwebsocket.js:137:47)
at Receiver.dataMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibreceiver.js:409:14)
(node:7900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
javascript bots discord discord.js
I have searched up and found multiple forum posts on both Reddit and StackOverflow where users are asking how to send a message to the specific channel, but I cannot find one where you can send to a specific channel using an Argument. What I mean is that you use
return bot.channels.get(channel).send(embed);
I have been testing around with this "function" and have managed to send the message to a specific channel, but it also includes the arg[0] aka the channel id. The command is
announce "CHANNEL ID" "MESSAGE"
It does send the embed with the message to that specific channel I input, but It adds the CHANNEL ID
to the embed, so I tried to use arg[0]
in the embed's .setDescription(arg[0])
but it didn't work. It spat out an error message to me which I have no idea what means. But maybe one if you pro's out there know what I can do. Here is the entire command Code:
if (cmd === `${prefix}announce`) {
console.log(message.author.username + " executed an Announcement in the channel #" + message.channel.name);
const embed = new Discord.RichEmbed()
.setColor("#e56b00")
.setAuthor("Announcement from " + message.author.username, message.author.avatarURL)
.setDescription(arg)
.setFooter(message.author.username)
.setTimestamp();
return bot.channels.get(channel).send(embed);
}
And here is the error code. Note that the error only pops up when I put arg[0]
in the .setDescription()
part of the embed. The channel let works fine with arg[1]
(node:7900) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at Client.bot.on (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsindex.js:32:34)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketshandlersMessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketpacketsWebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_modulesdiscord.jssrcclientwebsocketWebSocketConnection.js:296:17)
at WebSocket.onMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibevent-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibwebsocket.js:137:47)
at Receiver.dataMessage (C:UsersAdminDesktopDiscord BotsDISCORDBOSS.jsnode_moduleswslibreceiver.js:409:14)
(node:7900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
javascript bots discord discord.js
javascript bots discord discord.js
edited Nov 23 '18 at 20:18
Federico Grandi
3,29531230
3,29531230
asked Nov 23 '18 at 13:40
MariusMarius
228
228
I tried, didn't let me use the code format. It just bugged out. Thanks I also need to add: pastebin.com/SKfe2f9g
– Marius
Nov 23 '18 at 13:43
Thank you George
– Marius
Nov 23 '18 at 13:46
add a comment |
I tried, didn't let me use the code format. It just bugged out. Thanks I also need to add: pastebin.com/SKfe2f9g
– Marius
Nov 23 '18 at 13:43
Thank you George
– Marius
Nov 23 '18 at 13:46
I tried, didn't let me use the code format. It just bugged out. Thanks I also need to add: pastebin.com/SKfe2f9g
– Marius
Nov 23 '18 at 13:43
I tried, didn't let me use the code format. It just bugged out. Thanks I also need to add: pastebin.com/SKfe2f9g
– Marius
Nov 23 '18 at 13:43
Thank you George
– Marius
Nov 23 '18 at 13:46
Thank you George
– Marius
Nov 23 '18 at 13:46
add a comment |
1 Answer
1
active
oldest
votes
You could use the message.mentions
property. So you would do the following:
let announceChannel = message.mentions.channels.first();
Then to send the message do the following;
message.guild.channels.find(t => t.id == announceChannel.id).send(myMessage);
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447803%2fsending-message-to-specific-channel-based-on-an-argument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use the message.mentions
property. So you would do the following:
let announceChannel = message.mentions.channels.first();
Then to send the message do the following;
message.guild.channels.find(t => t.id == announceChannel.id).send(myMessage);
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
add a comment |
You could use the message.mentions
property. So you would do the following:
let announceChannel = message.mentions.channels.first();
Then to send the message do the following;
message.guild.channels.find(t => t.id == announceChannel.id).send(myMessage);
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
add a comment |
You could use the message.mentions
property. So you would do the following:
let announceChannel = message.mentions.channels.first();
Then to send the message do the following;
message.guild.channels.find(t => t.id == announceChannel.id).send(myMessage);
You could use the message.mentions
property. So you would do the following:
let announceChannel = message.mentions.channels.first();
Then to send the message do the following;
message.guild.channels.find(t => t.id == announceChannel.id).send(myMessage);
answered Nov 23 '18 at 13:46
ethamitcethamitc
332211
332211
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
add a comment |
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
Will this let me get the channel by using #channel_name? Instead of ID? If not how would I do so? Also I will try the code once I get home.
– Marius
Nov 23 '18 at 14:19
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
@Marius Yes, A channel mention is #channel_name. So instead of having to copy the ID you can just mention the channel.
– ethamitc
Nov 23 '18 at 14:35
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Thank you for the code. The code works fine now. However, it still displays the #channel_name in front of the argument I provide. So when the announcement displays on the channel I selected it looks like this: Announcement from Marius H. #testing-channel-please-mute This is a test
– Marius
Nov 23 '18 at 19:50
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
Nevermind! I got it working with some magic :D Thank you either way. Here is the working code: let taggedChannel = message.mentions.channels.first(); let specifiedchannel = message.guild.channels.find(t => t.id == taggedChannel.id);; console.log ("The announcement was sent to " + specifiedchannel); if(!specifiedchannel) return message.channel.send("That channel does not exist!"); message.delete().catch(O_o=>{}); specifiedchannel.send(embed); console.log (message.author.username + " executed an Announcement in the channel #" + message.channel.name);
– Marius
Nov 23 '18 at 20:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447803%2fsending-message-to-specific-channel-based-on-an-argument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I tried, didn't let me use the code format. It just bugged out. Thanks I also need to add: pastebin.com/SKfe2f9g
– Marius
Nov 23 '18 at 13:43
Thank you George
– Marius
Nov 23 '18 at 13:46