Coder Social home page Coder Social logo

dumsane's Introduction

dumsane's People

Contributors

meqativ avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

dumsane's Issues

[NoDelete] Fic own messages getting deleted

Change how the system work by replacing on how we store the data and adding flags for it, due the event firing twice.

changes

  • Replace how we store the datas
let delet = {}; 
  • Delet data example
// type Object {}
{
  "<EventID>" : {
    "arg": "<MessageDataArguments[Array]>",
    "flag": "< 1 | 2 >" // 1 = Cached and modified, 2 = Good for deletion
  }
}
  • Error Message for dismissable Message, this can be modified before all checks occured.
let message = "This message was deleted";

First Check

  • Check if the Message already been cached before or not, if not we push it into delet with several datas in it and modify the message to RED Error message that dismissable.
if( !delet[event.id] ) {
  args[0] = {
    type: "MESSAGE_EDIT_FAILED_AUTOMOD",
    messageData: {
      type: 1,
      message: {
        channelId: event.channelId,
        messageId: event.id,
      },
    },
    errorResponseBody: {
      code: 200000,
      message,
    },
  };
  delet[event.id] = {
    arg: args,
    flag: 1
  };
  return args;
}

Second Check

  • used to handle the followed up event with the same Id and prevent it to delete the already modified message we do on first check, so i create this check that check if it already available on delet and then if the flag of said id is 1, if both statement is true then we update the flag to 2, then we replace the msg with arg that contains the modified version to avoid it deleting the msg by accident, basically forcing it to not deleting it by updating it with the same stuff, this works for no reason
if( delet[event.id] && delet[event.id]['flag'] == 1 ) {
  delet[event.id]['flag'] = 2;
  return delet[event.id]["arg"];
};

Third Check

  • here we check if it exist on delet, and if the flag is 2, if statements are true, then we just delete the key from delet and remove the message.
if( delet[event.id] && delet[event.id]['flag'] == 2 ) {
  delete delet[event.id], delet;
  return args;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.