How to send a global message?












0















I'm wanting to send a message (in a way as a global announcement to all servers) about important information regarding the bot. In this instance, regarding unplanned downtime.





guild.channels.find(t => t.name == 'general').send I think.. is correct coding to find a text-channel with the name #general. (I want to add 'announcements' / 'lounge') as a back-up if #general isn't an option.



I have no clue where to start on coding up this command.
Any help would be appreciated.





BELOW YOU CAN FIND A SEMI-TEMPLATE / IDEA OF WHAT I WANT?



some parts of the code are chopped out, this is no way effects below.



exports.exec = async (Peepo, message, args) => {  

// Fires Error message that the command wasn't ran correctly.
if (args.length < 1) {
return message.channel.send({embed: {
color: 0,
description: `${message.author} add some words.`
}
});
}
// Fires Error message that the command wasn't ran correctly.


// FETCH CHANNELS TO SEND ANNOUNCEMENT TO


message.channel.send({
embed: {
color: 0,
title: ` ANNOUNCEMENT`,
description: `${guild.name}{`,
footer: {
text: "${guild.name} this is an official message from the creator of this bot."

};

/* * * * */









share|improve this question

























  • Maybe you can use Guild.defaultChannel Note: This is deprecated and may be removed in other versions

    – Koen Hollander
    Nov 26 '18 at 14:40











  • I'm on 11.4.2 for Discord JS I don't believe it works anymore sadly

    – Imaginebeingme
    Nov 26 '18 at 14:54
















0















I'm wanting to send a message (in a way as a global announcement to all servers) about important information regarding the bot. In this instance, regarding unplanned downtime.





guild.channels.find(t => t.name == 'general').send I think.. is correct coding to find a text-channel with the name #general. (I want to add 'announcements' / 'lounge') as a back-up if #general isn't an option.



I have no clue where to start on coding up this command.
Any help would be appreciated.





BELOW YOU CAN FIND A SEMI-TEMPLATE / IDEA OF WHAT I WANT?



some parts of the code are chopped out, this is no way effects below.



exports.exec = async (Peepo, message, args) => {  

// Fires Error message that the command wasn't ran correctly.
if (args.length < 1) {
return message.channel.send({embed: {
color: 0,
description: `${message.author} add some words.`
}
});
}
// Fires Error message that the command wasn't ran correctly.


// FETCH CHANNELS TO SEND ANNOUNCEMENT TO


message.channel.send({
embed: {
color: 0,
title: ` ANNOUNCEMENT`,
description: `${guild.name}{`,
footer: {
text: "${guild.name} this is an official message from the creator of this bot."

};

/* * * * */









share|improve this question

























  • Maybe you can use Guild.defaultChannel Note: This is deprecated and may be removed in other versions

    – Koen Hollander
    Nov 26 '18 at 14:40











  • I'm on 11.4.2 for Discord JS I don't believe it works anymore sadly

    – Imaginebeingme
    Nov 26 '18 at 14:54














0












0








0


0






I'm wanting to send a message (in a way as a global announcement to all servers) about important information regarding the bot. In this instance, regarding unplanned downtime.





guild.channels.find(t => t.name == 'general').send I think.. is correct coding to find a text-channel with the name #general. (I want to add 'announcements' / 'lounge') as a back-up if #general isn't an option.



I have no clue where to start on coding up this command.
Any help would be appreciated.





BELOW YOU CAN FIND A SEMI-TEMPLATE / IDEA OF WHAT I WANT?



some parts of the code are chopped out, this is no way effects below.



exports.exec = async (Peepo, message, args) => {  

// Fires Error message that the command wasn't ran correctly.
if (args.length < 1) {
return message.channel.send({embed: {
color: 0,
description: `${message.author} add some words.`
}
});
}
// Fires Error message that the command wasn't ran correctly.


// FETCH CHANNELS TO SEND ANNOUNCEMENT TO


message.channel.send({
embed: {
color: 0,
title: ` ANNOUNCEMENT`,
description: `${guild.name}{`,
footer: {
text: "${guild.name} this is an official message from the creator of this bot."

};

/* * * * */









share|improve this question
















I'm wanting to send a message (in a way as a global announcement to all servers) about important information regarding the bot. In this instance, regarding unplanned downtime.





guild.channels.find(t => t.name == 'general').send I think.. is correct coding to find a text-channel with the name #general. (I want to add 'announcements' / 'lounge') as a back-up if #general isn't an option.



I have no clue where to start on coding up this command.
Any help would be appreciated.





BELOW YOU CAN FIND A SEMI-TEMPLATE / IDEA OF WHAT I WANT?



some parts of the code are chopped out, this is no way effects below.



exports.exec = async (Peepo, message, args) => {  

// Fires Error message that the command wasn't ran correctly.
if (args.length < 1) {
return message.channel.send({embed: {
color: 0,
description: `${message.author} add some words.`
}
});
}
// Fires Error message that the command wasn't ran correctly.


// FETCH CHANNELS TO SEND ANNOUNCEMENT TO


message.channel.send({
embed: {
color: 0,
title: ` ANNOUNCEMENT`,
description: `${guild.name}{`,
footer: {
text: "${guild.name} this is an official message from the creator of this bot."

};

/* * * * */






discord.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 16:44









Federico Grandi

3,28531230




3,28531230










asked Nov 26 '18 at 12:36









ImaginebeingmeImaginebeingme

308




308













  • Maybe you can use Guild.defaultChannel Note: This is deprecated and may be removed in other versions

    – Koen Hollander
    Nov 26 '18 at 14:40











  • I'm on 11.4.2 for Discord JS I don't believe it works anymore sadly

    – Imaginebeingme
    Nov 26 '18 at 14:54



















  • Maybe you can use Guild.defaultChannel Note: This is deprecated and may be removed in other versions

    – Koen Hollander
    Nov 26 '18 at 14:40











  • I'm on 11.4.2 for Discord JS I don't believe it works anymore sadly

    – Imaginebeingme
    Nov 26 '18 at 14:54

















Maybe you can use Guild.defaultChannel Note: This is deprecated and may be removed in other versions

– Koen Hollander
Nov 26 '18 at 14:40





Maybe you can use Guild.defaultChannel Note: This is deprecated and may be removed in other versions

– Koen Hollander
Nov 26 '18 at 14:40













I'm on 11.4.2 for Discord JS I don't believe it works anymore sadly

– Imaginebeingme
Nov 26 '18 at 14:54





I'm on 11.4.2 for Discord JS I don't believe it works anymore sadly

– Imaginebeingme
Nov 26 '18 at 14:54












2 Answers
2






active

oldest

votes


















2














The easiest solution would be to message the guild owner.



client.guilds.forEach(guild => {
client.users.get(guild.ownerID).send("Important announcement!");
});


Every guild has an owner, so there's no worry about a server renaming their #general channel.






share|improve this answer
























  • This is actually a really smart and unique way of doing it. Many thanks for this.

    – Imaginebeingme
    Nov 28 '18 at 0:48



















1














Below is a basic forEach loop that will send a message to the general channel of every server - do note it will not send if the guild doesn't have a #general



client.guilds.forEach(guild => {
guild.channels.find(t => t.name == 'general').send('Some important announcement to all guilds!');
})





share|improve this answer
























    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53481254%2fhow-to-send-a-global-message%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    The easiest solution would be to message the guild owner.



    client.guilds.forEach(guild => {
    client.users.get(guild.ownerID).send("Important announcement!");
    });


    Every guild has an owner, so there's no worry about a server renaming their #general channel.






    share|improve this answer
























    • This is actually a really smart and unique way of doing it. Many thanks for this.

      – Imaginebeingme
      Nov 28 '18 at 0:48
















    2














    The easiest solution would be to message the guild owner.



    client.guilds.forEach(guild => {
    client.users.get(guild.ownerID).send("Important announcement!");
    });


    Every guild has an owner, so there's no worry about a server renaming their #general channel.






    share|improve this answer
























    • This is actually a really smart and unique way of doing it. Many thanks for this.

      – Imaginebeingme
      Nov 28 '18 at 0:48














    2












    2








    2







    The easiest solution would be to message the guild owner.



    client.guilds.forEach(guild => {
    client.users.get(guild.ownerID).send("Important announcement!");
    });


    Every guild has an owner, so there's no worry about a server renaming their #general channel.






    share|improve this answer













    The easiest solution would be to message the guild owner.



    client.guilds.forEach(guild => {
    client.users.get(guild.ownerID).send("Important announcement!");
    });


    Every guild has an owner, so there's no worry about a server renaming their #general channel.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 27 '18 at 16:40









    Thomas BlasquezThomas Blasquez

    435




    435













    • This is actually a really smart and unique way of doing it. Many thanks for this.

      – Imaginebeingme
      Nov 28 '18 at 0:48



















    • This is actually a really smart and unique way of doing it. Many thanks for this.

      – Imaginebeingme
      Nov 28 '18 at 0:48

















    This is actually a really smart and unique way of doing it. Many thanks for this.

    – Imaginebeingme
    Nov 28 '18 at 0:48





    This is actually a really smart and unique way of doing it. Many thanks for this.

    – Imaginebeingme
    Nov 28 '18 at 0:48













    1














    Below is a basic forEach loop that will send a message to the general channel of every server - do note it will not send if the guild doesn't have a #general



    client.guilds.forEach(guild => {
    guild.channels.find(t => t.name == 'general').send('Some important announcement to all guilds!');
    })





    share|improve this answer




























      1














      Below is a basic forEach loop that will send a message to the general channel of every server - do note it will not send if the guild doesn't have a #general



      client.guilds.forEach(guild => {
      guild.channels.find(t => t.name == 'general').send('Some important announcement to all guilds!');
      })





      share|improve this answer


























        1












        1








        1







        Below is a basic forEach loop that will send a message to the general channel of every server - do note it will not send if the guild doesn't have a #general



        client.guilds.forEach(guild => {
        guild.channels.find(t => t.name == 'general').send('Some important announcement to all guilds!');
        })





        share|improve this answer













        Below is a basic forEach loop that will send a message to the general channel of every server - do note it will not send if the guild doesn't have a #general



        client.guilds.forEach(guild => {
        guild.channels.find(t => t.name == 'general').send('Some important announcement to all guilds!');
        })






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 13:48









        ethamitcethamitc

        332211




        332211






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53481254%2fhow-to-send-a-global-message%23new-answer', 'question_page');
            }
            );

            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







            Popular posts from this blog

            Create new schema in PostgreSQL using DBeaver

            Deepest pit of an array with Javascript: test on Codility

            Costa Masnaga